Revision: 5193 http://sourceforge.net/p/jump-pilot/code/5193 Author: michaudm Date: 2016-11-18 12:38:53 +0000 (Fri, 18 Nov 2016) Log Message: ----------- Use datasource constants for properties keys
Modified Paths: -------------- core/trunk/src/com/vividsolutions/jump/io/AbstractJUMPReader.java core/trunk/src/com/vividsolutions/jump/io/AbstractJUMPWriter.java core/trunk/src/com/vividsolutions/jump/io/BaseFeatureInputStream.java core/trunk/src/com/vividsolutions/jump/io/ColumnDescription.java core/trunk/src/com/vividsolutions/jump/io/CompressedFile.java core/trunk/src/com/vividsolutions/jump/io/DriverProperties.java core/trunk/src/com/vividsolutions/jump/io/FMEGMLReader.java core/trunk/src/com/vividsolutions/jump/io/FMEGMLWriter.java core/trunk/src/com/vividsolutions/jump/io/GMLGeometryWriter.java core/trunk/src/com/vividsolutions/jump/io/GMLInputTemplate.java core/trunk/src/com/vividsolutions/jump/io/GMLOutputTemplate.java core/trunk/src/com/vividsolutions/jump/io/GMLReader.java core/trunk/src/com/vividsolutions/jump/io/GMLWriter.java core/trunk/src/com/vividsolutions/jump/io/JMLReader.java core/trunk/src/com/vividsolutions/jump/io/JMLWriter.java core/trunk/src/com/vividsolutions/jump/io/ParseException.java core/trunk/src/com/vividsolutions/jump/io/ShapefileReader.java core/trunk/src/com/vividsolutions/jump/io/ShapefileWriter.java core/trunk/src/com/vividsolutions/jump/io/WKTReader.java core/trunk/src/com/vividsolutions/jump/io/WKTWriter.java core/trunk/src/com/vividsolutions/jump/io/datasource/DataSource.java core/trunk/src/com/vividsolutions/jump/io/datasource/FileDataSource.java core/trunk/src/com/vividsolutions/jump/io/datasource/ReaderWriterFileDataSource.java core/trunk/src/com/vividsolutions/jump/io/datasource/StandardReaderWriterFileDataSource.java core/trunk/src/com/vividsolutions/jump/workbench/datasource/InstallStandardDataSourceQueryChoosersPlugIn.java core/trunk/src/org/openjump/OpenJumpConfiguration.java core/trunk/src/org/openjump/core/apitools/IOTools.java core/trunk/src/org/openjump/core/ui/DatasetOptionsPanel.java core/trunk/src/org/openjump/core/ui/plugin/file/SaveLayersWithoutDataSourcePlugIn.java core/trunk/src/org/openjump/core/ui/plugin/layer/LayerPropertiesPlugIn.java core/trunk/src/org/openjump/core/ui/plugin/layer/NewLayerPropertiesPlugIn.java core/trunk/src/org/openjump/core/ui/plugin/mousemenu/SaveDatasetsPlugIn.java Modified: core/trunk/src/com/vividsolutions/jump/io/AbstractJUMPReader.java =================================================================== --- core/trunk/src/com/vividsolutions/jump/io/AbstractJUMPReader.java 2016-11-18 12:34:50 UTC (rev 5192) +++ core/trunk/src/com/vividsolutions/jump/io/AbstractJUMPReader.java 2016-11-18 12:38:53 UTC (rev 5193) @@ -12,8 +12,8 @@ */ abstract public class AbstractJUMPReader implements JUMPReader, TaskMonitorSupport { - protected Collection<Exception> exceptions = null; - protected TaskMonitor taskMonitor = null; + private Collection<Exception> exceptions = null; + private TaskMonitor taskMonitor = null; /** * Read the specified file using the filename given by the "File" property and @@ -23,7 +23,7 @@ protected void addException(Exception e) { if (exceptions == null) - exceptions = new ArrayList<Exception>(); + exceptions = new ArrayList<>(); exceptions.add(e); } @@ -33,7 +33,7 @@ */ public Collection<Exception> getExceptions() { if (exceptions == null) - exceptions = new ArrayList<Exception>(); + exceptions = new ArrayList<>(); return exceptions; } Modified: core/trunk/src/com/vividsolutions/jump/io/AbstractJUMPWriter.java =================================================================== --- core/trunk/src/com/vividsolutions/jump/io/AbstractJUMPWriter.java 2016-11-18 12:34:50 UTC (rev 5192) +++ core/trunk/src/com/vividsolutions/jump/io/AbstractJUMPWriter.java 2016-11-18 12:38:53 UTC (rev 5193) @@ -4,10 +4,10 @@ import com.vividsolutions.jump.task.TaskMonitor; import com.vividsolutions.jump.task.TaskMonitorSupport; -public abstract class AbstractJUMPWriter implements JUMPWriter, - TaskMonitorSupport { - protected TaskMonitor taskMonitor; +public abstract class AbstractJUMPWriter implements JUMPWriter, TaskMonitorSupport { + private TaskMonitor taskMonitor; + @Override abstract public void write(FeatureCollection featureCollection, DriverProperties dp) throws Exception; Modified: core/trunk/src/com/vividsolutions/jump/io/BaseFeatureInputStream.java =================================================================== --- core/trunk/src/com/vividsolutions/jump/io/BaseFeatureInputStream.java 2016-11-18 12:34:50 UTC (rev 5192) +++ core/trunk/src/com/vividsolutions/jump/io/BaseFeatureInputStream.java 2016-11-18 12:38:53 UTC (rev 5193) @@ -13,6 +13,7 @@ * They also need to set the featureSchema instance variable. */ public abstract class BaseFeatureInputStream implements FeatureInputStream { + private Feature nextFeature = null; public abstract FeatureSchema getFeatureSchema(); @@ -37,7 +38,7 @@ * Read the next feature, if any. * * @return the next Feature, or <code>null</code> if there is none - * @throws Exception + * @throws Exception if an exception occured while reading next Feature */ protected abstract Feature readNext() throws Exception; Modified: core/trunk/src/com/vividsolutions/jump/io/ColumnDescription.java =================================================================== --- core/trunk/src/com/vividsolutions/jump/io/ColumnDescription.java 2016-11-18 12:34:50 UTC (rev 5192) +++ core/trunk/src/com/vividsolutions/jump/io/ColumnDescription.java 2016-11-18 12:38:53 UTC (rev 5193) @@ -45,8 +45,8 @@ */ public class ColumnDescription { - public static final int VALUE_IS_BODY = 1; - public static final int VALUE_IS_ATT = 2; + static final int VALUE_IS_BODY = 1; + static final int VALUE_IS_ATT = 2; String columnName; //jcs column name String tagName; //XML tag this is a part of Modified: core/trunk/src/com/vividsolutions/jump/io/CompressedFile.java =================================================================== --- core/trunk/src/com/vividsolutions/jump/io/CompressedFile.java 2016-11-18 12:34:50 UTC (rev 5192) +++ core/trunk/src/com/vividsolutions/jump/io/CompressedFile.java 2016-11-18 12:38:53 UTC (rev 5193) @@ -113,7 +113,7 @@ } public static List<URI> listEntries(File file) throws Exception { - List<URI> entries = new ArrayList<URI>(); + List<URI> entries = new ArrayList<>(); // tar[.gz,.bz...] (un)compressed archive files if (CompressedFile.isTar(file.getName())) { @@ -237,7 +237,7 @@ } // load into memory workaround until commons compress 7zip learns streaming again - else if (compressedEntry != null && isSevenZ(filePath)) { + else if (isSevenZ(filePath)) { SevenZFile sevenZFile = new SevenZFile(new File(filePath)); try { Modified: core/trunk/src/com/vividsolutions/jump/io/DriverProperties.java =================================================================== --- core/trunk/src/com/vividsolutions/jump/io/DriverProperties.java 2016-11-18 12:34:50 UTC (rev 5192) +++ core/trunk/src/com/vividsolutions/jump/io/DriverProperties.java 2016-11-18 12:38:53 UTC (rev 5193) @@ -38,6 +38,8 @@ package com.vividsolutions.jump.io; +import com.vividsolutions.jump.io.datasource.DataSource; + import java.util.Properties; @@ -56,6 +58,9 @@ */ public class DriverProperties extends Properties { + static String DEFAULT_VALUE_KEY = "DefaultValue"; + + /** Creates new DataProperties */ public DriverProperties() { } @@ -66,7 +71,7 @@ *@param defaultValue value portion for the the key 'DefaultValue' */ public DriverProperties(String defaultValue) { - this.set("DefaultValue", defaultValue); + this.set(DEFAULT_VALUE_KEY, defaultValue); } /** Modified: core/trunk/src/com/vividsolutions/jump/io/FMEGMLReader.java =================================================================== --- core/trunk/src/com/vividsolutions/jump/io/FMEGMLReader.java 2016-11-18 12:34:50 UTC (rev 5192) +++ core/trunk/src/com/vividsolutions/jump/io/FMEGMLReader.java 2016-11-18 12:38:53 UTC (rev 5193) @@ -37,6 +37,7 @@ package com.vividsolutions.jump.io; import com.vividsolutions.jump.feature.FeatureCollection; +import com.vividsolutions.jump.io.datasource.DataSource; import java.io.*; import java.nio.charset.Charset; @@ -78,12 +79,12 @@ String inputfname; boolean isCompressed; - isCompressed = (dp.getProperty("CompressedFile") != null); + isCompressed = (dp.getProperty(DataSource.COMPRESSED_KEY) != null); - inputfname = dp.getProperty("DefaultValue"); + inputfname = dp.getProperty(DriverProperties.DEFAULT_VALUE_KEY); if (inputfname == null) { - inputfname = dp.getProperty("File"); + inputfname = dp.getProperty(DataSource.FILE_KEY); } if (inputfname == null) { @@ -93,7 +94,7 @@ if (isCompressed) { inputStream = CompressedFile.openFile(inputfname, - dp.getProperty("CompressedFile")); + dp.getProperty(DataSource.COMPRESSED_KEY)); } else { inputStream = new BufferedInputStream(new FileInputStream(inputfname)); } @@ -110,7 +111,7 @@ if (isCompressed) { inputStream = CompressedFile.openFile(inputfname, - dp.getProperty("CompressedFile")); + dp.getProperty(DataSource.COMPRESSED_KEY)); } else { inputStream = new BufferedInputStream(new FileInputStream(inputfname)); } @@ -155,7 +156,7 @@ int end; String propertyNamePrefix; - while ((foundStartTag == false) && (lineNo < 10)) { + while (!foundStartTag && lineNo < 10) { s = reader.readLine(); if (s == null) { @@ -165,7 +166,7 @@ lineNo++; - if (s.indexOf("<schemaFeatures>") > -1) { + if (s.contains("<schemaFeatures>")) { foundStartTag = true; } } @@ -177,20 +178,20 @@ columns = ""; - while ((foundEndTag == false)) { + while (!foundEndTag) { s = reader.readLine(); - if (s.indexOf("</schemaFeatures>") > -1) { + if (s.contains("</schemaFeatures>")) { foundEndTag = true; } - if ((s.indexOf("<property fme:name") != -1) || - (s.indexOf("<property name") != -1)) { + if ((s.contains("<property fme:name")) || + (s.contains("<property name"))) { //column definition //handle 2 fme variants - <property fme:name="name">...</property> and <property name="name">..</property> propertyNamePrefix = ""; - if (s.indexOf("<property fme:name") != -1) { + if (s.contains("<property fme:name")) { propertyNamePrefix = "fme:"; } @@ -282,12 +283,12 @@ * * @param fmeType type that fme reports (ie. fme_char, fme_decimal, long) */ - String FMEtypeToJCSType(String fmeType) { - if (fmeType.indexOf("fme_char") > -1) { + private String FMEtypeToJCSType(String fmeType) { + if (fmeType.contains("fme_char")) { return "STRING"; } - if (fmeType.indexOf("fme_decimal") > -1) { + if (fmeType.contains("fme_decimal")) { int loc; loc = fmeType.indexOf(","); @@ -303,7 +304,7 @@ return "DOUBLE"; } - if (fmeType.indexOf("long") > -1) { + if (fmeType.contains("long")) { return "DOUBLE"; // strange but true! } Modified: core/trunk/src/com/vividsolutions/jump/io/FMEGMLWriter.java =================================================================== --- core/trunk/src/com/vividsolutions/jump/io/FMEGMLWriter.java 2016-11-18 12:34:50 UTC (rev 5192) +++ core/trunk/src/com/vividsolutions/jump/io/FMEGMLWriter.java 2016-11-18 12:38:53 UTC (rev 5193) @@ -42,6 +42,7 @@ import java.util.Date; import com.vividsolutions.jump.feature.*; +import com.vividsolutions.jump.io.datasource.DataSource; /** @@ -104,7 +105,8 @@ */ public class FMEGMLWriter implements JUMPWriter { - int outputFormatType = 1; // 0 = 2000, 1 = 2001, others to come + private int outputFormatType = 1; // 0 = 2000, 1 = 2001, others to come + private String FME_FORMAT_VERSION = "FMEFormatVersion"; /** Creates new FMEGMLWriter */ public FMEGMLWriter() { @@ -124,10 +126,10 @@ java.io.BufferedWriter w; String outputfname; - outputfname = dp.getProperty("File"); + outputfname = dp.getProperty(DataSource.FILE_KEY); if (outputfname == null) { - outputfname = dp.getProperty("DefaultValue"); + outputfname = dp.getProperty(DriverProperties.DEFAULT_VALUE_KEY); } if (outputfname == null) { @@ -135,12 +137,12 @@ "call to FMEGMLWriter.write() has DataProperties w/o a OutputFile specified"); } - if (dp.getProperty("FMEFormatVersion") != null) { - if (dp.getProperty("FMEFormatVersion").equals("2000")) { + if (dp.getProperty(FME_FORMAT_VERSION) != null) { + if (dp.getProperty(FME_FORMAT_VERSION).equals("2000")) { outputFormatType = 0; } - if (dp.getProperty("FMEFormatVersion").equals("2001")) { + if (dp.getProperty(FME_FORMAT_VERSION).equals("2001")) { outputFormatType = 1; } } @@ -165,7 +167,7 @@ * * @param fs description of the column in the dataset. */ - public GMLOutputTemplate createOutputTemplate(FeatureSchema fs) throws Exception { + private GMLOutputTemplate createOutputTemplate(FeatureSchema fs) throws Exception { GMLOutputTemplate result; String templateText; String column; @@ -290,7 +292,7 @@ * * @param jcsType JCS column type (ie. 'STRING','DOUBLE', or 'INTEGER' */ - String JCSattributeType2FMEtype(String jcsType) throws ParseException { + private String JCSattributeType2FMEtype(String jcsType) throws ParseException { switch (outputFormatType) { case 0: Modified: core/trunk/src/com/vividsolutions/jump/io/GMLGeometryWriter.java =================================================================== --- core/trunk/src/com/vividsolutions/jump/io/GMLGeometryWriter.java 2016-11-18 12:34:50 UTC (rev 5192) +++ core/trunk/src/com/vividsolutions/jump/io/GMLGeometryWriter.java 2016-11-18 12:38:53 UTC (rev 5193) @@ -51,7 +51,7 @@ * @return a <code>String</code> of characters */ private static String stringOfChar(char ch, int count) { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); for (int i = 0; i < count; i++) { buf.append(ch); } @@ -72,7 +72,7 @@ public GMLGeometryWriter() { } - public void setLinePrefix(String linePrefix) + void setLinePrefix(String linePrefix) { this.linePrefix = linePrefix; } @@ -80,7 +80,7 @@ /** * Sets the <code>srsName</code> attribute to be output on the Geometry element. * If <code>null</code> no attribute will be output. - * @param srsName + * @param srsName name of the SpatialReferenceSystem */ public void setSRSName(String srsName) { @@ -92,12 +92,12 @@ * If <code>null</code> no attribute will be output. * @param gid the geographic identifier */ - public void setGID(String gid) + void setGID(String gid) { this.gid = gid; } - public void setMaximumCoordinatesPerLine(int maxCoordinatesPerLine) + void setMaximumCoordinatesPerLine(int maxCoordinatesPerLine) { if (maxCoordinatesPerLine <= 0) { this.maxCoordinatesPerLine = 1; @@ -166,7 +166,7 @@ private String geometryTag(String geometryName, String attributes) { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); buf.append("<gml:"); buf.append(geometryName); if (attributes != null && attributes.length() > 0) { @@ -179,7 +179,7 @@ private String attributeString() { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); if (gid != null) { buf.append(" gid='"); buf.append(gid); Modified: core/trunk/src/com/vividsolutions/jump/io/GMLInputTemplate.java =================================================================== --- core/trunk/src/com/vividsolutions/jump/io/GMLInputTemplate.java 2016-11-18 12:34:50 UTC (rev 5192) +++ core/trunk/src/com/vividsolutions/jump/io/GMLInputTemplate.java 2016-11-18 12:38:53 UTC (rev 5193) @@ -60,31 +60,32 @@ */ public class GMLInputTemplate extends DefaultHandler { - XMLReader xr; - String tagBody = ""; + boolean loaded = false; String collectionTag; String featureTag; - private ArrayList<String> geometryElements = new ArrayList<>(20); //shouldnt need more than 20, but will auto-expand bigger - String streamName; - boolean havecollectionTag = false; - boolean havefeatureTag = false; - boolean havegeometryElement = false; - public boolean loaded = false; ArrayList<ColumnDescription> columnDefinitions = new ArrayList<>(); //list of type ColumnDescription + private XMLReader xr; + private String tagBody = ""; + private ArrayList<String> geometryElements = new ArrayList<>(20); //shouldnt need more than 20, but will auto-expand bigger + private String streamName; + private boolean havecollectionTag = false; + private boolean havefeatureTag = false; + private boolean havegeometryElement = false; + //for the jcs column definition - int columnDef_valueType = 0; // 0 - undef, 1 = body, 2 = attribute - String columnDef_valueAttribute = ""; // name of the attribute the value is in - String columnDef_tagName = ""; // tag this is a part of - int columnDef_tagType = 0; // 0 - undef, 1=tag only, 2 = attribute, 3 = att & value - String columnDef_tagAttribute = ""; - String columnDef_tagValue = ""; - String columnDef_columnName = ""; - AttributeType columnDef_type = null; - String lastStartTag_uri; - String lastStartTag_name; - String lastStartTag_qName; - Attributes lastStartTag_atts; + private int columnDef_valueType = 0; // 0 - undef, 1 = body, 2 = attribute + private String columnDef_valueAttribute = ""; // name of the attribute the value is in + private String columnDef_tagName = ""; // tag this is a part of + private int columnDef_tagType = 0; // 0 - undef, 1=tag only, 2 = attribute, 3 = att & value + private String columnDef_tagAttribute = ""; + private String columnDef_tagValue = ""; + private String columnDef_columnName = ""; + private AttributeType columnDef_type = null; + private String lastStartTag_uri; + private String lastStartTag_name; + private String lastStartTag_qName; + private Attributes lastStartTag_atts; /** * constructor - makes a new org.apache.xerces.parser and makes this class be the SAX @@ -101,7 +102,7 @@ * Returns the column name for the 'index'th column. *@param index 0=first */ - public String columnName(int index) throws ParseException { + String columnName(int index) throws ParseException { if (loaded) { return columnDefinitions.get(index).columnName; } else { @@ -113,7 +114,7 @@ /** * Converts this GMLInputTemplate to a feature schema. */ - public FeatureSchema toFeatureSchema() throws ParseException { + FeatureSchema toFeatureSchema() throws ParseException { if (!(loaded)) { throw new ParseException( "requested toFeatureSchema w/o loading the template"); @@ -134,7 +135,7 @@ * Function to help the GMLParser - is this tag name the Geometry Element tag name? *@param tag an XML tag name **/ - public boolean isGeometryElement(String tag) { + boolean isGeometryElement(String tag) { int t; String s; @@ -272,7 +273,7 @@ * @param tagBody value of the XML tag body * @param xmlAtts key/values of the XML tag's attributes */ - public Object getColumnValue(int index, String tagBody, Attributes xmlAtts) + Object getColumnValue(int index, String tagBody, Attributes xmlAtts) throws ParseException { String val; ColumnDescription cd; @@ -443,7 +444,7 @@ *@param atts the attributes for the xml tag (from SAX) *@param att_name the name of the attribute to search for */ - int lookupAttribute(Attributes atts, String att_name) { + private int lookupAttribute(Attributes atts, String att_name) { int t; for (t = 0; t < atts.getLength(); t++) { Modified: core/trunk/src/com/vividsolutions/jump/io/GMLOutputTemplate.java =================================================================== --- core/trunk/src/com/vividsolutions/jump/io/GMLOutputTemplate.java 2016-11-18 12:34:50 UTC (rev 5192) +++ core/trunk/src/com/vividsolutions/jump/io/GMLOutputTemplate.java 2016-11-18 12:38:53 UTC (rev 5193) @@ -105,30 +105,31 @@ public class GMLOutputTemplate { String headerText; - String footerText; - String AllFeatureText; ArrayList<String> featureText = new ArrayList<>(); ArrayList<String> codingText = new ArrayList<>(); String featureTextfooter; - int lineNumber = 0; - String streamName; + String footerText; + private String AllFeatureText; + private int lineNumber = 0; + private String streamName; + /** constructor**/ public GMLOutputTemplate() { } /** sets the HeaderText for the Outputtemplate */ - public void setHeaderText(String text) { + void setHeaderText(String text) { headerText = text; } /** sets the FooterText for the Outputtemplate */ - public void setFooterText(String text) { + void setFooterText(String text) { footerText = text; } /** sets the Footer text for the bottom of the feature*/ - public void setFeatureFooter(String text) { + void setFeatureFooter(String text) { featureTextfooter = text; } Modified: core/trunk/src/com/vividsolutions/jump/io/GMLReader.java =================================================================== --- core/trunk/src/com/vividsolutions/jump/io/GMLReader.java 2016-11-18 12:34:50 UTC (rev 5192) +++ core/trunk/src/com/vividsolutions/jump/io/GMLReader.java 2016-11-18 12:38:53 UTC (rev 5193) @@ -218,8 +218,8 @@ */ public class GMLReader extends DefaultHandler implements JUMPReader { - static int STATE_GET_COLUMNS = 3; - Collection<Exception> exceptions; + private static int STATE_GET_COLUMNS = 3; + private Collection<Exception> exceptions; /** * STATE MEANING <br> @@ -231,14 +231,14 @@ * 1000 Parsing Multi-geometry, recursion level =1 <br> * 1001 Parsing Multi-geometry, recursion level =2 <br> */ - static int STATE_INIT = 0; - static int STATE_PARSE_GEOM_NESTED = 1000; - static int STATE_PARSE_GEOM_SIMPLE = 4; - static int STATE_WAIT_COLLECTION_TAG = 1; - static int STATE_WAIT_FEATURE_TAG = 2; + private static int STATE_INIT = 0; + private static int STATE_PARSE_GEOM_NESTED = 1000; + private static int STATE_PARSE_GEOM_SIMPLE = 4; + private static int STATE_WAIT_COLLECTION_TAG = 1; + private static int STATE_WAIT_FEATURE_TAG = 2; - final static List<String> simpleGeoms = new ArrayList<>(); - final static List<String> multiGeoms = new ArrayList<>(); + private final static List<String> simpleGeoms = new ArrayList<>(); + private final static List<String> multiGeoms = new ArrayList<>(); static { multiGeoms.add("multipoint"); @@ -252,46 +252,46 @@ simpleGeoms.add("linearring"); } - GMLInputTemplate GMLinput = null; - int STATE = STATE_INIT; // list of points - Point apoint; - Feature currentFeature; - int currentGeometryNumb = 1; - FeatureCollection fc; - FeatureSchema fcmd; // list of geometries - Geometry finalGeometry; // list of geometrycollections - list of list of + private GMLInputTemplate GMLinput = null; + private int STATE = STATE_INIT; // list of points + private Point apoint; + private Feature currentFeature; + private int currentGeometryNumb = 1; + private FeatureCollection fc; + private FeatureSchema fcmd; // list of geometries + private Geometry finalGeometry; // list of geometrycollections - list of list of // geometry - String current_geom_qname = ""; - ArrayList<Geometry> geometry; - GeometryFactory geometryFactory = new GeometryFactory(); // this might get + private String current_geom_qname = ""; + private ArrayList<Geometry> geometry; + private GeometryFactory geometryFactory = new GeometryFactory(); // this might get // replaced if // there's an SRID // change - ArrayList<LinearRing> innerBoundaries = new ArrayList<>(); - Attributes lastStartTag_atts; - String lastStartTag_name; - String lastStartTag_qName; // accumulate values inside a tag + private ArrayList<LinearRing> innerBoundaries = new ArrayList<>(); + private Attributes lastStartTag_atts; + private String lastStartTag_name; + private String lastStartTag_qName; // accumulate values inside a tag // info about the last start tag encountered - String lastStartTag_uri; - LineString lineString; - LinearRing linearRing; // a LR - LinearRing outerBoundary; // list of LinearRing - ArrayList<Coordinate> pointList = new ArrayList<>(); // list of accumulated points + private String lastStartTag_uri; + private LineString lineString; + private LinearRing linearRing; // a LR + private LinearRing outerBoundary; // list of LinearRing + private ArrayList<Coordinate> pointList = new ArrayList<>(); // list of accumulated points // (Coordinate) - Polygon polygon; // polygon + private Polygon polygon; // polygon // higherlevel geomery object - ArrayList<ArrayList> recursivegeometry = new ArrayList<>(); + private ArrayList<ArrayList> recursivegeometry = new ArrayList<>(); // low-level geometry objects - Coordinate singleCoordinate = new Coordinate(); - String streamName; // result geometry - - StringBuffer tagBody; - XMLReader xr; // see above + private Coordinate singleCoordinate = new Coordinate(); + private String streamName; // result geometry - + private StringBuffer tagBody; + private XMLReader xr; // see above - int SRID = 0; // srid to give the created geometries - public boolean parseSRID = false; // true = put SRID for srsName="EPSG:42102" + private int SRID = 0; // srid to give the created geometries + private boolean parseSRID = false; // true = put SRID for srsName="EPSG:42102" /** * true => for 'OBJECT' types, if you find more than 1 item, make a list and Modified: core/trunk/src/com/vividsolutions/jump/io/GMLWriter.java =================================================================== --- core/trunk/src/com/vividsolutions/jump/io/GMLWriter.java 2016-11-18 12:34:50 UTC (rev 5192) +++ core/trunk/src/com/vividsolutions/jump/io/GMLWriter.java 2016-11-18 12:38:53 UTC (rev 5193) @@ -108,9 +108,9 @@ public class GMLWriter implements JUMPWriter { // Standard tags for the auto-generated outputTemplate. - public static String standard_geom = "geometry"; - public static String standard_feature = "feature"; - public static String standard_featureCollection = "featureCollection"; + private static String standard_geom = "geometry"; + private static String standard_feature = "feature"; + private static String standard_featureCollection = "featureCollection"; private GMLOutputTemplate outputTemplate = null; private GMLGeometryWriter geometryWriter = new GMLGeometryWriter(); @@ -213,7 +213,7 @@ * Ie. convert "<" to "<" *@param s string to safe-ify */ - public static String safeXML(String s) { + private static String safeXML(String s) { if (s == null) return null; StringBuilder sb = new StringBuilder(s); char c; @@ -248,7 +248,7 @@ /** * Attaches a GMLOuputTemplate */ - public void setOutputTemplate(GMLOutputTemplate ot) { + void setOutputTemplate(GMLOutputTemplate ot) { outputTemplate = ot; } @@ -390,7 +390,7 @@ * in the JCS format * @param fcmd input featureSchema */ - public static GMLOutputTemplate makeOutputTemplate(FeatureSchema fcmd) { + private static GMLOutputTemplate makeOutputTemplate(FeatureSchema fcmd) { GMLOutputTemplate result; String inputTemplate; int t; @@ -436,13 +436,14 @@ return result; } - /**given a FeatureSchema, make a chunk of XML that represents a valid - * GMLInputTemplate for the JCS format. Used by makeOutputTemplate since the + /** + * Given a FeatureSchema, make a chunk of XML that represents a valid + * GMLInputTemplate for the JCS format. Used by makeOutputTemplate since the * output template includes an inputtemplate. * - *@param fcmd the featureSchema to describe + * @param fcmd the featureSchema to describe */ - public static String makeInputTemplate(FeatureSchema fcmd) { + private static String makeInputTemplate(FeatureSchema fcmd) { String result; int t; Modified: core/trunk/src/com/vividsolutions/jump/io/JMLReader.java =================================================================== --- core/trunk/src/com/vividsolutions/jump/io/JMLReader.java 2016-11-18 12:34:50 UTC (rev 5192) +++ core/trunk/src/com/vividsolutions/jump/io/JMLReader.java 2016-11-18 12:38:53 UTC (rev 5193) @@ -39,6 +39,7 @@ package com.vividsolutions.jump.io; import com.vividsolutions.jump.feature.FeatureCollection; +import com.vividsolutions.jump.io.datasource.DataSource; /** @@ -97,10 +98,10 @@ GMLReader gmlReader; String inputFname; - inputFname = dp.getProperty("File"); + inputFname = dp.getProperty(DataSource.FILE_KEY); if (inputFname == null) { - inputFname = dp.getProperty("DefaultValue"); + inputFname = dp.getProperty(DriverProperties.DEFAULT_VALUE_KEY); } if (inputFname == null) { Modified: core/trunk/src/com/vividsolutions/jump/io/JMLWriter.java =================================================================== --- core/trunk/src/com/vividsolutions/jump/io/JMLWriter.java 2016-11-18 12:34:50 UTC (rev 5192) +++ core/trunk/src/com/vividsolutions/jump/io/JMLWriter.java 2016-11-18 12:38:53 UTC (rev 5193) @@ -39,6 +39,7 @@ package com.vividsolutions.jump.io; import com.vividsolutions.jump.feature.FeatureCollection; +import com.vividsolutions.jump.io.datasource.DataSource; /** @@ -82,10 +83,10 @@ GMLWriter gmlWriter; String outputFname; - outputFname = dp.getProperty("File"); + outputFname = dp.getProperty(DataSource.FILE_KEY); if (outputFname == null) { - outputFname = dp.getProperty("DefaultValue"); + outputFname = dp.getProperty(DriverProperties.DEFAULT_VALUE_KEY); } if (outputFname == null) { Modified: core/trunk/src/com/vividsolutions/jump/io/ParseException.java =================================================================== --- core/trunk/src/com/vividsolutions/jump/io/ParseException.java 2016-11-18 12:34:50 UTC (rev 5192) +++ core/trunk/src/com/vividsolutions/jump/io/ParseException.java 2016-11-18 12:38:53 UTC (rev 5193) @@ -45,8 +45,8 @@ //fileName. cpos is kind of cryptic. Also, the Java naming convention is to //separate words with capitals; for example, lineNo rather than lineno. [Jon Aquino] public String fileName; - public int lineNumber; - public int charPos; + private int lineNumber; + private int charPos; /** construct exception with a message*/ public ParseException(String message) { Modified: core/trunk/src/com/vividsolutions/jump/io/ShapefileReader.java =================================================================== --- core/trunk/src/com/vividsolutions/jump/io/ShapefileReader.java 2016-11-18 12:34:50 UTC (rev 5192) +++ core/trunk/src/com/vividsolutions/jump/io/ShapefileReader.java 2016-11-18 12:38:53 UTC (rev 5193) @@ -49,6 +49,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import com.vividsolutions.jump.io.datasource.DataSource; import org.geotools.dbffile.DbfFile; import org.geotools.shapefile.Shapefile; @@ -109,11 +110,6 @@ private File delete_this_tmp_shx = null; private File delete_this_tmp_cpg = null; - public static final String FILE_PROPERTY_KEY = "File"; - public static final String DEFAULT_VALUE_PROPERTY_KEY = "DefaultValue"; - public static final String COMPRESSED_FILE_PROPERTY_KEY = "CompressedFile"; - - /** Creates new ShapeReader */ public ShapefileReader() { } @@ -132,10 +128,10 @@ // ATTENTION: this can contain a zip file path as well // shpFileName contains the .shp extension - String shpFileName = dp.getProperty(FILE_PROPERTY_KEY); + String shpFileName = dp.getProperty(DataSource.FILE_KEY); if (shpFileName == null) { - shpFileName = dp.getProperty(DEFAULT_VALUE_PROPERTY_KEY); + shpFileName = dp.getProperty(DriverProperties.DEFAULT_VALUE_KEY); } if (shpFileName == null) { @@ -143,15 +139,15 @@ } //okay, we have .shp and .dbf file paths, lets create Shapefile and DbfFile - Shapefile myshape = getShapefile(shpFileName, dp.getProperty(COMPRESSED_FILE_PROPERTY_KEY)); + Shapefile myshape = getShapefile(shpFileName, dp.getProperty(DataSource.COMPRESSED_KEY)); // charset used to read dbf (one charset defined by cpg file, // charset defined in dp or default platform charset) String charsetName = getCharset(shpFileName, dp); - DbfFile mydbf = getDbfFile(shpFileName, dp.getProperty(COMPRESSED_FILE_PROPERTY_KEY), + DbfFile mydbf = getDbfFile(shpFileName, dp.getProperty(DataSource.COMPRESSED_KEY), Charset.forName(charsetName)); - InputStream shx = getShx(shpFileName, dp.getProperty(COMPRESSED_FILE_PROPERTY_KEY)); + InputStream shx = getShx(shpFileName, dp.getProperty(DataSource.COMPRESSED_KEY)); GeometryFactory factory = new GeometryFactory(); GeometryCollection collection = null; try { @@ -315,7 +311,7 @@ // if a cpg file is found, charset used is the one defined in the cpg file //BufferedReader cpgCharsetReader = null; try (InputStream cpgCharsetInputStream = - getCpgInputStream(shpFileName, dp.getProperty(COMPRESSED_FILE_PROPERTY_KEY))) { + getCpgInputStream(shpFileName, dp.getProperty(DataSource.COMPRESSED_KEY))) { if (cpgCharsetInputStream != null) { try (BufferedReader cpgCharsetReader = new BufferedReader(new InputStreamReader(cpgCharsetInputStream))) { @@ -333,9 +329,9 @@ } // if dp.getProperty("charset") contains a charset different from platform default, // this charset is preferred to the one defined by cpg file - if (dp.getProperty("charset") != null && Charset.isSupported(dp.getProperty("charset")) && - !Charset.defaultCharset().name().equals(Charset.forName(dp.getProperty("charset")).name())) { - charsetName = dp.getProperty("charset"); + if (dp.getProperty(DataSource.CHARSET_KEY) != null && Charset.isSupported(dp.getProperty(DataSource.CHARSET_KEY)) && + !Charset.defaultCharset().name().equals(Charset.forName(dp.getProperty(DataSource.CHARSET_KEY)).name())) { + charsetName = dp.getProperty(DataSource.CHARSET_KEY); } return charsetName; } Modified: core/trunk/src/com/vividsolutions/jump/io/ShapefileWriter.java =================================================================== --- core/trunk/src/com/vividsolutions/jump/io/ShapefileWriter.java 2016-11-18 12:34:50 UTC (rev 5192) +++ core/trunk/src/com/vividsolutions/jump/io/ShapefileWriter.java 2016-11-18 12:38:53 UTC (rev 5193) @@ -38,6 +38,7 @@ import com.vividsolutions.jump.feature.Feature; import com.vividsolutions.jump.feature.FeatureCollection; import com.vividsolutions.jump.feature.FeatureSchema; +import com.vividsolutions.jump.io.datasource.DataSource; import com.vividsolutions.jump.workbench.ui.OKCancelDialog; import org.geotools.dbffile.DbfFieldDef; import org.geotools.dbffile.DbfFile; @@ -222,13 +223,13 @@ **/ public class ShapefileWriter implements JUMPWriter { - public static final String FILE_PROPERTY_KEY = "File"; - public static final String DEFAULT_VALUE_PROPERTY_KEY = "DefaultValue"; - public static final String SHAPE_TYPE_PROPERTY_KEY = "ShapeType"; - public static boolean truncate = false; + //public static final String FILE_PROPERTY_KEY = "File"; + //public static final String DEFAULT_VALUE_PROPERTY_KEY = "DefaultValue"; + private static final String SHAPE_TYPE_PROPERTY_KEY = "ShapeType"; + private static boolean truncate = false; private static long lastTimeTruncate = new Date(0).getTime(); - protected static CGAlgorithms CG_ALGO = new CGAlgorithms(); + private static CGAlgorithms CG_ALGO = new CGAlgorithms(); /** Creates new ShapefileWriter */ public ShapefileWriter() { @@ -258,10 +259,10 @@ //sstein: check for mixed geometry types in the FC this.checkIfGeomsAreMixed(featureCollection); - shpfileName = dp.getProperty(FILE_PROPERTY_KEY); + shpfileName = dp.getProperty(DataSource.FILE_KEY); if (shpfileName == null) { - shpfileName = dp.getProperty(DEFAULT_VALUE_PROPERTY_KEY); + shpfileName = dp.getProperty(DriverProperties.DEFAULT_VALUE_KEY); } if (shpfileName == null) { @@ -290,7 +291,7 @@ fname_withoutextention = fname.substring(0, loc); // ie. "hills.shp" -> "hills." dbffname = path + fname_withoutextention + ".dbf"; - String charsetName = dp.getProperty("charset"); + String charsetName = dp.getProperty(DataSource.CHARSET_KEY); if (charsetName == null) charsetName = Charset.defaultCharset().name(); writeDbf(featureCollection, dbffname, Charset.forName(charsetName)); PrintWriter pw = null; @@ -361,7 +362,7 @@ * (3 is for x,y,m but thats not supported yet) <br> * @param g geometry to test - looks at 1st coordinate */ - public int guessCoordinateDims(Geometry g) { + private int guessCoordinateDims(Geometry g) { Coordinate[] cs = g.getCoordinates(); for (Coordinate coord : cs) { @@ -394,7 +395,7 @@ * July 2, 2010 - modified by beckerl to read existing dbf file header * and use the existing numeric field definitions. */ - void writeDbf(FeatureCollection featureCollection, String fname, Charset charset) + private void writeDbf(FeatureCollection featureCollection, String fname, Charset charset) throws Exception { DbfFileWriter dbf; FeatureSchema fs; @@ -730,7 +731,7 @@ * @param fc features to look at * @param attributeIndex which of the column to test. */ - int findMaxStringLength(FeatureCollection fc, int attributeIndex, Charset charset) { + private int findMaxStringLength(FeatureCollection fc, int attributeIndex, Charset charset) { int l; int maxlen = 0; Feature f; @@ -764,7 +765,7 @@ * 31 : only non empty geometry collection<br> * @param fc feature collection containing tet geometries. */ - int findBestGeometryType(FeatureCollection fc) { + private int findBestGeometryType(FeatureCollection fc) { Geometry geom; boolean onlyPoints = true; boolean onlyEmptyGeometryCollection = true; @@ -814,7 +815,7 @@ } - public void checkIfGeomsAreMixed(FeatureCollection featureCollection) throws Exception { + private void checkIfGeomsAreMixed(FeatureCollection featureCollection) throws Exception { //-- sstein: check first if features are of different geometry type. int i= 0; Class firstClass = null; @@ -862,7 +863,7 @@ /** * Reverses the order of points in lr (is CW -> CCW or CCW->CW) */ - LinearRing reverseRing(LinearRing lr) { + private LinearRing reverseRing(LinearRing lr) { int numPoints = lr.getNumPoints(); Coordinate[] newCoords = new Coordinate[numPoints]; @@ -877,7 +878,7 @@ * Make sure outer ring is CCW and holes are CW * @param p polygon to check */ - Polygon makeGoodSHAPEPolygon(Polygon p) { + private Polygon makeGoodSHAPEPolygon(Polygon p) { if (p.isEmpty()) return p; @@ -887,7 +888,7 @@ coords = p.getExteriorRing().getCoordinates(); - if (CG_ALGO.isCCW(coords)) { + if (CGAlgorithms.isCCW(coords)) { outer = reverseRing((LinearRing) p.getExteriorRing()); } else { outer = (LinearRing) p.getExteriorRing(); @@ -895,7 +896,7 @@ for (int t = 0; t < p.getNumInteriorRing(); t++) { coords = p.getInteriorRingN(t).getCoordinates(); - if (!(CG_ALGO.isCCW(coords))) { + if (!(CGAlgorithms.isCCW(coords))) { holes[t] = reverseRing((LinearRing) p.getInteriorRingN(t)); } else { holes[t] = (LinearRing) p.getInteriorRingN(t); @@ -909,7 +910,7 @@ * Make sure outer ring is CCW and holes are CW for all the polygons in the Geometry * @param mp set of polygons to check */ - MultiPolygon makeGoodSHAPEMultiPolygon(MultiPolygon mp) { + private MultiPolygon makeGoodSHAPEMultiPolygon(MultiPolygon mp) { MultiPolygon result; Polygon[] ps = new Polygon[mp.getNumGeometries()]; @@ -933,7 +934,7 @@ * * @param fc feature collection to make homogeneous */ - public GeometryCollection makeSHAPEGeometryCollection(FeatureCollection fc) + private GeometryCollection makeSHAPEGeometryCollection(FeatureCollection fc) throws Exception { GeometryCollection result; Geometry[] allGeoms = new Geometry[fc.size()]; Modified: core/trunk/src/com/vividsolutions/jump/io/WKTReader.java =================================================================== --- core/trunk/src/com/vividsolutions/jump/io/WKTReader.java 2016-11-18 12:34:50 UTC (rev 5192) +++ core/trunk/src/com/vividsolutions/jump/io/WKTReader.java 2016-11-18 12:38:53 UTC (rev 5193) @@ -38,6 +38,7 @@ import com.vividsolutions.jts.geom.GeometryFactory; import com.vividsolutions.jts.io.ParseException; import com.vividsolutions.jump.feature.*; +import com.vividsolutions.jump.io.datasource.DataSource; /** @@ -87,12 +88,12 @@ boolean isCompressed; Reader fileReader = null; - isCompressed = (dp.getProperty("CompressedFile") != null); + isCompressed = (dp.getProperty(DataSource.COMPRESSED_KEY) != null); - inputFname = dp.getProperty("File"); + inputFname = dp.getProperty(DataSource.FILE_KEY); if (inputFname == null) { - inputFname = dp.getProperty("DefaultValue"); + inputFname = dp.getProperty(DriverProperties.DEFAULT_VALUE_KEY); } if (inputFname == null) { @@ -103,7 +104,7 @@ try { if (isCompressed) { fileReader = new InputStreamReader(CompressedFile.openFile( - inputFname, dp.getProperty("CompressedFile"))); + inputFname, dp.getProperty(DataSource.COMPRESSED_KEY))); } else { fileReader = new FileReader(inputFname); } Modified: core/trunk/src/com/vividsolutions/jump/io/WKTWriter.java =================================================================== --- core/trunk/src/com/vividsolutions/jump/io/WKTWriter.java 2016-11-18 12:34:50 UTC (rev 5192) +++ core/trunk/src/com/vividsolutions/jump/io/WKTWriter.java 2016-11-18 12:38:53 UTC (rev 5193) @@ -39,6 +39,7 @@ import com.vividsolutions.jump.feature.Feature; import com.vividsolutions.jump.feature.FeatureCollection; +import com.vividsolutions.jump.io.datasource.DataSource; /** * WKTWriter is a {@link JUMPWriter} specialized to write WTK (Well Known Text) files. @@ -82,10 +83,10 @@ String outputFname; - outputFname = dp.getProperty("File"); + outputFname = dp.getProperty(DataSource.FILE_KEY); if (outputFname == null) { - outputFname = dp.getProperty("DefaultValue"); + outputFname = dp.getProperty(DriverProperties.DEFAULT_VALUE_KEY); } if (outputFname == null) { Modified: core/trunk/src/com/vividsolutions/jump/io/datasource/DataSource.java =================================================================== --- core/trunk/src/com/vividsolutions/jump/io/datasource/DataSource.java 2016-11-18 12:34:50 UTC (rev 5192) +++ core/trunk/src/com/vividsolutions/jump/io/datasource/DataSource.java 2016-11-18 12:38:53 UTC (rev 5193) @@ -47,17 +47,17 @@ */ public abstract class DataSource { - private Map properties; + private Map<String,Object> properties; /** * Sets properties required to open a DataSource, such as username, password, * filename, coordinate system, etc. Called by DataSourceQueryChoosers. */ - public void setProperties(Map properties) { - this.properties = new HashMap(properties); + public void setProperties(Map<String,Object> properties) { + this.properties = new HashMap<>(properties); } - public Map getProperties() { + public Map<String,Object> getProperties() { // This method needs to be public because it is called by Java2XML [Jon // Aquino 11/13/2003] @@ -89,6 +89,11 @@ public static final String COMPRESSED_KEY = "CompressedFile"; /** + * A property used to define the datasource encoding + */ + public static final String CHARSET_KEY = "charset"; + + /** * Coordinate-system property, used for files and other DataSources that have * a single CoordinateSystem */ Modified: core/trunk/src/com/vividsolutions/jump/io/datasource/FileDataSource.java =================================================================== --- core/trunk/src/com/vividsolutions/jump/io/datasource/FileDataSource.java 2016-11-18 12:34:50 UTC (rev 5192) +++ core/trunk/src/com/vividsolutions/jump/io/datasource/FileDataSource.java 2016-11-18 12:38:53 UTC (rev 5193) @@ -1,6 +1,6 @@ package com.vividsolutions.jump.io.datasource; -abstract public class FileDataSource extends DataSource { +abstract class FileDataSource extends DataSource { abstract public String[] getExtensions(); Modified: core/trunk/src/com/vividsolutions/jump/io/datasource/ReaderWriterFileDataSource.java =================================================================== --- core/trunk/src/com/vividsolutions/jump/io/datasource/ReaderWriterFileDataSource.java 2016-11-18 12:34:50 UTC (rev 5192) +++ core/trunk/src/com/vividsolutions/jump/io/datasource/ReaderWriterFileDataSource.java 2016-11-18 12:38:53 UTC (rev 5193) @@ -174,11 +174,11 @@ protected DriverProperties getDriverProperties(){ DriverProperties properties = new DriverProperties(); - Map<Object,Object> map = getProperties(); + Map<String,Object> map = getProperties(); // explicitly copy into properties object or getProperty() returns null - for (Map.Entry entry : map.entrySet()){ - properties.setProperty(String.valueOf(entry.getKey()), (String.valueOf(entry.getValue()))); + for (Map.Entry<String,Object> entry : map.entrySet()){ + properties.setProperty(entry.getKey(), (String.valueOf(entry.getValue()))); } return properties; Modified: core/trunk/src/com/vividsolutions/jump/io/datasource/StandardReaderWriterFileDataSource.java =================================================================== --- core/trunk/src/com/vividsolutions/jump/io/datasource/StandardReaderWriterFileDataSource.java 2016-11-18 12:34:50 UTC (rev 5192) +++ core/trunk/src/com/vividsolutions/jump/io/datasource/StandardReaderWriterFileDataSource.java 2016-11-18 12:38:53 UTC (rev 5193) @@ -50,6 +50,8 @@ public static final String[] GML_EXTENSIONS = new String[] { "gml", "xml" }; + public static String TEMPLATE_FILE_KEY = "TemplateFile"; + public static final String OUTPUT_TEMPLATE_FILE_KEY = "Output Template File"; public static final String INPUT_TEMPLATE_FILE_KEY = "Input Template File"; @@ -69,7 +71,7 @@ * receive the properties they need to do decompression. */ private static class ClassicReaderWriterFileDataSource extends StandardReaderWriterFileDataSource { - public ClassicReaderWriterFileDataSource( + ClassicReaderWriterFileDataSource( JUMPReader reader, JUMPWriter writer, String[] extensions) { @@ -150,14 +152,14 @@ } protected DriverProperties getReaderDriverProperties() { return super.getReaderDriverProperties().set( - "TemplateFile", - (String) getProperties().get(StandardReaderWriterFileDataSource.INPUT_TEMPLATE_FILE_KEY)); + TEMPLATE_FILE_KEY, + (String) getProperties().get(StandardReaderWriterFileDataSource.INPUT_TEMPLATE_FILE_KEY)); } protected DriverProperties getWriterDriverProperties() { return super.getWriterDriverProperties().set( - "TemplateFile", - (String) getProperties().get(StandardReaderWriterFileDataSource.OUTPUT_TEMPLATE_FILE_KEY)); + TEMPLATE_FILE_KEY, + (String) getProperties().get(StandardReaderWriterFileDataSource.OUTPUT_TEMPLATE_FILE_KEY)); } public boolean isReadable() { Modified: core/trunk/src/com/vividsolutions/jump/workbench/datasource/InstallStandardDataSourceQueryChoosersPlugIn.java =================================================================== --- core/trunk/src/com/vividsolutions/jump/workbench/datasource/InstallStandardDataSourceQueryChoosersPlugIn.java 2016-11-18 12:34:50 UTC (rev 5192) +++ core/trunk/src/com/vividsolutions/jump/workbench/datasource/InstallStandardDataSourceQueryChoosersPlugIn.java 2016-11-18 12:38:53 UTC (rev 5193) @@ -34,6 +34,7 @@ import com.vividsolutions.jts.util.Assert; import com.vividsolutions.jump.I18N; import com.vividsolutions.jump.io.*; +import com.vividsolutions.jump.io.datasource.DataSource; import com.vividsolutions.jump.io.datasource.StandardReaderWriterFileDataSource; import com.vividsolutions.jump.io.geojson.GeoJSONReader; import com.vividsolutions.jump.io.geojson.GeoJSONWriter; @@ -105,7 +106,7 @@ charsetName = (String) ((ComboBoxComponentPanel) comboboxFieldComponent) .getSelectedItem(); } - properties.put("charset", charsetName); + properties.put(DataSource.CHARSET_KEY, charsetName); return properties; } Modified: core/trunk/src/org/openjump/OpenJumpConfiguration.java =================================================================== --- core/trunk/src/org/openjump/OpenJumpConfiguration.java 2016-11-18 12:34:50 UTC (rev 5192) +++ core/trunk/src/org/openjump/OpenJumpConfiguration.java 2016-11-18 12:38:53 UTC (rev 5193) @@ -19,6 +19,7 @@ import java.util.Arrays; import java.util.List; +import com.vividsolutions.jump.io.datasource.DataSource; import org.openjump.core.feature.BeanshellAttributeOperationFactory; import org.openjump.core.rasterimage.AddRasterImageLayerWizard; import org.openjump.core.rasterimage.RasterImageLayer; @@ -177,7 +178,7 @@ DatasetOptionsPanel.BB_DATASET_OPTIONS_SHOW_CHARSET_SELECTION); if (showCharsetSelection instanceof Boolean) { if (((Boolean) showCharsetSelection).booleanValue()) { - fileLoader.addOption("charset", "CharSetComboBoxField", Charset + fileLoader.addOption(DataSource.CHARSET_KEY, "CharSetComboBoxField", Charset .defaultCharset().displayName(), true); } } Modified: core/trunk/src/org/openjump/core/apitools/IOTools.java =================================================================== --- core/trunk/src/org/openjump/core/apitools/IOTools.java 2016-11-18 12:34:50 UTC (rev 5192) +++ core/trunk/src/org/openjump/core/apitools/IOTools.java 2016-11-18 12:38:53 UTC (rev 5193) @@ -20,6 +20,7 @@ import com.vividsolutions.jump.feature.Feature; import com.vividsolutions.jump.feature.FeatureCollection; import com.vividsolutions.jump.io.*; +import com.vividsolutions.jump.io.datasource.DataSource; public class IOTools { @@ -27,8 +28,7 @@ private static String getExtension(String filename) { int len = filename.length(); - String extension = filename.substring(len - 3, len); - return extension; + return filename.substring(len - 3, len); } public static FeatureCollection load(String filename) @@ -58,7 +58,7 @@ { JMLReader rdr = new JMLReader(); DriverProperties dp = new DriverProperties(); - dp.set("File", filename); + dp.set(DataSource.FILE_KEY, filename); return rdr.read(dp); } @@ -67,7 +67,7 @@ { ShapefileReader rdr = new ShapefileReader(); DriverProperties dp = new DriverProperties(); - dp.set("File", filename); + dp.set(DataSource.FILE_KEY, filename); return rdr.read(dp); } @@ -76,9 +76,9 @@ { ShapefileReader rdr = new ShapefileReader(); DriverProperties dp = new DriverProperties(); - dp.set(ShapefileReader.FILE_PROPERTY_KEY, filename); + dp.set(DataSource.FILE_KEY, filename); if (zipFileName != null) - dp.set(ShapefileReader.COMPRESSED_FILE_PROPERTY_KEY, zipFileName); + dp.set(DataSource.COMPRESSED_KEY, zipFileName); return rdr.read(dp); } @@ -87,7 +87,7 @@ { FMEGMLReader rdr = new FMEGMLReader(); DriverProperties dp = new DriverProperties(); - dp.set("File", filename); + dp.set(DataSource.FILE_KEY, filename); return rdr.read(dp); } @@ -96,7 +96,7 @@ { WKTReader rdr = new WKTReader(); DriverProperties dp = new DriverProperties(); - dp.set("File", filename); + dp.set(DataSource.FILE_KEY, filename); FeatureCollection fc = rdr.read(dp); return fc; } @@ -121,7 +121,7 @@ { ShapefileWriter writer = new ShapefileWriter(); DriverProperties dp = new DriverProperties(); - dp.set("File", filename); + dp.set(DataSource.FILE_KEY, filename); writer.write(fc, dp); } public static void saveJMLFile(FeatureCollection fc, String filename) @@ -129,7 +129,7 @@ { JMLWriter writer = new JMLWriter(); DriverProperties dp = new DriverProperties(); - dp.set("File", filename); + dp.set(DataSource.FILE_KEY, filename); writer.write(fc, dp); } public static void print(FeatureCollection fc) Modified: core/trunk/src/org/openjump/core/ui/DatasetOptionsPanel.java =================================================================== --- core/trunk/src/org/openjump/core/ui/DatasetOptionsPanel.java 2016-11-18 12:34:50 UTC (rev 5192) +++ core/trunk/src/org/openjump/core/ui/DatasetOptionsPanel.java 2016-11-18 12:38:53 UTC (rev 5193) @@ -1,6 +1,7 @@ package org.openjump.core.ui; import com.vividsolutions.jump.I18N; +import com.vividsolutions.jump.io.datasource.DataSource; import com.vividsolutions.jump.util.Blackboard; import com.vividsolutions.jump.workbench.WorkbenchContext; import com.vividsolutions.jump.workbench.datasource.DataSourceQueryChooserDialog; @@ -86,9 +87,9 @@ if (loader instanceof DataSourceFileLayerLoader) { DataSourceFileLayerLoader fileLoader = (DataSourceFileLayerLoader)loader; if (fileLoader.getDescription().equals("ESRI Shapefile")) { - fileLoader.removeOption("charset", "CharSetComboBoxField", Charset.defaultCharset().displayName(), true); + fileLoader.removeOption(DataSource.CHARSET_KEY, "CharSetComboBoxField", Charset.defaultCharset().displayName(), true); if (charsetSelectionCheckBox.isSelected()) { - fileLoader.addOption("charset", "CharSetComboBoxField", Charset.defaultCharset().displayName(), true); + fileLoader.addOption(DataSource.CHARSET_KEY, "CharSetComboBoxField", Charset.defaultCharset().displayName(), true); } // update the DataSourceQueryChooserDialog for the current format String KEY = SaveDatasetAsPlugIn.class.getName() + " - DIALOG"; Modified: core/trunk/src/org/openjump/core/ui/plugin/file/SaveLayersWithoutDataSourcePlugIn.java =================================================================== --- core/trunk/src/org/openjump/core/ui/plugin/file/SaveLayersWithoutDataSourcePlugIn.java 2016-11-18 12:34:50 UTC (rev 5192) +++ core/trunk/src/org/openjump/core/ui/plugin/file/SaveLayersWithoutDataSourcePlugIn.java 2016-11-18 12:38:53 UTC (rev 5193) @@ -33,10 +33,7 @@ package org.openjump.core.ui.plugin.file; import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; +import java.util.*; import javax.swing.ImageIcon; import javax.swing.JFileChooser; @@ -164,9 +161,10 @@ File file = getFile(layer, dir, ext); String path = file.getAbsolutePath(); - DriverProperties dp = new DriverProperties(); - dp.set(DataSource.URI_KEY, file.toURI().toString()); - dp.set(DataSource.FILE_KEY, path); + //DriverProperties dp = new DriverProperties(); + Map<String,Object> dp = new HashMap<>(); + dp.put(DataSource.URI_KEY, file.toURI().toString()); + dp.put(DataSource.FILE_KEY, path); dataSource.setProperties(dp); DataSourceQuery dsq = new DataSourceQuery(dataSource, path, path); Modified: core/trunk/src/org/openjump/core/ui/plugin/layer/LayerPropertiesPlugIn.java =================================================================== --- core/trunk/src/org/openjump/core/ui/plugin/layer/LayerPropertiesPlugIn.java 2016-11-18 12:34:50 UTC (rev 5192) +++ core/trunk/src/org/openjump/core/ui/plugin/layer/LayerPropertiesPlugIn.java 2016-11-18 12:38:53 UTC (rev 5193) @@ -65,6 +65,7 @@ import com.vividsolutions.jump.I18N; import com.vividsolutions.jump.feature.Feature; import com.vividsolutions.jump.feature.FeatureCollectionWrapper; +import com.vividsolutions.jump.io.datasource.DataSource; import com.vividsolutions.jump.io.datasource.DataSourceQuery; import com.vividsolutions.jump.workbench.WorkbenchContext; import com.vividsolutions.jump.workbench.datastore.ConnectionDescriptor; @@ -633,12 +634,12 @@ DataSourceQuery dsq = layers[0].getDataSourceQuery(); if (dsq != null) { Map properties = dsq.getDataSource().getProperties(); - charsetName = (String) properties.get("charset"); + charsetName = (String) properties.get(DataSource.CHARSET_KEY); // if the layer do not have the charset property, set with default // charset if (charsetName == null) { charsetName = Charset.defaultCharset().displayName(); - properties.put("charset", charsetName); + properties.put(DataSource.CHARSET_KEY, charsetName); } } else { // if the layer does not come from a datasource Modified: core/trunk/src/org/openjump/core/ui/plugin/layer/NewLayerPropertiesPlugIn.java =================================================================== --- core/trunk/src/org/openjump/core/ui/plugin/layer/NewLayerPropertiesPlugIn.java 2016-11-18 12:34:50 UTC (rev 5192) +++ core/trunk/src/org/openjump/core/ui/plugin/layer/NewLayerPropertiesPlugIn.java 2016-11-18 12:38:53 UTC (rev 5193) @@ -636,12 +636,12 @@ DataSourceQuery dsq = layers[0].getDataSourceQuery(); if (dsq != null) { @SuppressWarnings("unchecked") - Map<String, String> properties = dsq.getDataSource() + Map<String,Object> properties = dsq.getDataSource() .getProperties(); - charsetName = (String) properties.get("charset"); + charsetName = (String) properties.get(DataSource.CHARSET_KEY); if (charsetName == null) { charsetName = Charset.defaultCharset().displayName(); - properties.put("charset", charsetName); + properties.put(DataSource.CHARSET_KEY, charsetName); } } else { charsetName = Charset.defaultCharset().displayName(); Modified: core/trunk/src/org/openjump/core/ui/plugin/mousemenu/SaveDatasetsPlugIn.java =================================================================== --- core/trunk/src/org/openjump/core/ui/plugin/mousemenu/SaveDatasetsPlugIn.java 2016-11-18 12:34:50 UTC (rev 5192) +++ core/trunk/src/org/openjump/core/ui/plugin/mousemenu/SaveDatasetsPlugIn.java 2016-11-18 12:38:53 UTC (rev 5193) @@ -616,9 +616,9 @@ newLayers = splitLayer(context, layer); // charset fix [Matthias Scholz 12. Feb 2011] - Object charsetName = dsq.getDataSource().getProperties().get("charset"); + Object charsetName = dsq.getDataSource().getProperties().get(DataSource.CHARSET_KEY); if (charsetName != null) - dp.set("charset", charsetName.toString()); + dp.set(DataSource.CHARSET_KEY, charsetName.toString()); (new ShapefileWriter()).write(layer.getFeatureCollectionWrapper(), dp); ------------------------------------------------------------------------------ _______________________________________________ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel