[Xulu-commits] r123 - trunk/src/edu/bonn/xulu/plugin/io/misc
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Thu May 24 10:45:20 CEST 2012
Author: mojays
Date: 2012-05-24 10:45:19 +0200 (Thu, 24 May 2012)
New Revision: 123
Modified:
trunk/src/edu/bonn/xulu/plugin/io/misc/DynamicXuluObjectFactory_BasicStructure.java
Log:
DynamicXuluObjectFactory_BasicStructure:
Import: Wird als Property-Type nur der "SimpleClassName" angegeben, wird das Package "de.schmitzm.data.property" automatisch gesetzt
Export: F?\195?\188r Properties aus dem Standard-Package "de.schmitzm.data.property" wird nur der SimpleClassName als PropertyType abgespeichert
Modified: trunk/src/edu/bonn/xulu/plugin/io/misc/DynamicXuluObjectFactory_BasicStructure.java
===================================================================
--- trunk/src/edu/bonn/xulu/plugin/io/misc/DynamicXuluObjectFactory_BasicStructure.java 2012-05-05 20:49:36 UTC (rev 122)
+++ trunk/src/edu/bonn/xulu/plugin/io/misc/DynamicXuluObjectFactory_BasicStructure.java 2012-05-24 08:45:19 UTC (rev 123)
@@ -54,6 +54,11 @@
* @version 1.0
*/
public class DynamicXuluObjectFactory_BasicStructure extends AbstractFactory implements ImportFactory, ExportFactory {
+ /** Default package property type classes are used from, if no fully qualified
+ * type name is specified. */
+ public static final String DEFAULT_PROPTYPE_PACKAGE = ScalarProperty.class.getPackage().getName();
+
+
/** Logger fuer Debug-Ausgaben und Warnings. */
protected final Logger LOGGER = LangUtil.createLogger(this);
@@ -163,7 +168,7 @@
// Zeile als Property-Parameter interpretieren
if ( l.getTagName().equalsIgnoreCase(TAG_PROPTYPE) ) {
// Typ der Property
- propClass = Class.forName(l.getFirstValue());
+ propClass = loadPropertyType(l.getFirstValue());
// nur Skalar-, List- oder Matrix-Property zulaessig
if ( !ScalarProperty.class.equals(propClass) &&
!ListProperty.class.equals(propClass) &&
@@ -204,6 +209,20 @@
return xuluObject;
}
+ /**
+ * Loads the class for a property type. If no fully qualified class name is given
+ * the method tries to load the class from {@link #DEFAULT_PROPTYPE_PACKAGE}.
+ * @param typeStr property type name
+ */
+ private static Class loadPropertyType(String typeStr) throws ClassNotFoundException {
+ try {
+ return Class.forName(typeStr);
+ } catch (ClassNotFoundException err) {
+ // Class not found -> try to add default package to type name
+ typeStr = DEFAULT_PROPTYPE_PACKAGE + "." + typeStr;
+ return Class.forName(typeStr);
+ }
+ }
private void initPropertyVariables() {
propName = null;
@@ -433,7 +452,10 @@
out.write("["+prop.getName().trim()+"]\n");
//**** Property-Typ ****
- out.write(TAG_PROPTYPE+" = "+prop.getClass().getName());
+ String propTypeStr = prop.getClass().getName();
+ if ( DEFAULT_PROPTYPE_PACKAGE.equals(prop.getClass().getPackage().getName()) )
+ propTypeStr = prop.getClass().getSimpleName();
+ out.write(TAG_PROPTYPE+" = "+propTypeStr);
// Parameter hinzufuegen
if ( prop instanceof MatrixProperty)
for (int dimSize : ((MatrixProperty)prop).getSize())
More information about the Xulu-commits
mailing list