/** * {@inheritDoc} * * @see org.modeshape.graph.property.ValueTypeSystem.Factory#asReadableString(java.lang.Object) */ @Override public String asReadableString( Object value ) { return stringValueFactory.create(value); } };
@SuppressWarnings( "unchecked" ) private static <T> ValueFactory<T> getFactory( Map<PropertyType, ValueFactory<?>> factories, ValueFactory<T> defaultFactory ) { PropertyType type = defaultFactory.getPropertyType(); ValueFactory<?> factory = factories.get(type); if (factory == null) { factory = defaultFactory; factories.put(type, factory); } return (ValueFactory<T>)factory; }
/** * {@inheritDoc} * * @see org.modeshape.graph.query.model.TypeSystem#asString(java.lang.Object) */ public String asString( Object value ) { return stringValueFactory.create(value); }
protected Factory( ValueFactory<T> valueFactory ) { this.valueFactory = valueFactory; this.type = this.valueFactory.getPropertyType(); this.typeName = type.getName().toUpperCase(); }
/** * {@inheritDoc} * * @see org.modeshape.graph.query.model.TypeSystem.TypeFactory#create(java.lang.String) */ public T create( String value ) throws ValueFormatException { return valueFactory.create(value); }
/** * {@inheritDoc} * * @see org.modeshape.graph.query.model.TypeSystem#getTypeFactory(java.lang.Object) */ public TypeFactory<?> getTypeFactory( Object prototype ) { ValueFactory<?> valueFactory = valueFactories.getValueFactory(prototype); if (valueFactory == null) return null; PropertyType type = valueFactory.getPropertyType(); assert type != null; return typeFactoriesByPropertyType.get(type); }
/** * {@inheritDoc} * * @see org.modeshape.graph.query.model.TypeSystem.TypeFactory#create(java.lang.Object) */ public T create( Object value ) throws ValueFormatException { return valueFactory.create(value); }
/** * {@inheritDoc} * * @see org.modeshape.graph.property.ValueTypeSystem.Factory#asString(java.lang.Object) */ @Override public String asString( Object value ) { return stringValueFactory.create(value); }
/** * {@inheritDoc} * * @see org.modeshape.graph.query.model.TypeSystem.TypeFactory#asString(java.lang.Object) */ public String asString( Object value ) { if (value instanceof String) { // Convert to the typed value, then back to a string ... value = valueFactory.create((String)value); } return stringValueFactory.create(value); }
/** * {@inheritDoc} * * @see java.util.Iterator#next() */ public ValueType next() { return factory.create(this.delegate.next()); }
/** * {@inheritDoc} */ public Object create( String value ) { return this.getStringValueFactory().create(value); }
/** * {@inheritDoc} * * @see org.modeshape.graph.property.ValueTypeSystem.Factory#create(java.lang.String) */ @Override public DateTime create( String value ) throws ValueFormatException { DateTime result = valueFactory.create(value); // Convert the timestamp to UTC, since that's how everything should be queried ... return result.toUtcTimeZone(); } };
/** * {@inheritDoc} * * @see org.modeshape.graph.property.ValueTypeSystem.Factory#length(java.lang.Object) */ @Override public long length( Object value ) { Binary binary = this.valueFactory.create(value); return binary != null ? binary.getSize() : 0; } };
/** * {@inheritDoc} */ public Object create( String value, TextDecoder decoder ) { return this.getStringValueFactory().create(value, decoder); }
/** * {@inheritDoc} */ public Object create( byte[] value ) { return getBinaryValueFactory().create(value); }
/** * {@inheritDoc} */ public Object create( InputStream stream, long approximateLength ) { return getBinaryValueFactory().create(stream, approximateLength); }
/** * {@inheritDoc} * * @see org.modeshape.graph.property.PathFactory#create(org.modeshape.graph.property.Path, java.lang.String, int) */ public Path create( Path parentPath, String segmentName, int index ) { return create(parentPath, nameValueFactory.create(segmentName), index); }
/** * {@inheritDoc} */ public Object create( Reader reader, long approximateLength ) { return getBinaryValueFactory().create(reader, approximateLength); }
/** * {@inheritDoc} * * @see org.modeshape.graph.query.model.TypeSystem.TypeFactory#length(java.lang.Object) */ public long length( Object value ) { String str = asString(valueFactory.create(value)); return str != null ? str.length() : 0; }
/** * {@inheritDoc} */ public Segment createSegment( String segmentName, int index ) { CheckArg.isNotNull(segmentName, "segment name"); if (Path.SELF.equals(segmentName)) return Path.SELF_SEGMENT; if (Path.PARENT.equals(segmentName)) return Path.PARENT_SEGMENT; return new BasicPathSegment(this.nameValueFactory.create(segmentName), index); }