public static NodeValue makeNodeInteger(long v) { NodeValue nv = makeNode(Long.toString(v), null, XSDinteger.getURI()) ; return nv ; }
/** * Test whether the given LiteralLabel is a valid instance * of this datatype. This takes into accound typing information * as well as lexical form - for example an xsd:string is * never considered valid as an xsd:integer (even if it is * lexically legal like "1"). */ @Override public boolean isValidLiteral(LiteralLabel lit) { return isBaseTypeCompatible(lit) && isValid(lit.getLexicalForm()); }
public static int nodeToInt(Node node) { LiteralLabel lit = node.getLiteral() ; if ( ! XSDDatatype.XSDinteger.isValidLiteral(lit) ) return Integer.MIN_VALUE ; int i = ((Number)lit.getValue()).intValue() ; return i ; }
return Integer.valueOf(trimPlus(validatedInfo.normalizedValue)); return suitableInteger( trimPlus(validatedInfo.normalizedValue) ); return Integer.valueOf(trimPlus(validatedInfo.normalizedValue)); BigDecimal value = new BigDecimal(trimPlus(validatedInfo.normalizedValue)); return XSDdecimal.cannonicalise( value ); String lexical = trimPlus(validatedInfo.normalizedValue); int dotx = lexical.indexOf('.'); if (dotx != -1) { return new BigInteger(lexical); } else { return suitableInteger( lexical ); return parseValidated(validatedInfo.normalizedValue);
if ( sameValueAsString && XSDstring.isValidLiteral(lit) ) if ( XSDinteger.isValidLiteral(lit) ) if ( datatype.equals(XSDdecimal) && XSDdecimal.isValidLiteral(lit) ) if ( datatype.equals(XSDfloat) && XSDfloat.isValidLiteral(lit) ) if ( datatype.equals(XSDdouble) && XSDdouble.isValidLiteral(lit) ) XSDdateTime.isValid(lex) ) if ( datatype.equals(XSDdate) && XSDdate.isValidLiteral(lit) ) if ( datatype.equals(XSDtime) && XSDtime.isValidLiteral(lit) ) if ( datatype.equals(XSDgYear) && XSDgYear.isValidLiteral(lit) ) if ( datatype.equals(XSDgYearMonth) && XSDgYearMonth.isValidLiteral(lit) ) if ( datatype.equals(XSDgMonth) && XSDgMonth.isValidLiteral(lit) ) if ( datatype.equals(XSDgMonthDay) && XSDgMonthDay.isValidLiteral(lit) ) if ( datatype.equals(XSDgDay) && XSDgDay.isValidLiteral(lit) ) dtXSDdayTimeDuration.equals(datatypeURI) || dtXSDyearMonthDuration.equals(datatypeURI) ) && XSDduration.isValid(lex) ) // use lex
/** * Turn a possible numeric token into typed literal else a plain literal * @return the constructed literal node */ Node parseNumber(String lit) { if ( Character.isDigit(lit.charAt(0)) || (lit.charAt(0) == '-' && lit.length() > 1 && Character.isDigit(lit.charAt(1))) ) { if (lit.indexOf(".") != -1) { // Float? if (XSDDatatype.XSDfloat.isValid(lit)) { return NodeFactory.createLiteral(lit, "", XSDDatatype.XSDfloat); } } else { // Int? if (XSDDatatype.XSDint.isValid(lit)) { return NodeFactory.createLiteral(lit, "", XSDDatatype.XSDint); } } } // Default is a plain literal return NodeFactory.createLiteral(lit, "", false); }
evidenceIndividual, ResourceFactory.createProperty(TIME_PROPERTY_FROM), ResourceFactory.createTypedLiteral(evidence.defactoTimePeriod.getFrom().toString(), new XSDDatatype("gYear")))); ResourceFactory.createTypedLiteral(evidence.defactoTimePeriod.getTo().toString(), new XSDDatatype("gYear"))));
/** * Parse a lexical form of this datatype to a value * @throws DatatypeFormatException if the lexical form is not legal */ @Override public Object parse(String lexicalForm) throws DatatypeFormatException { try { ValidationContext context = new ValidationState(); ValidatedInfo resultInfo = new ValidatedInfo(); Object result = typeDeclaration.validate(lexicalForm, context, resultInfo); return convertValidatedDataValue(resultInfo); } catch (InvalidDatatypeValueException e) { throw new DatatypeFormatException(lexicalForm, this, "during parse -" + e); } }
protected NodeValue cast(String s, NodeValue nv, XSDDatatype castType2) { // Plain cast. if ( ! castType.isValid(s) ) throw new ExprEvalException("CastXSD: Not a valid literal form: "+s) ; // Unfortunately, validity testing happens in NodeValue.makeNode as well. return NodeValue.makeNode(s, castType) ; } }
tm.registerDatatype(new XSDDatatype("anySimpleType"));
public static NodeValue makeNodeDecimal(String lexicalForm) { NodeValue nv = makeNode(lexicalForm, null, XSDdecimal.getURI()) ; return nv ; }
public static long nodeToLong(Node node) { LiteralLabel lit = node.getLiteral() ; if ( ! XSDDatatype.XSDinteger.isValidLiteral(lit) ) return Long.MIN_VALUE ; long i = ((Number)lit.getValue()).longValue() ; return i ; }
if ( ! castType.isValid(s) ) throw new ExprEvalException("CastXSD: Not a valid literal form: '"+s+"'") ;
protected void emitLiteralInteger(int beginLine, int beginColumn, String image) { emitLiteral(beginLine, beginColumn, image, null, XSDDatatype.XSDinteger.getURI(), null) ; }
public static int nodeToInt(Node node) { LiteralLabel lit = node.getLiteral() ; if ( ! XSDDatatype.XSDinteger.isValidLiteral(lit) ) return Integer.MIN_VALUE ; int i = ((Number)lit.getValue()).intValue() ; return i ; }
public static NodeValue makeNodeInteger(String lexicalForm) { NodeValue nv = makeNode(lexicalForm, null, XSDinteger.getURI()) ; return nv ; }
public static long nodeToLong(Node node) { LiteralLabel lit = node.getLiteral() ; if ( ! XSDDatatype.XSDinteger.isValidLiteral(lit) ) return Long.MIN_VALUE ; long i = ((Number)lit.getValue()).longValue() ; return i ; }
public static NodeValue makeNodeFloat(String lexicalForm) { NodeValue nv = makeNode(lexicalForm, null, XSDdouble.getURI()) ; return nv ; }
public static float nodeToFloat(Node node) { LiteralLabel lit = node.getLiteral(); if ( ! XSDDatatype.XSDfloat.isValidLiteral(lit) ) return Float.NaN; float f = ((Number)lit.getValue()).floatValue(); return f; }
public static NodeValue makeNodeDouble(String lexicalForm) { NodeValue nv = makeNode(lexicalForm, null, XSDdouble.getURI()) ; return nv ; }