本文整理汇总了Java中org.relaxng.datatype.ValidationContext类的典型用法代码示例。如果您正苦于以下问题:Java ValidationContext类的具体用法?Java ValidationContext怎么用?Java ValidationContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ValidationContext类属于org.relaxng.datatype包,在下文中一共展示了ValidationContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkValue
import org.relaxng.datatype.ValidationContext; //导入依赖的package包/类
public void checkValue(String value, ValidationContext context)
throws DatatypeException
{
super.checkValid(value, context);
int len = value.length();
if (len == 0)
throw new DatatypeException(0, "invalid negative integer value");
for (int i = 0; i < len; i++)
{
char c = value.charAt(i);
if (c == '-')
{
if (i == 0)
continue;
}
else if (c >= 0x30 && c <= 0x39)
continue;
throw new DatatypeException(i, "invalid negative integer value");
}
}
示例2: checkValid
import org.relaxng.datatype.ValidationContext; //导入依赖的package包/类
public void checkValid(String value, ValidationContext context)
throws DatatypeException
{
super.checkValid(value, context);
int len = value.length();
if (len == 0)
throw new DatatypeException(0, "invalid token value");
if (value.charAt(0) == ' ' || value.charAt(len - 1) == ' ')
throw new DatatypeException(0, "invalid token value");
char last = '\u0000';
for (int i = 0; i < len; i++)
{
char c = value.charAt(i);
if (c == 0x0a || c == 0x0d || c == 0x09)
throw new DatatypeException(i, "invalid token value");
if (c == ' ' && last == ' ')
throw new DatatypeException(i, "invalid token value");
last = c;
}
}
示例3: checkValid
import org.relaxng.datatype.ValidationContext; //导入依赖的package包/类
public void checkValid(String value, ValidationContext context)
throws DatatypeException
{
super.checkValid(value, context);
int len = value.length();
CPStringBuilder buf = new CPStringBuilder();
for (int i = 0; i < len; i++)
{
char c = value.charAt(i);
if (c == ' ')
{
String token = buf.toString();
if (token.length() > 0)
checkNmtoken(token, i);
buf.setLength(0);
}
else
buf.append(c);
}
checkNmtoken(buf.toString(), len);
}
示例4: checkValid
import org.relaxng.datatype.ValidationContext; //导入依赖的package包/类
public void checkValid(String value, ValidationContext context)
throws DatatypeException
{
super.checkValid(value, context);
if (SPECIAL.contains(value))
return;
try
{
Double.parseDouble(value);
}
catch (NumberFormatException e)
{
DatatypeException e2 = new DatatypeException("invalid double value");
e2.initCause(e);
throw e2;
}
}
示例5: checkValid
import org.relaxng.datatype.ValidationContext; //导入依赖的package包/类
public void checkValid(String value, ValidationContext context)
throws DatatypeException
{
super.checkValid(value, context);
try
{
int[] cp = UnicodeReader.toCodePointArray(value);
if (cp.length == 0)
throw new DatatypeException("invalid Name value");
// XXX XML 1.1 documents?
if (!XMLParser.isNameStartCharacter(cp[0], false))
throw new DatatypeException(0, "invalid Name value");
for (int i = 1; i < cp.length; i++)
{
if (!XMLParser.isNameCharacter(cp[i], false))
throw new DatatypeException(i, "invalid Name value");
}
}
catch (IOException e)
{
DatatypeException e2 = new DatatypeException("invalid Name value");
e2.initCause(e);
throw e2;
}
}
示例6: checkValid
import org.relaxng.datatype.ValidationContext; //导入依赖的package包/类
public void checkValid(String value, ValidationContext context)
throws DatatypeException
{
super.checkValid(value, context);
int len = value.length();
if (len == 0)
throw new DatatypeException(0, "invalid integer value");
for (int i = 0; i < len; i++)
{
char c = value.charAt(i);
if (c >= 0x30 && c <= 0x39)
continue;
else if (c == '+' && i == 0)
continue;
else if (c == '-' && i == 0)
continue;
throw new DatatypeException(i, "invalid integer value");
}
}
示例7: checkValid
import org.relaxng.datatype.ValidationContext; //导入依赖的package包/类
public void checkValid(String value, ValidationContext context)
throws DatatypeException
{
super.checkValid(value, context);
try
{
new URI(value);
}
catch (URISyntaxException e)
{
DatatypeException e2 = new DatatypeException(e.getIndex(),
e.getReason());
e2.initCause(e);
throw e2;
}
}
示例8: createValue
import org.relaxng.datatype.ValidationContext; //导入依赖的package包/类
public Object createValue(String literal, ValidationContext context) {
try
{
int offset = 5;
if (literal.charAt(0) == '-')
offset++;
GYearMonth ret = new GYearMonth();
ret.year = Integer.parseInt(literal.substring(0, offset));
ret.month = Integer.parseInt(literal.substring(offset + 1));
return ret;
}
catch (Exception e)
{
return null;
}
}
示例9: checkValid
import org.relaxng.datatype.ValidationContext; //导入依赖的package包/类
public void checkValid(String value, ValidationContext context)
throws DatatypeException
{
super.checkValid(value, context);
int len = value.length();
if (len == 0)
throw new DatatypeException(0, "invalid positive integer value");
for (int i = 0; i < len; i++)
{
char c = value.charAt(i);
if (c == '+')
{
if (i == 0)
continue;
}
else if (c >= 0x30 && c <= 0x39)
continue;
throw new DatatypeException(i, "invalid positive integer value");
}
}
示例10: checkValid
import org.relaxng.datatype.ValidationContext; //导入依赖的package包/类
public void checkValid(String value, ValidationContext context)
throws DatatypeException
{
super.checkValid(value, context);
try
{
int[] cp = UnicodeReader.toCodePointArray(value);
if (cp.length == 0)
throw new DatatypeException("invalid NMTOKEN value");
for (int i = 0; i < cp.length; i++)
{
// XXX XML 1.1 documents?
if (!XMLParser.isNameCharacter(cp[i], false))
throw new DatatypeException(i, "invalid NMTOKEN value");
}
}
catch (IOException e)
{
DatatypeException e2 = new DatatypeException("invalid NMTOKEN value");
e2.initCause(e);
throw e2;
}
}
示例11: checkValid
import org.relaxng.datatype.ValidationContext; //导入依赖的package包/类
public void checkValid(String value, ValidationContext context)
throws DatatypeException
{
super.checkValid(value, context);
if (SPECIAL.contains(value))
return;
try
{
Float.parseFloat(value);
}
catch (NumberFormatException e)
{
DatatypeException e2 = new DatatypeException("invalid float value");
e2.initCause(e);
throw e2;
}
}
示例12: getValue
import org.relaxng.datatype.ValidationContext; //导入依赖的package包/类
Object getValue(String str, ValidationContext vc) {
int nBytes = byteCount(str);
byte[] value = new byte[nBytes];
int valueIndex = 0;
int nBytesAccum = 0;
int accum = 0;
for (int i = 0, len = str.length(); i < len; i++) {
int w = weightTable[str.charAt(i)];
if (w != WHITESPACE) {
accum <<= 6;
if (w != PADDING)
accum |= w;
if (++nBytesAccum == 4) {
for (int shift = 16; shift >= 0; shift -= 8) {
if (valueIndex < nBytes)
value[valueIndex++] = (byte)((accum >> shift) & 0xFF);
}
nBytesAccum = 0;
accum = 0;
}
}
}
return value;
}
示例13: XmlString
import org.relaxng.datatype.ValidationContext; //导入依赖的package包/类
/**
* Creates a new {@link XmlString} from a lexical representation and in-scope namespaces.
*/
public XmlString(String value, ValidationContext context) {
this.value = value;
this.context = context;
if(context==null)
throw new IllegalArgumentException();
}
示例14: checkValid
import org.relaxng.datatype.ValidationContext; //导入依赖的package包/类
public void checkValid(String value, ValidationContext context)
throws DatatypeException
{
super.checkValid(value, context);
StringTokenizer st = new StringTokenizer(value, " ");
if (!st.hasMoreTokens())
throw new DatatypeException("invalid list value");
while (st.hasMoreTokens())
{
String token = st.nextToken();
itemType.checkValid(token, context);
}
}
示例15: addParameter
import org.relaxng.datatype.ValidationContext; //导入依赖的package包/类
public void addParameter(String name, String value, ValidationContext context)
throws DatatypeException
{
// TODO fundamental facets
if ("length".equals(name))
type.facets.add(parseLengthFacet(value));
else if ("minLength".equals(name))
type.facets.add(parseMinLengthFacet(value));
else if ("maxLength".equals(name))
type.facets.add(parseMaxLengthFacet(value));
else if ("pattern".equals(name))
type.facets.add(parsePatternFacet(value));
else if ("enumeration".equals(name))
type.facets.add(parseEnumerationFacet(value));
else if ("whiteSpace".equals(name))
type.facets.add(parseWhiteSpaceFacet(value));
else if ("maxInclusive".equals(name))
type.facets.add(parseMaxInclusiveFacet(value, context));
else if ("maxExclusive".equals(name))
type.facets.add(parseMaxExclusiveFacet(value, context));
else if ("minExclusive".equals(name))
type.facets.add(parseMinExclusiveFacet(value, context));
else if ("minInclusive".equals(name))
type.facets.add(parseMinInclusiveFacet(value, context));
else if ("totalDigits".equals(name))
type.facets.add(parseTotalDigitsFacet(value));
else if ("fractionDigits".equals(name))
type.facets.add(parseFractionDigitsFacet(value));
}