From: <svn...@os...> - 2012-05-29 07:47:04
|
Author: jive Date: 2012-05-29 00:46:52 -0700 (Tue, 29 May 2012) New Revision: 38773 Modified: trunk/modules/library/main/src/main/java/org/geotools/data/DataUtilities.java trunk/modules/library/main/src/test/java/org/geotools/data/DataUtilitiesTest.java Log: Move the type spec javadocs to createType, as createAttribute method is not shown in our javadocs. Signed-off-by: Jody Garnett <jod...@gm...> Modified: trunk/modules/library/main/src/main/java/org/geotools/data/DataUtilities.java =================================================================== --- trunk/modules/library/main/src/main/java/org/geotools/data/DataUtilities.java 2012-05-29 07:46:31 UTC (rev 38772) +++ trunk/modules/library/main/src/main/java/org/geotools/data/DataUtilities.java 2012-05-29 07:46:52 UTC (rev 38773) @@ -1769,74 +1769,70 @@ * </p> * * <p> - * Where <i>Type</i> is defined by createAttribute. + * Where <i>Type</i> is defined by {@link createAttribute}: + * <ul> + * <li>Each attribute descriptor is defined using the form: <i>"name:Type:hint"</i> </li> + * <li>Where <i>Type</i> is: + * <ul> + * <li>0,Interger,int: represents Interger</li> + * <li>0.0, Double, double: represents Double</li> + * <li>"",String,string: represents String</li> + * <li>Geometry: represents Geometry, additional common geometry types supported including + * Point,LineString,Polygon,MultiLineString,MultiPolygon,MultiPoint,GeometryCollection</ul> + * <li>UUID</li> + * <li>Date</li> + * <li><i>full.class.path</i>: represents java type</li> + * </ul> + * </li> + * <li>Where <i>hint</i> is "hint1;hint2;...;hintN", in which "hintN" is one of: + * <ul> + * <li><code>nillable</code></li> + * <li><code>srid=<#></code></li> + * </ul> + * </li> + * <li>You may indicate the default Geometry with an astrix: "*geom:Geometry".</li> + * <li>You may also indicate the srid (used to look up a EPSG code): "*point:Point:3226</li> * </p> * * <p> - * You may indicate the default Geometry with an astrix: "*geom:Geometry". You may also indicate - * the srid (used to look up a EPSG code). - * </p> - * - * <p> * Examples: * <ul> - * <li><code>name:"",age:0,geom:Geometry,centroid:Point,url:java.io.URL"</code> - * <li><code>id:String,polygonProperty:Polygon:srid=32615</code> + * <li><code>name:"",age:0,geom:Geometry,centroid:Point,url:java.io.URL"</code></li> + * <li><code>id:String,polygonProperty:Polygon:srid=32615</code></li> + * <li><code>identifier:UUID,location:Point,*area:MultiPolygon,created:Date</code></li> + * <li><code>uuid:UUID,name:String,description:String,time:java.sql.Timestamp</code></li> * </ul> * </p> * - * @param identification + * @param typeName * identification of FeatureType: (<i>namesapce</i>).<i>typeName</i> * @param typeSpec - * Specification for FeatureType + * Specification of FeatureType attributes "name:Type,name2:Type2,..." * * * @throws SchemaException */ - public static SimpleFeatureType createType(String identification, String typeSpec) + public static SimpleFeatureType createType(String typeName, String typeSpec) throws SchemaException { - int split = identification.lastIndexOf('.'); - String namespace = (split == -1) ? null : identification.substring(0, split); - String typeName = (split == -1) ? identification : identification.substring(split + 1); + int split = typeName.lastIndexOf('.'); + String namespace = (split == -1) ? null : typeName.substring(0, split); + String name = (split == -1) ? typeName : typeName.substring(split + 1); - return createType(namespace, typeName, typeSpec); + return createType(namespace, name, typeSpec); } /** * Utility method for FeatureType construction. * <p> - * Will parse a String of the form: <i>"name:Type,name2:Type2,..."</i> - * </p> - * - * <p> - * Where <i>Type</i> is defined by createAttribute. - * </p> - * - * <p> - * You may indicate the default Geometry with an astrix: "*geom:Geometry". You may also indicate - * the srid (used to look up a EPSG code). - * </p> - * - * <p> - * Examples: - * <ul> - * <li><code>name:"",age:0,geom:Geometry,centroid:Point,url:java.io.URL"</code> - * <li><code>id:String,polygonProperty:Polygon:srid=32615</code> - * </ul> - * </p> - * - * @param identification - * identification of FeatureType: (<i>namesapce</i>).<i>typeName</i> - * @param typeSpec - * Specification for FeatureType - * - * + * @param namespace Typename namespace used to qualify the provided name + * @param name Typename name, as qualified by namespace + * @param typeSpec Definition of attributes, for details see {@link #createType(String, String)} * @throws SchemaException */ - public static SimpleFeatureType createType(String namespace, String typeName, String typeSpec) + public static SimpleFeatureType createType(String namespace, String name, String typeSpec) throws SchemaException { SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); - builder.setName(typeName); + builder.setName(name); builder.setNamespaceURI(namespace); String[] types = typeSpec.split(","); @@ -2512,40 +2508,14 @@ } /** - * Returns AttributeType based on String specification (based on UML). - * + * Generate AttributeDescriptor based on String type specification (based on UML). * <p> - * Will parse a String of the form: <i>"name:Type:hint"</i> + * Will parse a String of the form: <i>"name:Type:hint" as described in {@link #createType}</i> * </p> * - * <p> - * Where <i>Type</i> is: - * </p> - * - * <ul> - * <li> - * 0,Interger,int: represents Interger</li> - * <li> - * 0.0, Double, double: represents Double</li> - * <li> - * "",String,string: represents String</li> - * <li> - * Geometry: represents Geometry</li> - * <li> - * <i>full.class.path</i>: represents java type</li> - * </ul> - * - * <p> - * Where <i>hint</i> is "hint1;hint2;...;hintN", in which "hintN" is one of: - * <ul> - * <li><code>nillable</code></li> - * <li><code>srid=<#></code></li> - * </ul> - * </p> - * * @param typeSpec + * @see #createType * - * * @throws SchemaException * If typeSpect could not be interpreted */ Modified: trunk/modules/library/main/src/test/java/org/geotools/data/DataUtilitiesTest.java =================================================================== --- trunk/modules/library/main/src/test/java/org/geotools/data/DataUtilitiesTest.java 2012-05-29 07:46:31 UTC (rev 38772) +++ trunk/modules/library/main/src/test/java/org/geotools/data/DataUtilitiesTest.java 2012-05-29 07:46:52 UTC (rev 38773) @@ -43,6 +43,7 @@ import org.geotools.feature.type.AttributeDescriptorImpl; import org.geotools.feature.type.AttributeTypeImpl; import org.geotools.filter.IllegalFilterException; +import org.geotools.geometry.jts.GeometryBuilder; import org.geotools.geometry.jts.ReferencedEnvelope; import org.geotools.referencing.CRS; import org.geotools.referencing.crs.DefaultGeographicCRS; @@ -464,6 +465,17 @@ // test escape handling assertEquals( "newline decode check", "Jody Garnett\nSteering Committee", feature1.getAttribute("party") ); assertEquals( "escape check", "John Hudson|Hapless Victim", feature2.getAttribute("party") ); + + // test feature id handling + assertEquals( "fid1", feature1.getID() ); + assertNotNull( feature2.getID() ); + assertEquals( feature2.getID(), feature2.getIdentifier().getID() ); + + // test geometry handling + GeometryBuilder geomBuilder = new GeometryBuilder(); + assertEquals( geomBuilder.point(6,2), feature2.getDefaultGeometry() ); + assertEquals( geomBuilder.point(6,2), feature2.getAttribute("geom") ); + } /** * Test createType and createFeature methods as per GEOT-4150 @@ -676,7 +688,7 @@ public void testSpecNoCRS() throws Exception { String spec = "id:String,polygonProperty:Polygon"; SimpleFeatureType ft = DataUtilities.createType("testType", spec); - String spec2 = DataUtilities.spec(ft); + String spec2 = DataUtilities.encodeType(ft); // System.out.println("BEFORE:"+spec); // System.out.println(" AFTER:"+spec2); assertEquals(spec, spec2); @@ -685,7 +697,7 @@ public void testSpecCRS() throws Exception { String spec = "id:String,polygonProperty:Polygon:srid=32615"; SimpleFeatureType ft = DataUtilities.createType("testType", spec); - String spec2 = DataUtilities.spec(ft); + String spec2 = DataUtilities.encodeType(ft); // System.out.println("BEFORE:"+spec); // System.out.println(" AFTER:"+spec2); assertEquals(spec, spec2); @@ -700,7 +712,7 @@ // since we cannot go back to a code with do a best effort encoding String expected = "id:String,polygonProperty:Polygon"; - String spec2 = DataUtilities.spec(transformedFt); + String spec2 = DataUtilities.encodeType(transformedFt); // System.out.println(" BEFORE:"+spec); // System.out.println("EXPECTED:"+expected); // System.out.println(" AFTER:"+spec2); |