Java Code Examples for javax.jcr.PropertyType#LONG

The following examples show how to use javax.jcr.PropertyType#LONG . 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: ValueFactoryImpl.java    From jackalope with Apache License 2.0 6 votes vote down vote up
@Override
public Value createValue(String value, int type) throws ValueFormatException {
    switch (type) {
        case PropertyType.STRING:
            return createValue(value);
        case PropertyType.LONG:
            return createValue(Long.valueOf(value));
        case PropertyType.DOUBLE:
            return createValue(Double.valueOf(value));
        case PropertyType.BOOLEAN:
            return createValue(Boolean.valueOf(value));
        case PropertyType.DECIMAL:
            return createValue(new BigDecimal(value));
        case PropertyType.DATE: // TODO: parse dates
        case PropertyType.BINARY:
            return createValue(createBinary(value));
        default:
            return null;
    }
}
 
Example 2
Source File: ValueComparator.java    From jackrabbit-filevault with Apache License 2.0 6 votes vote down vote up
public int compare(Value o1, Value o2) {
    try {
        // assume types are equal
        switch (o1.getType()) {
            case PropertyType.BINARY:
                throw new IllegalArgumentException("sorting of binary values not supported.");
            case PropertyType.DATE:
                return o1.getDate().compareTo(o2.getDate());
            case PropertyType.DECIMAL:
                return o1.getDecimal().compareTo(o2.getDecimal());
            case PropertyType.DOUBLE:
                return ((Double) o1.getDouble()).compareTo(o2.getDouble());
            case PropertyType.LONG:
                return ((Long) o1.getLong()).compareTo(o2.getLong());
            default:
                return o1.getString().compareTo(o2.getString());
        }
    } catch (RepositoryException e) {
        throw new IllegalArgumentException(e);
    }
}
 
Example 3
Source File: ValueImpl.java    From jackalope with Apache License 2.0 5 votes vote down vote up
private static int selectPropertyType(Object value) {
    return (value instanceof String) ? PropertyType.STRING :
        (value instanceof Long) ? PropertyType.LONG :
            (value instanceof Double) ? PropertyType.DOUBLE :
                (value instanceof BigDecimal) ? PropertyType.DECIMAL :
                    (value instanceof Calendar) ? PropertyType.DATE :
                        (value instanceof Boolean) ? PropertyType.BOOLEAN :
                            (value instanceof Binary) ? PropertyType.BINARY :
                                PropertyType.UNDEFINED;
}
 
Example 4
Source File: CNDImporter.java    From jackrabbit-filevault with Apache License 2.0 5 votes vote down vote up
private int doPropertyType(Node pdi) throws ParseException, RepositoryException {
    if (!currentTokenEquals(Lexer.BEGIN_TYPE)) {
        return PropertyType.UNDEFINED;
    }
    nextToken();
    int type = PropertyType.UNDEFINED;
    if (currentTokenEquals(Lexer.STRING)) {
        type = PropertyType.STRING;
    } else if (currentTokenEquals(Lexer.BINARY)) {
        type = PropertyType.BINARY;
    } else if (currentTokenEquals(Lexer.LONG)) {
        type = PropertyType.LONG;
    } else if (currentTokenEquals(Lexer.DOUBLE)) {
        type = PropertyType.DOUBLE;
    } else if (currentTokenEquals(Lexer.BOOLEAN)) {
        type = PropertyType.BOOLEAN;
    } else if (currentTokenEquals(Lexer.DATE)) {
        type = PropertyType.DATE;
    } else if (currentTokenEquals(Lexer.NAME)) {
        type = PropertyType.NAME;
    } else if (currentTokenEquals(Lexer.PATH)) {
        type = PropertyType.PATH;
    } else if (currentTokenEquals(Lexer.REFERENCE)) {
        type = PropertyType.REFERENCE;
    } else if (currentTokenEquals(Lexer.UNDEFINED)) {
        type = PropertyType.UNDEFINED;
    } else {
        lexer.fail("Unknown property type '" + currentToken + "' specified");
    }
    pdi.setProperty(JcrConstants.JCR_REQUIREDTYPE, PropertyType.nameFromValue(type).toUpperCase());
    nextToken();
    if (!currentTokenEquals(Lexer.END_TYPE)) {
        lexer.fail("Missing '" + Lexer.END_TYPE + "' delimiter for end of property type");
    }
    nextToken();
    return type;
}
 
Example 5
Source File: ValueImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public long getLong() throws ValueFormatException, RepositoryException {
    if (type != PropertyType.LONG) throw new ValueFormatException();
    return (long)valueObject;
}
 
Example 6
Source File: ValueFactoryImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public Value createValue(long value) {
    return new ValueImpl(PropertyType.LONG, value);
}