Java Code Examples for org.eclipse.rdf4j.model.vocabulary.XMLSchema#BOOLEAN

The following examples show how to use org.eclipse.rdf4j.model.vocabulary.XMLSchema#BOOLEAN . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SmartUriAdapter.java    From rya with Apache License 2.0 6 votes vote down vote up
private static IRI determineType(final String data) {
    if (Ints.tryParse(data) != null) {
        return XMLSchema.INTEGER;
    } else if (Doubles.tryParse(data) != null) {
        return XMLSchema.DOUBLE;
    } else if (Floats.tryParse(data) != null) {
        return XMLSchema.FLOAT;
    } else if (isShort(data)) {
        return XMLSchema.SHORT;
    } else if (Longs.tryParse(data) != null) {
        return XMLSchema.LONG;
    } if (Boolean.parseBoolean(data)) {
        return XMLSchema.BOOLEAN;
    } else if (isByte(data)) {
        return XMLSchema.BYTE;
    } else if (isDate(data)) {
        return XMLSchema.DATETIME;
    } else if (isUri(data)) {
        return XMLSchema.ANYURI;
    }

    return XMLSchema.STRING;
}
 
Example 2
Source File: TripleSources.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static boolean booleanValue(Resource subj, IRI pred, TripleSource store) throws QueryEvaluationException {
	Value v = TripleSources.singleValue(subj, pred, store);
	if (v == null) {
		return false;
	} else if (v instanceof Literal) {
		try {
			return ((Literal) v).booleanValue();
		} catch (IllegalArgumentException e) {
			throw new QueryEvaluationException(
					"Value for " + pred + " must be of datatype " + XMLSchema.BOOLEAN + ": " + subj);
		}
	} else {
		throw new QueryEvaluationException("Non-literal value for " + pred + ": " + subj);
	}
}
 
Example 3
Source File: BooleanMemLiteral.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public BooleanMemLiteral(Object creator, String label, boolean b) {
	super(creator, label, XMLSchema.BOOLEAN);
	this.b = b;
}
 
Example 4
Source File: BooleanCast.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
protected IRI getXsdDatatype() {
	return XMLSchema.BOOLEAN;
}
 
Example 5
Source File: BooleanLiteral.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Creates an xsd:boolean typed literal with the specified value.
 */
protected BooleanLiteral(boolean value) {
	super(Boolean.toString(value), XMLSchema.BOOLEAN);
	this.value = value;
}
 
Example 6
Source File: BooleanRyaTypeResolver.java    From rya with Apache License 2.0 4 votes vote down vote up
public BooleanRyaTypeResolver() {
    super((byte) BOOLEAN_LITERAL_MARKER, XMLSchema.BOOLEAN);
}
 
Example 7
Source File: DuplicateDataDetector.java    From rya with Apache License 2.0 4 votes vote down vote up
@Override
public IRI getXmlSchemaUri() {
    return XMLSchema.BOOLEAN;
}
 
Example 8
Source File: RyaTypeUtils.java    From rya with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a boolean {@link RyaType} object.
 * @param value the {@link Boolean} object.
 * @return the {@link RyaType} with the data type set to
 * {@link XMLSchema#BOOLEAN} and the data set to the specified
 * {@code value}.
 */
public static RyaType booleanRyaType(final Boolean value) {
    return new RyaType(XMLSchema.BOOLEAN, Boolean.toString(value));
}