/** * Produce a set of default values for the provided FeatureType * * @param featureType * @return Array of values, that are good starting point for data entry */ public static Object[] defaultValues(SimpleFeatureType featureType) { return defaultValues(featureType, null); }
/** * Create a new feature from the provided values, using appropriate default values for any nulls * provided. * * @param featureType * @param providedValues * @return newly created feature * @throws ArrayIndexOutOfBoundsException If the number of provided values does not match the * featureType */ public static SimpleFeature template(SimpleFeatureType featureType, Object[] providedValues) { return SimpleFeatureBuilder.build( featureType, defaultValues(featureType, providedValues), null); }
/** * Constructs an empty feature to use as a Template for new content. * * <p>We may move this functionality to FeatureType.create( null )? * * @param featureType Type of feature we wish to create * @return A new Feature of type featureType */ public static SimpleFeature template(SimpleFeatureType featureType) throws IllegalAttributeException { return SimpleFeatureBuilder.build(featureType, defaultValues(featureType), null); }
/** * Use the provided featureType to create an empty feature. * * <p>The {@link #defaultValues(SimpleFeatureType)} method is used to generate the intial values * (making use of {@link AttributeDescriptor#getDefaultValue()} as required. * * @param featureType * @param featureID * @return Craeted feature */ public static SimpleFeature template(SimpleFeatureType featureType, String featureID) { return SimpleFeatureBuilder.build(featureType, defaultValues(featureType), featureID); }
/** * Create a new feature from the provided values, using appropriate default values for any nulls * provided. * * @param featureType * @param featureID * @param providedValues provided attributes * @return newly created feature * @throws ArrayIndexOutOfBoundsException If the number of provided values does not match the * featureType */ public static SimpleFeature template( SimpleFeatureType featureType, String featureID, Object[] providedValues) { return SimpleFeatureBuilder.build( featureType, defaultValues(featureType, providedValues), featureID); }
public void testDefaultValues() throws IllegalAttributeException { Object[] values = DataUtilities.defaultValues(roadType); assertNotNull(values); assertEquals(values.length, roadType.getAttributeCount()); }
public SimpleFeature next() throws IOException { if (writer == null) { throw new IOException("Writer has been closed"); } String fid = null; try { if (hasNext()) { delegate.next(); // grab next line fid = delegate.fid; Object values[] = new Object[type.getAttributeCount()]; for (int i = 0; i < type.getAttributeCount(); i++) { values[i] = delegate.read(i); } origional = SimpleFeatureBuilder.build(type, values, fid); live = SimpleFeatureBuilder.copy(origional); return live; } else { fid = type.getTypeName() + "." + System.currentTimeMillis(); Object values[] = DataUtilities.defaultValues(type); origional = null; live = SimpleFeatureBuilder.build(type, values, fid); return live; } } catch (IllegalAttributeException e) { String message = "Problem creating feature " + (fid != null ? fid : ""); throw new DataSourceException(message, e); } } // next end
/** * Produce a set of default values for the provided FeatureType * * @param featureType * @return Array of values, that are good starting point for data entry */ public static Object[] defaultValues(SimpleFeatureType featureType) { return defaultValues(featureType, null); }
/** * DOCUMENT ME! * * @param featureType DOCUMENT ME! * * @return DOCUMENT ME! * * @throws IllegalAttributeException DOCUMENT ME! */ public static Object[] defaultValues(FeatureType featureType) throws IllegalAttributeException { return defaultValues(featureType, null); }
/** * Create a new feature from the provided values, using appropriate default values for any nulls * provided. * * @param featureType * @param providedValues * @return newly created feature * @throws ArrayIndexOutOfBoundsException If the number of provided values does not match the featureType */ public static SimpleFeature template(SimpleFeatureType featureType, Object[] providedValues) { return SimpleFeatureBuilder.build(featureType, defaultValues(featureType, providedValues), null); }
/** * Use the provided featureType to create an empty feature. * <p> * The {@link #defaultValues(SimpleFeatureType)} method is used to generate * the intial values (making use of {@link AttributeDescriptor#getDefaultValue()} as required. * * @param featureType * @param featureID * @return Craeted feature */ public static SimpleFeature template(SimpleFeatureType featureType, String featureID) { return SimpleFeatureBuilder.build(featureType, defaultValues(featureType), featureID); }
/** * DOCUMENT ME! * * @param featureType DOCUMENT ME! * @param featureID DOCUMENT ME! * * @return DOCUMENT ME! * * @throws IllegalAttributeException DOCUMENT ME! */ public static Feature template(FeatureType featureType, String featureID) throws IllegalAttributeException { return featureType.create(defaultValues(featureType), featureID); }
/** * DOCUMENT ME! * * @param featureType DOCUMENT ME! * @param atts DOCUMENT ME! * * @return DOCUMENT ME! * * @throws IllegalAttributeException DOCUMENT ME! */ public static Feature template(FeatureType featureType, Object[] atts) throws IllegalAttributeException { return featureType.create(defaultValues(featureType, atts)); }
/** * DOCUMENT ME! * * @param featureType DOCUMENT ME! * @param featureID DOCUMENT ME! * @param atts DOCUMENT ME! * * @return DOCUMENT ME! * * @throws IllegalAttributeException DOCUMENT ME! */ public static Feature template(FeatureType featureType, String featureID, Object[] atts) throws IllegalAttributeException { return featureType.create(defaultValues(featureType, atts), featureID); }
/** * Constructs an empty feature to use as a Template for new content. * * <p> * We may move this functionality to FeatureType.create( null )? * </p> * * @param featureType * Type of feature we wish to create * * @return A new Feature of type featureType */ public static SimpleFeature template(SimpleFeatureType featureType) throws IllegalAttributeException { return SimpleFeatureBuilder.build(featureType, defaultValues(featureType), null); }
/** * Create a new feature from the provided values, using appropriate default values for any nulls * provided. * * @param featureType * @param featureID * @param providedValues provided attributes * * @return newly created feature * * @throws ArrayIndexOutOfBoundsException If the number of provided values does not match the featureType */ public static SimpleFeature template(SimpleFeatureType featureType, String featureID, Object[] providedValues) { return SimpleFeatureBuilder.build(featureType, defaultValues(featureType, providedValues), featureID); }
/** * Constructs an empty feature to use as a Template for new content. * * <p> * We may move this functionality to FeatureType.create( null )? * </p> * * @param featureType Type of feature we wish to create * * @return A new Feature of type featureType * * @throws IllegalAttributeException if we could not create featureType * instance with acceptable default values */ public static Feature template(FeatureType featureType) throws IllegalAttributeException { return featureType.create(defaultValues(featureType)); }
@Override public SimpleFeature next() throws IOException, IllegalArgumentException, NoSuchElementException { if (csvWriter == null) { throw new IOException("Writer has been closed"); } if (this.currentFeature != null) { this.write(); // the previous one was not written, so do it now. } try { if (!appending) { if (iterator.hasNext()) { this.currentFeature = iterator.next(); return this.currentFeature; } else { this.appending = true; } } String fid = featureType.getTypeName() + "-fid" + nextRow; Object values[] = DataUtilities.defaultValues(featureType); this.currentFeature = SimpleFeatureBuilder.build(featureType, values, fid); return this.currentFeature; } catch (IllegalArgumentException invalid) { throw new IOException("Unable to create feature:" + invalid.getMessage(), invalid); } } // next end
@Override public SimpleFeature next() throws IOException { if (dataBuilder == null) { throw new IOException("FeatureWriter has been closed"); } if (this.currentFeature != null) { this.write(); } try { if (!appending) { if (delegate.hasNext()) { this.currentFeature = delegate.next(); return this.currentFeature; } else { this.appending = true; } } SimpleFeatureType featureType = state.getFeatureType(); String fid = featureType.getTypeName() + "." + nextRow; Object values[] = DataUtilities.defaultValues(featureType); this.currentFeature = SimpleFeatureBuilder.build(featureType, values, fid); return this.currentFeature; } catch (IllegalArgumentException invalid) { throw new IOException("Unable to create feature:" + invalid.getMessage(), invalid); } }
Object values[] = DataUtilities.defaultValues( type );