/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: XSDurationValidator.java,v 1.2 2008/06/25 05:53:07 qcheng Exp $
*
*/
/**
* Validator for <code>xs:duration</code> format.
* The validation of the cache duration is done based on the following:
* If the number of years, months, days, hours, minutes, or seconds in
* any expression equals zero, the number and its corresponding
* designator may be omitted. However, at least one number and its
* designator must be present.
* The seconds part may have a decimal fraction.
* The designator 'T' must be absent if and only if all of the
* time items are absent.
* The designator 'P' must always be present.
*/
public class XSDurationValidator
extends ValidatorBase
{
private static boolean debug = false;
private XSDurationValidator() {
}
/**
* Returns an instance of this validator.
*
* @return an instance of this validator.
*/
return instance;
}
/* validate the cache duration string */
throws ValidationException
{
// if the string is null or empty or less then 3 charactors
// then throw error
}
// expecting this format P1Y2M4DT9H8M20S
// first character should be a P
}
// time data validation
// T without time elements H M S error
}
} else {
// time elements without T not allowed.
}
}
int start = 0;
return;
}
throws ValidationException
{
int value = 0;
try {
if (value < 0) {
}
} catch (NumberFormatException e) {
}
return value;
}
throws ValidationException
{
double value = 0;
try {
if (value < 0) {
}
} catch (NumberFormatException e) {
}
return value;
}
/* Process the Time String in the Duration */
}
// Seconds should be preceded by a decimal number , if there
// is a "." then should have some number after it.
}
}
int start=0;
if (idxH != -1) {
}
if (idxM != -1) {
}
if (idxS != -1) {
throw new ValidationException(
resourceBundleName, "errorCode4");
}
}
}
}
/* Process the Date String in the Duration */
}
}
}
int start = 0;
if (idxY != -1) {
}
if (idxM != -1) {
}
if (idxD != -1) {
}
}
return;
}
}