Java Code Examples for javax.jcr.PropertyType#BINARY
The following examples show how to use
javax.jcr.PropertyType#BINARY .
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 |
@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 |
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 |
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: AggregateImpl.java From jackrabbit-filevault with Apache License 2.0 | 5 votes |
private void include(Node parent, Property prop, String propPath) throws RepositoryException { String relPath = propPath.substring(path.length()); if (includes == null || !includes.contains(relPath)) { if (log.isDebugEnabled()) { log.trace("including {} -> {}", path, propPath); } // ensure that parent node is included as well include(parent, null); includes.add(mgr.cacheString(relPath)); if (prop.getType() == PropertyType.BINARY) { boolean includeBinary = true; if (useBinaryReferences) { Binary bin = prop.getBinary(); if (bin != null && bin instanceof ReferenceBinary) { String binaryReference = ((ReferenceBinary) bin).getReference(); // do not create a separate binary file if there is a reference if (binaryReference != null) { includeBinary = false; } } } if (includeBinary) { if (binaries == null) { binaries = new LinkedList<Property>(); } binaries.add(prop); } } } }
Example 5
Source File: CNDImporter.java From jackrabbit-filevault with Apache License 2.0 | 5 votes |
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 6
Source File: ValueImpl.java From jackalope with Apache License 2.0 | 4 votes |
@Override public Binary getBinary() throws RepositoryException { if (type != PropertyType.BINARY) throw new ValueFormatException(); return (Binary)valueObject; }
Example 7
Source File: ValueFactoryImpl.java From jackalope with Apache License 2.0 | 4 votes |
@Override public Value createValue(Binary value) { return new ValueImpl(PropertyType.BINARY, value); }
Example 8
Source File: DocViewProperty.java From jackrabbit-filevault with Apache License 2.0 | 4 votes |
/** * Sets this property on the given node * * @param node the node * @return {@code true} if the value was modified. * @throws RepositoryException if a repository error occurs */ public boolean apply(Node node) throws RepositoryException { Property prop = node.hasProperty(name) ? node.getProperty(name) : null; // check if multiple flags are equal if (prop != null && isMulti != prop.getDefinition().isMultiple()) { prop.remove(); prop = null; } if (prop != null) { int propType = prop.getType(); if (propType != type && (propType != PropertyType.STRING || type != PropertyType.UNDEFINED)) { // never compare if types differ prop = null; } } if (isMulti) { // todo: handle multivalue binaries and reference binaries Value[] vs = prop == null ? null : prop.getValues(); if (vs != null && vs.length == values.length) { // quick check all values boolean modified = false; for (int i=0; i<vs.length; i++) { if (!vs[i].getString().equals(values[i])) { modified = true; } } if (!modified) { return false; } } if (type == PropertyType.UNDEFINED) { node.setProperty(name, values); } else { node.setProperty(name, values, type); } // assume modified return true; } else { Value v = prop == null ? null : prop.getValue(); if (type == PropertyType.BINARY) { if (isReferenceProperty) { ReferenceBinary ref = new SimpleReferenceBinary(values[0]); Binary binary = node.getSession().getValueFactory().createValue(ref).getBinary(); if (v != null) { Binary bin = v.getBinary(); if (bin.equals(binary)) { return false; } } node.setProperty(name, binary); } // the binary property is always modified (TODO: check if still correct with JCRVLT-110) return true; } if (v == null || !v.getString().equals(values[0])) { try { if (type == PropertyType.UNDEFINED) { node.setProperty(name, values[0]); } else { node.setProperty(name, values[0], type); } } catch (ValueFormatException e) { // forcing string node.setProperty(name, values[0], PropertyType.STRING); } return true; } } return false; }