X4O: Formated x4o-driver module java classes
This commit is contained in:
parent
ed096a1427
commit
0b75d4e283
108 changed files with 2420 additions and 2248 deletions
|
|
@ -46,116 +46,109 @@ public abstract class X4ODriver<T> {
|
||||||
|
|
||||||
/** Defines the default version if none is defined. */
|
/** Defines the default version if none is defined. */
|
||||||
public final static String DEFAULT_LANGUAGE_VERSION = "1.0";
|
public final static String DEFAULT_LANGUAGE_VERSION = "1.0";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* marker constructor.
|
* marker constructor.
|
||||||
*/
|
*/
|
||||||
public X4ODriver(/*X4ODriverManager.ConstructorMarker marker*/) {
|
public X4ODriver(/* X4ODriverManager.ConstructorMarker marker */) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the langauge name of this driver.
|
* @return Returns the langauge name of this driver.
|
||||||
*/
|
*/
|
||||||
abstract public String getLanguageName();
|
abstract public String getLanguageName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the supported language versions for this driver.
|
* @return Returns the supported language versions for this driver.
|
||||||
*/
|
*/
|
||||||
abstract public String[] getLanguageVersions();
|
abstract public String[] getLanguageVersions();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// =============== build methods to override
|
// =============== build methods to override
|
||||||
|
|
||||||
protected X4OLanguage buildLanguage(String version) {
|
protected X4OLanguage buildLanguage(String version) {
|
||||||
return X4ODriverManager.getDefaultBuildLanguage(this, version);
|
return X4ODriverManager.getDefaultBuildLanguage(this, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected X4OPhaseManager buildPhaseManager() {
|
protected X4OPhaseManager buildPhaseManager() {
|
||||||
return X4ODriverManager.getDefaultBuildPhaseManager();
|
return X4ODriverManager.getDefaultBuildPhaseManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected X4OLanguageConfiguration buildLanguageConfiguration() {
|
protected X4OLanguageConfiguration buildLanguageConfiguration() {
|
||||||
return X4ODriverManager.getDefaultBuildLanguageConfiguration();
|
return X4ODriverManager.getDefaultBuildLanguageConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// =============== Reader
|
// =============== Reader
|
||||||
|
|
||||||
public X4OReader<T> createReader() {
|
public X4OReader<T> createReader() {
|
||||||
return createReaderSession();
|
return createReaderSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
public X4OReader<T> createReader(String version) {
|
public X4OReader<T> createReader(String version) {
|
||||||
return createReaderSession(version);
|
return createReaderSession(version);
|
||||||
}
|
}
|
||||||
|
|
||||||
public X4OReaderSession<T> createReaderSession() {
|
public X4OReaderSession<T> createReaderSession() {
|
||||||
return createReaderSession(getLanguageVersionDefault());
|
return createReaderSession(getLanguageVersionDefault());
|
||||||
}
|
}
|
||||||
|
|
||||||
public X4OReaderSession<T> createReaderSession(String version) {
|
public X4OReaderSession<T> createReaderSession(String version) {
|
||||||
return new DefaultX4OReader<T>(createLanguage(version));
|
return new DefaultX4OReader<T>(createLanguage(version));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// =============== Writer
|
// =============== Writer
|
||||||
|
|
||||||
public X4OWriter<T> createWriter() {
|
public X4OWriter<T> createWriter() {
|
||||||
return createWriterSession();
|
return createWriterSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
public X4OWriter<T> createWriter(String version) {
|
public X4OWriter<T> createWriter(String version) {
|
||||||
return createWriterSession(version);
|
return createWriterSession(version);
|
||||||
}
|
}
|
||||||
|
|
||||||
public X4OWriterSession<T> createWriterSession() {
|
public X4OWriterSession<T> createWriterSession() {
|
||||||
return createWriterSession(getLanguageVersionDefault());
|
return createWriterSession(getLanguageVersionDefault());
|
||||||
}
|
}
|
||||||
|
|
||||||
public X4OWriterSession<T> createWriterSession(String version) {
|
public X4OWriterSession<T> createWriterSession(String version) {
|
||||||
return new DefaultX4OWriter<T>(createLanguage(version));
|
return new DefaultX4OWriter<T>(createLanguage(version));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// =============== Language
|
// =============== Language
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the default language which is the latest version.
|
* Returns the default language which is the latest version.
|
||||||
* @return The default language version.
|
*
|
||||||
|
* @return The default language version.
|
||||||
*/
|
*/
|
||||||
final public String getLanguageVersionDefault() {
|
final public String getLanguageVersionDefault() {
|
||||||
return X4ODriverManager.getDefaultLanguageVersion(getLanguageVersions());
|
return X4ODriverManager.getDefaultLanguageVersion(getLanguageVersions());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the X4OLanguage for the specified version.
|
* Creates the X4OLanguage for the specified version.
|
||||||
* @param version The language version to create.
|
*
|
||||||
* @return The created X4OLanguage.
|
* @param version The language version to create.
|
||||||
|
* @return The created X4OLanguage.
|
||||||
*/
|
*/
|
||||||
final public X4OLanguage createLanguage(String version) {
|
final public X4OLanguage createLanguage(String version) {
|
||||||
return buildLanguage(version);
|
return buildLanguage(version);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the X4OLanguage for the default version.
|
* Creates the X4OLanguage for the default version.
|
||||||
* @return The created X4OLanguage.
|
*
|
||||||
|
* @return The created X4OLanguage.
|
||||||
*/
|
*/
|
||||||
final public X4OLanguage createLanguage() {
|
final public X4OLanguage createLanguage() {
|
||||||
return buildLanguage(getLanguageVersionDefault());
|
return buildLanguage(getLanguageVersionDefault());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// =============== Language Tasks
|
// =============== Language Tasks
|
||||||
|
|
||||||
final public X4OLanguageTask getLanguageTask(String taskId) {
|
final public X4OLanguageTask getLanguageTask(String taskId) {
|
||||||
return X4ODriverManager.getX4OLanguageTask(taskId);
|
return X4ODriverManager.getX4OLanguageTask(taskId);
|
||||||
}
|
}
|
||||||
|
|
||||||
final public List<X4OLanguageTask> getLanguageTasks() {
|
final public List<X4OLanguageTask> getLanguageTasks() {
|
||||||
return X4ODriverManager.getX4OLanguageTasks();
|
return X4ODriverManager.getX4OLanguageTasks();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,33 +34,35 @@ import java.util.Locale;
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
abstract public class AbstractObjectConverter implements ObjectConverter {
|
abstract public class AbstractObjectConverter implements ObjectConverter {
|
||||||
|
|
||||||
protected List<ObjectConverter> converters = new ArrayList<ObjectConverter>(5);
|
protected List<ObjectConverter> converters = new ArrayList<ObjectConverter>(5);
|
||||||
|
|
||||||
abstract public Object convertAfterTo(Object obj, Locale locale) throws ObjectConverterException;
|
abstract public Object convertAfterTo(Object obj, Locale locale) throws ObjectConverterException;
|
||||||
|
|
||||||
abstract public Object convertAfterBack(Object obj, Locale locale) throws ObjectConverterException;
|
abstract public Object convertAfterBack(Object obj, Locale locale) throws ObjectConverterException;
|
||||||
|
|
||||||
abstract public ObjectConverter clone() throws CloneNotSupportedException;
|
abstract public ObjectConverter clone() throws CloneNotSupportedException;
|
||||||
|
|
||||||
protected List<ObjectConverter> cloneConverters() throws CloneNotSupportedException {
|
protected List<ObjectConverter> cloneConverters() throws CloneNotSupportedException {
|
||||||
List<ObjectConverter> result = new ArrayList<ObjectConverter>(converters.size());
|
List<ObjectConverter> result = new ArrayList<ObjectConverter>(converters.size());
|
||||||
for (ObjectConverter converter:converters) {
|
for (ObjectConverter converter : converters) {
|
||||||
result.add(converter.clone());
|
result.add(converter.clone());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.conv.ObjectConverter#convertTo(java.lang.Object, java.util.Locale)
|
* @see org.x4o.xml.conv.ObjectConverter#convertTo(java.lang.Object, java.util.Locale)
|
||||||
*/
|
*/
|
||||||
public Object convertTo(Object obj, Locale locale) throws ObjectConverterException {
|
public Object convertTo(Object obj, Locale locale) throws ObjectConverterException {
|
||||||
if (converters.isEmpty()) {
|
if (converters.isEmpty()) {
|
||||||
return convertAfterTo(obj,locale);
|
return convertAfterTo(obj, locale);
|
||||||
}
|
}
|
||||||
Object result = null;
|
Object result = null;
|
||||||
for (ObjectConverter conv:converters) {
|
for (ObjectConverter conv : converters) {
|
||||||
result = conv.convertTo(obj, locale);
|
result = conv.convertTo(obj, locale);
|
||||||
}
|
}
|
||||||
result = convertAfterTo(obj,locale);
|
result = convertAfterTo(obj, locale);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -69,13 +71,13 @@ abstract public class AbstractObjectConverter implements ObjectConverter {
|
||||||
*/
|
*/
|
||||||
public Object convertBack(Object obj, Locale locale) throws ObjectConverterException {
|
public Object convertBack(Object obj, Locale locale) throws ObjectConverterException {
|
||||||
if (converters.isEmpty()) {
|
if (converters.isEmpty()) {
|
||||||
return convertAfterBack(obj,locale);
|
return convertAfterBack(obj, locale);
|
||||||
}
|
}
|
||||||
Object result = null;
|
Object result = null;
|
||||||
for (ObjectConverter conv:converters) {
|
for (ObjectConverter conv : converters) {
|
||||||
result = conv.convertBack(obj, locale);
|
result = conv.convertBack(obj, locale);
|
||||||
}
|
}
|
||||||
result = convertAfterBack(obj,locale);
|
result = convertAfterBack(obj, locale);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,16 +42,17 @@ abstract public class AbstractStringObjectConverter extends AbstractObjectConver
|
||||||
|
|
||||||
public Object convertAfterTo(Object obj, Locale locale) throws ObjectConverterException {
|
public Object convertAfterTo(Object obj, Locale locale) throws ObjectConverterException {
|
||||||
if (obj instanceof String) {
|
if (obj instanceof String) {
|
||||||
return convertStringTo((String)obj,locale);
|
return convertStringTo((String) obj, locale);
|
||||||
} else {
|
} else {
|
||||||
return convertStringTo(obj.toString(),locale);
|
return convertStringTo(obj.toString(), locale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object convertAfterBack(Object obj, Locale locale) throws ObjectConverterException {
|
public Object convertAfterBack(Object obj, Locale locale) throws ObjectConverterException {
|
||||||
return convertStringBack(obj,locale);
|
return convertStringBack(obj, locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract public Object convertStringTo(String str, Locale locale) throws ObjectConverterException;
|
abstract public Object convertStringTo(String str, Locale locale) throws ObjectConverterException;
|
||||||
abstract public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException;
|
|
||||||
|
abstract public String convertStringBack(Object obj, Locale locale) throws ObjectConverterException;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,19 +43,20 @@ import org.x4o.xml.conv.text.URLConverter;
|
||||||
* @version 1.0 Jan 20, 2012
|
* @version 1.0 Jan 20, 2012
|
||||||
*/
|
*/
|
||||||
public class DefaultObjectConverterProvider implements ObjectConverterProvider {
|
public class DefaultObjectConverterProvider implements ObjectConverterProvider {
|
||||||
|
|
||||||
private Map<Class<?>,ObjectConverter> converters = null;
|
private Map<Class<?>, ObjectConverter> converters = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new DefaultObjectConverterProvider.
|
* Create new DefaultObjectConverterProvider.
|
||||||
*/
|
*/
|
||||||
public DefaultObjectConverterProvider() {
|
public DefaultObjectConverterProvider() {
|
||||||
converters = new HashMap<Class<?>,ObjectConverter>(20);
|
converters = new HashMap<Class<?>, ObjectConverter>(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new DefaultObjectConverterProvider.
|
* Create new DefaultObjectConverterProvider.
|
||||||
* @param addDefaults When true do the addDefaults().
|
*
|
||||||
|
* @param addDefaults When true do the addDefaults().
|
||||||
*/
|
*/
|
||||||
public DefaultObjectConverterProvider(boolean addDefaults) {
|
public DefaultObjectConverterProvider(boolean addDefaults) {
|
||||||
this();
|
this();
|
||||||
|
|
@ -63,7 +64,7 @@ public class DefaultObjectConverterProvider implements ObjectConverterProvider {
|
||||||
addDefaults();
|
addDefaults();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the default converters.
|
* Adds the default converters.
|
||||||
*/
|
*/
|
||||||
|
|
@ -78,9 +79,9 @@ public class DefaultObjectConverterProvider implements ObjectConverterProvider {
|
||||||
addObjectConverter(new URLConverter());
|
addObjectConverter(new URLConverter());
|
||||||
addObjectConverter(new ClassConverter());
|
addObjectConverter(new ClassConverter());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param converter The converter to add.
|
* @param converter The converter to add.
|
||||||
*/
|
*/
|
||||||
public void addObjectConverter(ObjectConverter converter) {
|
public void addObjectConverter(ObjectConverter converter) {
|
||||||
converters.put(converter.getObjectClassTo(), converter);
|
converters.put(converter.getObjectClassTo(), converter);
|
||||||
|
|
@ -89,14 +90,14 @@ public class DefaultObjectConverterProvider implements ObjectConverterProvider {
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.conv.ObjectConverterProvider#getObjectConverterForClass(java.lang.Class)
|
* @see org.x4o.xml.conv.ObjectConverterProvider#getObjectConverterForClass(java.lang.Class)
|
||||||
* @param clazz The Class to search an ObjectConverter for.
|
* @param clazz The Class to search an ObjectConverter for.
|
||||||
* @return The ObjectConverter or null for the class.
|
* @return The ObjectConverter or null for the class.
|
||||||
*/
|
*/
|
||||||
public ObjectConverter getObjectConverterForClass(Class<?> clazz) {
|
public ObjectConverter getObjectConverterForClass(Class<?> clazz) {
|
||||||
return converters.get(clazz);
|
return converters.get(clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns all ObjectConverted stored in this class.
|
* @return Returns all ObjectConverted stored in this class.
|
||||||
*/
|
*/
|
||||||
protected Collection<ObjectConverter> getObjectConverters() {
|
protected Collection<ObjectConverter> getObjectConverters() {
|
||||||
return converters.values();
|
return converters.values();
|
||||||
|
|
|
||||||
|
|
@ -32,56 +32,58 @@ import java.util.Locale;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Aug 28, 2008
|
* @version 1.0 Aug 28, 2008
|
||||||
*/
|
*/
|
||||||
public interface ObjectConverter extends Cloneable,Serializable {
|
public interface ObjectConverter extends Cloneable, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the class which we can convert to.
|
* @return Returns the class which we can convert to.
|
||||||
*/
|
*/
|
||||||
Class<?> getObjectClassTo();
|
Class<?> getObjectClassTo();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the class which we can convert from.
|
* @return Returns the class which we can convert from.
|
||||||
*/
|
*/
|
||||||
Class<?> getObjectClassBack();
|
Class<?> getObjectClassBack();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert to the object.
|
* Convert to the object.
|
||||||
* @param obj The object to convert.
|
*
|
||||||
* @param locale The Object convert locale if needed.
|
* @param obj The object to convert.
|
||||||
|
* @param locale The Object convert locale if needed.
|
||||||
* @return Returns the converted object.
|
* @return Returns the converted object.
|
||||||
* @throws ObjectConverterException When the conversion failes.
|
* @throws ObjectConverterException When the conversion failes.
|
||||||
*/
|
*/
|
||||||
Object convertTo(Object obj,Locale locale) throws ObjectConverterException;
|
Object convertTo(Object obj, Locale locale) throws ObjectConverterException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert the object back.
|
* Convert the object back.
|
||||||
* @param obj The object to convert.
|
*
|
||||||
* @param locale The Object convert locale if needed.
|
* @param obj The object to convert.
|
||||||
|
* @param locale The Object convert locale if needed.
|
||||||
* @return Returns the converted object.
|
* @return Returns the converted object.
|
||||||
* @throws ObjectConverterException When the conversion failes.
|
* @throws ObjectConverterException When the conversion failes.
|
||||||
*/
|
*/
|
||||||
Object convertBack(Object obj,Locale locale) throws ObjectConverterException;
|
Object convertBack(Object obj, Locale locale) throws ObjectConverterException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns list of child converters.
|
* @return Returns list of child converters.
|
||||||
*/
|
*/
|
||||||
List<ObjectConverter> getObjectConverters();
|
List<ObjectConverter> getObjectConverters();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param converter Adds an child converter.
|
* @param converter Adds an child converter.
|
||||||
*/
|
*/
|
||||||
void addObjectConverter(ObjectConverter converter);
|
void addObjectConverter(ObjectConverter converter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param converter Removes this child converter.
|
* @param converter Removes this child converter.
|
||||||
*/
|
*/
|
||||||
void removeObjectConverter(ObjectConverter converter);
|
void removeObjectConverter(ObjectConverter converter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Force impl to have public clone method.
|
* Force impl to have public clone method.
|
||||||
*
|
*
|
||||||
* @return An cloned ObjectConverter.
|
* @return An cloned ObjectConverter.
|
||||||
* @throws CloneNotSupportedException If thrown when cloning is not supported.
|
* @throws CloneNotSupportedException If thrown when cloning is not supported.
|
||||||
*/
|
*/
|
||||||
ObjectConverter clone() throws CloneNotSupportedException;
|
ObjectConverter clone() throws CloneNotSupportedException;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,33 +29,35 @@ package org.x4o.xml.conv;
|
||||||
* @version 1.0 Jan 20, 2012
|
* @version 1.0 Jan 20, 2012
|
||||||
*/
|
*/
|
||||||
public class ObjectConverterException extends Exception {
|
public class ObjectConverterException extends Exception {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private final ObjectConverter converter;
|
private final ObjectConverter converter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an ObjectConverterException.
|
* Creates an ObjectConverterException.
|
||||||
* @param converter The converter which has the exception.
|
*
|
||||||
* @param message The exception message.
|
* @param converter The converter which has the exception.
|
||||||
|
* @param message The exception message.
|
||||||
*/
|
*/
|
||||||
public ObjectConverterException(ObjectConverter converter,String message) {
|
public ObjectConverterException(ObjectConverter converter, String message) {
|
||||||
super(message);
|
super(message);
|
||||||
this.converter=converter;
|
this.converter = converter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an ObjectConverterException.
|
* Creates an ObjectConverterException.
|
||||||
* @param converter The converter which has the exception.
|
*
|
||||||
* @param message The exception message.
|
* @param converter The converter which has the exception.
|
||||||
* @param exception The parent exception.
|
* @param message The exception message.
|
||||||
|
* @param exception The parent exception.
|
||||||
*/
|
*/
|
||||||
public ObjectConverterException(ObjectConverter converter,String message,Exception exception) {
|
public ObjectConverterException(ObjectConverter converter, String message, Exception exception) {
|
||||||
super(message,exception);
|
super(message, exception);
|
||||||
this.converter=converter;
|
this.converter = converter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the ObjectConverter of this exception.
|
* @return Returns the ObjectConverter of this exception.
|
||||||
*/
|
*/
|
||||||
public ObjectConverter getObjectConverter() {
|
public ObjectConverter getObjectConverter() {
|
||||||
return converter;
|
return converter;
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,12 @@ package org.x4o.xml.conv;
|
||||||
* @version 1.0 Jan 20, 2012
|
* @version 1.0 Jan 20, 2012
|
||||||
*/
|
*/
|
||||||
public interface ObjectConverterProvider {
|
public interface ObjectConverterProvider {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides an ObjectConvert based on the converted class result.
|
* Provides an ObjectConvert based on the converted class result.
|
||||||
* @param clazz The result class we want.
|
*
|
||||||
* @return The ObjectConverter which can convert for us.
|
* @param clazz The result class we want.
|
||||||
|
* @return The ObjectConverter which can convert for us.
|
||||||
*/
|
*/
|
||||||
ObjectConverter getObjectConverterForClass(Class<?> clazz);
|
ObjectConverter getObjectConverterForClass(Class<?> clazz);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.conv.text;
|
package org.x4o.xml.conv.text;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
|
@ -35,67 +35,66 @@ import org.x4o.xml.lang.X4OLanguageClassLoader;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Aug 31, 2007
|
* @version 1.0 Aug 31, 2007
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"rawtypes","unchecked"})
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
public class EnumConverter extends AbstractStringObjectConverter {
|
public class EnumConverter extends AbstractStringObjectConverter {
|
||||||
|
|
||||||
private static final long serialVersionUID = 8860785472427794548L;
|
private static final long serialVersionUID = 8860785472427794548L;
|
||||||
|
|
||||||
|
|
||||||
private String enumClass = null;
|
private String enumClass = null;
|
||||||
|
|
||||||
|
|
||||||
private Class enumObjectClass = null;
|
private Class enumObjectClass = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the convert to class.
|
* Returns the convert to class.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
|
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
|
||||||
* @return The class to convert to.
|
* @return The class to convert to.
|
||||||
*/
|
*/
|
||||||
public Class<?> getObjectClassTo() {
|
public Class<?> getObjectClassTo() {
|
||||||
return Enum.class;
|
return Enum.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts string into object.
|
* Converts string into object.
|
||||||
*
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
|
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
|
||||||
* @param str The string to convert to object.
|
* @param str The string to convert to object.
|
||||||
* @param locale The locale to convert the string from.
|
* @param locale The locale to convert the string from.
|
||||||
* @return The object converted from the string.
|
* @return The object converted from the string.
|
||||||
* @throws ObjectConverterException When conversion fails.
|
* @throws ObjectConverterException When conversion fails.
|
||||||
*/
|
*/
|
||||||
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
||||||
if (getEnumClass()==null) {
|
if (getEnumClass() == null) {
|
||||||
throw new ObjectConverterException(this,"enumClass String attribute is not set.");
|
throw new ObjectConverterException(this, "enumClass String attribute is not set.");
|
||||||
}
|
}
|
||||||
//if (value instanceof Enum) {
|
// if (value instanceof Enum) {
|
||||||
// return value;
|
// return value;
|
||||||
//}
|
// }
|
||||||
String v = str; //value.toString();
|
String v = str; // value.toString();
|
||||||
try {
|
try {
|
||||||
if (enumObjectClass==null) {
|
if (enumObjectClass == null) {
|
||||||
enumObjectClass = (Class<?>)X4OLanguageClassLoader.loadClass(getEnumClass());
|
enumObjectClass = (Class<?>) X4OLanguageClassLoader.loadClass(getEnumClass());
|
||||||
}
|
}
|
||||||
if (enumObjectClass==null) {
|
if (enumObjectClass == null) {
|
||||||
throw new ObjectConverterException(this,"Could not load enumClass");
|
throw new ObjectConverterException(this, "Could not load enumClass");
|
||||||
}
|
}
|
||||||
return Enum.valueOf(enumObjectClass, v);
|
return Enum.valueOf(enumObjectClass, v);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ObjectConverterException(this,e.getMessage(),e);
|
throw new ObjectConverterException(this, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts object into string.
|
* Converts object into string.
|
||||||
*
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
|
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
|
||||||
* @param obj The object to convert to string.
|
* @param obj The object to convert to string.
|
||||||
* @param locale The locale to convert the object from.
|
* @param locale The locale to convert the object from.
|
||||||
* @return The string converted from the object.
|
* @return The string converted from the object.
|
||||||
* @throws ObjectConverterException When conversion fails.
|
* @throws ObjectConverterException When conversion fails.
|
||||||
*/
|
*/
|
||||||
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
|
public String convertStringBack(Object obj, Locale locale) throws ObjectConverterException {
|
||||||
return ((Enum<?>)obj).name();
|
return ((Enum<?>) obj).name();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -105,16 +104,16 @@ public class EnumConverter extends AbstractStringObjectConverter {
|
||||||
return enumClass;
|
return enumClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param enumClass the enumClass to set
|
* @param enumClass the enumClass to set
|
||||||
*/
|
*/
|
||||||
public void setEnumClass(String enumClass) {
|
public void setEnumClass(String enumClass) {
|
||||||
this.enumClass = enumClass;
|
this.enumClass = enumClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clone this ObjectConverter.
|
* Clone this ObjectConverter.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
|
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
|
||||||
* @return The cloned ObjectConverter.
|
* @return The cloned ObjectConverter.
|
||||||
* @throws CloneNotSupportedException When cloning fails.
|
* @throws CloneNotSupportedException When cloning fails.
|
||||||
|
|
@ -122,8 +121,8 @@ public class EnumConverter extends AbstractStringObjectConverter {
|
||||||
@Override
|
@Override
|
||||||
public ObjectConverter clone() throws CloneNotSupportedException {
|
public ObjectConverter clone() throws CloneNotSupportedException {
|
||||||
EnumConverter result = new EnumConverter();
|
EnumConverter result = new EnumConverter();
|
||||||
result.converters=cloneConverters();
|
result.converters = cloneConverters();
|
||||||
result.enumClass=enumClass;
|
result.enumClass = enumClass;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,18 +40,19 @@ public class FloatConverter extends AbstractStringObjectConverter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the convert to class.
|
* Returns the convert to class.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
|
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
|
||||||
* @return The class to convert to.
|
* @return The class to convert to.
|
||||||
*/
|
*/
|
||||||
public Class<?> getObjectClassTo() {
|
public Class<?> getObjectClassTo() {
|
||||||
return Float.class;
|
return Float.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts string into object.
|
* Converts string into object.
|
||||||
*
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
|
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
|
||||||
* @param str The string to convert to object.
|
* @param str The string to convert to object.
|
||||||
* @param locale The locale to convert the string from.
|
* @param locale The locale to convert the string from.
|
||||||
* @return The object converted from the string.
|
* @return The object converted from the string.
|
||||||
* @throws ObjectConverterException When conversion fails.
|
* @throws ObjectConverterException When conversion fails.
|
||||||
|
|
@ -59,22 +60,23 @@ public class FloatConverter extends AbstractStringObjectConverter {
|
||||||
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
||||||
return Float.valueOf(str);
|
return Float.valueOf(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts object into string.
|
* Converts object into string.
|
||||||
*
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
|
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
|
||||||
* @param obj The object to convert to string.
|
* @param obj The object to convert to string.
|
||||||
* @param locale The locale to convert the object from.
|
* @param locale The locale to convert the object from.
|
||||||
* @return The string converted from the object.
|
* @return The string converted from the object.
|
||||||
* @throws ObjectConverterException When conversion fails.
|
* @throws ObjectConverterException When conversion fails.
|
||||||
*/
|
*/
|
||||||
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
|
public String convertStringBack(Object obj, Locale locale) throws ObjectConverterException {
|
||||||
return ((Float)obj).toString();
|
return ((Float) obj).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clone this ObjectConverter.
|
* Clone this ObjectConverter.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
|
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
|
||||||
* @return The cloned ObjectConverter.
|
* @return The cloned ObjectConverter.
|
||||||
* @throws CloneNotSupportedException When cloning fails.
|
* @throws CloneNotSupportedException When cloning fails.
|
||||||
|
|
@ -82,7 +84,7 @@ public class FloatConverter extends AbstractStringObjectConverter {
|
||||||
@Override
|
@Override
|
||||||
public ObjectConverter clone() throws CloneNotSupportedException {
|
public ObjectConverter clone() throws CloneNotSupportedException {
|
||||||
FloatConverter result = new FloatConverter();
|
FloatConverter result = new FloatConverter();
|
||||||
result.converters=cloneConverters();
|
result.converters = cloneConverters();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,18 +40,19 @@ public class IntegerConverter extends AbstractStringObjectConverter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the convert to class.
|
* Returns the convert to class.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
|
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
|
||||||
* @return The class to convert to.
|
* @return The class to convert to.
|
||||||
*/
|
*/
|
||||||
public Class<?> getObjectClassTo() {
|
public Class<?> getObjectClassTo() {
|
||||||
return Integer.class;
|
return Integer.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts string into object.
|
* Converts string into object.
|
||||||
*
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
|
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
|
||||||
* @param str The string to convert to object.
|
* @param str The string to convert to object.
|
||||||
* @param locale The locale to convert the string from.
|
* @param locale The locale to convert the string from.
|
||||||
* @return The object converted from the string.
|
* @return The object converted from the string.
|
||||||
* @throws ObjectConverterException When conversion fails.
|
* @throws ObjectConverterException When conversion fails.
|
||||||
|
|
@ -59,22 +60,23 @@ public class IntegerConverter extends AbstractStringObjectConverter {
|
||||||
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
||||||
return Integer.valueOf(str);
|
return Integer.valueOf(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts object into string.
|
* Converts object into string.
|
||||||
*
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
|
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
|
||||||
* @param obj The object to convert to string.
|
* @param obj The object to convert to string.
|
||||||
* @param locale The locale to convert the object from.
|
* @param locale The locale to convert the object from.
|
||||||
* @return The string converted from the object.
|
* @return The string converted from the object.
|
||||||
* @throws ObjectConverterException When conversion fails.
|
* @throws ObjectConverterException When conversion fails.
|
||||||
*/
|
*/
|
||||||
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
|
public String convertStringBack(Object obj, Locale locale) throws ObjectConverterException {
|
||||||
return ((Integer)obj).toString();
|
return ((Integer) obj).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clone this ObjectConverter.
|
* Clone this ObjectConverter.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
|
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
|
||||||
* @return The cloned ObjectConverter.
|
* @return The cloned ObjectConverter.
|
||||||
* @throws CloneNotSupportedException When cloning fails.
|
* @throws CloneNotSupportedException When cloning fails.
|
||||||
|
|
@ -82,7 +84,7 @@ public class IntegerConverter extends AbstractStringObjectConverter {
|
||||||
@Override
|
@Override
|
||||||
public ObjectConverter clone() throws CloneNotSupportedException {
|
public ObjectConverter clone() throws CloneNotSupportedException {
|
||||||
IntegerConverter result = new IntegerConverter();
|
IntegerConverter result = new IntegerConverter();
|
||||||
result.converters=cloneConverters();
|
result.converters = cloneConverters();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,18 +40,19 @@ public class LongConverter extends AbstractStringObjectConverter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the convert to class.
|
* Returns the convert to class.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
|
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
|
||||||
* @return The class to convert to.
|
* @return The class to convert to.
|
||||||
*/
|
*/
|
||||||
public Class<?> getObjectClassTo() {
|
public Class<?> getObjectClassTo() {
|
||||||
return Long.class;
|
return Long.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts string into object.
|
* Converts string into object.
|
||||||
*
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
|
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
|
||||||
* @param str The string to convert to object.
|
* @param str The string to convert to object.
|
||||||
* @param locale The locale to convert the string from.
|
* @param locale The locale to convert the string from.
|
||||||
* @return The object converted from the string.
|
* @return The object converted from the string.
|
||||||
* @throws ObjectConverterException When conversion fails.
|
* @throws ObjectConverterException When conversion fails.
|
||||||
|
|
@ -59,22 +60,23 @@ public class LongConverter extends AbstractStringObjectConverter {
|
||||||
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
||||||
return Long.valueOf(str);
|
return Long.valueOf(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts object into string.
|
* Converts object into string.
|
||||||
*
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
|
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
|
||||||
* @param obj The object to convert to string.
|
* @param obj The object to convert to string.
|
||||||
* @param locale The locale to convert the object from.
|
* @param locale The locale to convert the object from.
|
||||||
* @return The string converted from the object.
|
* @return The string converted from the object.
|
||||||
* @throws ObjectConverterException When conversion fails.
|
* @throws ObjectConverterException When conversion fails.
|
||||||
*/
|
*/
|
||||||
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
|
public String convertStringBack(Object obj, Locale locale) throws ObjectConverterException {
|
||||||
return ((Long)obj).toString();
|
return ((Long) obj).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clone this ObjectConverter.
|
* Clone this ObjectConverter.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
|
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
|
||||||
* @return The cloned ObjectConverter.
|
* @return The cloned ObjectConverter.
|
||||||
* @throws CloneNotSupportedException When cloning fails.
|
* @throws CloneNotSupportedException When cloning fails.
|
||||||
|
|
@ -82,7 +84,7 @@ public class LongConverter extends AbstractStringObjectConverter {
|
||||||
@Override
|
@Override
|
||||||
public ObjectConverter clone() throws CloneNotSupportedException {
|
public ObjectConverter clone() throws CloneNotSupportedException {
|
||||||
LongConverter result = new LongConverter();
|
LongConverter result = new LongConverter();
|
||||||
result.converters=cloneConverters();
|
result.converters = cloneConverters();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,76 +49,77 @@ public class StringSplitConverter extends AbstractStringObjectConverter {
|
||||||
private String singleToMethod = null;
|
private String singleToMethod = null;
|
||||||
private Boolean useNativeType = null;
|
private Boolean useNativeType = null;
|
||||||
private List<StringSplitConverterStep> stringSplitConverterSteps = null;
|
private List<StringSplitConverterStep> stringSplitConverterSteps = null;
|
||||||
|
|
||||||
public StringSplitConverter() {
|
public StringSplitConverter() {
|
||||||
stringSplitConverterSteps = new ArrayList<StringSplitConverterStep>(10);
|
stringSplitConverterSteps = new ArrayList<StringSplitConverterStep>(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the convert to class.
|
* Returns the convert to class.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
|
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
|
||||||
* @return The class to convert to.
|
* @return The class to convert to.
|
||||||
*/
|
*/
|
||||||
public Class<?> getObjectClassTo() {
|
public Class<?> getObjectClassTo() {
|
||||||
return classTo;
|
return classTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts string into object.
|
* Converts string into object.
|
||||||
*
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
|
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
|
||||||
* @param str The string to convert to object.
|
* @param str The string to convert to object.
|
||||||
* @param locale The locale to convert the string from.
|
* @param locale The locale to convert the string from.
|
||||||
* @return The object converted from the string.
|
* @return The object converted from the string.
|
||||||
* @throws ObjectConverterException When conversion fails.
|
* @throws ObjectConverterException When conversion fails.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
||||||
if (split==null) {
|
if (split == null) {
|
||||||
throw new ObjectConverterException(this,"split is not set.");
|
throw new ObjectConverterException(this, "split is not set.");
|
||||||
}
|
}
|
||||||
if (splitSize==null) {
|
if (splitSize == null) {
|
||||||
throw new ObjectConverterException(this,"splitSize is not set.");
|
throw new ObjectConverterException(this, "splitSize is not set.");
|
||||||
}
|
}
|
||||||
if (classTo==null) {
|
if (classTo == null) {
|
||||||
throw new ObjectConverterException(this,"classTo is not set.");
|
throw new ObjectConverterException(this, "classTo is not set.");
|
||||||
}
|
}
|
||||||
String[] strSplit = str.split(split);
|
String[] strSplit = str.split(split);
|
||||||
if(strSplit.length!=splitSize) {
|
if (strSplit.length != splitSize) {
|
||||||
throw new ObjectConverterException(this,"Split size is wrong; "+strSplit.length+" need: "+splitSize);
|
throw new ObjectConverterException(this, "Split size is wrong; " + strSplit.length + " need: " + splitSize);
|
||||||
}
|
}
|
||||||
List<StringSplitConverterStep> steps = getOrderedSteps(true);
|
List<StringSplitConverterStep> steps = getOrderedSteps(true);
|
||||||
if (steps.size()!=splitSize) {
|
if (steps.size() != splitSize) {
|
||||||
throw new ObjectConverterException(this,"Step size is wrong; "+steps.size()+" need: "+splitSize);
|
throw new ObjectConverterException(this, "Step size is wrong; " + steps.size() + " need: " + splitSize);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Object[] singleMethodValues = new Object[splitSize];
|
Object[] singleMethodValues = new Object[splitSize];
|
||||||
Object object = X4OLanguageClassLoader.newInstance(classTo);
|
Object object = X4OLanguageClassLoader.newInstance(classTo);
|
||||||
for (int i=0;i<steps.size();i++) {
|
for (int i = 0; i < steps.size(); i++) {
|
||||||
StringSplitConverterStep step = steps.get(i);
|
StringSplitConverterStep step = steps.get(i);
|
||||||
Object stepObject = strSplit[i];
|
Object stepObject = strSplit[i];
|
||||||
Object stepValue = step.getObjectConverter().convertTo(stepObject, locale);
|
Object stepValue = step.getObjectConverter().convertTo(stepObject, locale);
|
||||||
if (singleToMethod==null) {
|
if (singleToMethod == null) {
|
||||||
Method m = classTo.getMethod(step.getToMethod(), new Class[] {stepValue.getClass()});
|
Method m = classTo.getMethod(step.getToMethod(), new Class[] { stepValue.getClass() });
|
||||||
m.invoke(object, stepValue);
|
m.invoke(object, stepValue);
|
||||||
} else {
|
} else {
|
||||||
singleMethodValues[i] = stepValue;
|
singleMethodValues[i] = stepValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (singleToMethod!=null) {
|
if (singleToMethod != null) {
|
||||||
List<Class> arguClass = new ArrayList<Class>(singleMethodValues.length);
|
List<Class> arguClass = new ArrayList<Class>(singleMethodValues.length);
|
||||||
for (int i=0;i<singleMethodValues.length;i++) {
|
for (int i = 0; i < singleMethodValues.length; i++) {
|
||||||
arguClass.add(singleMethodValues[i].getClass());
|
arguClass.add(singleMethodValues[i].getClass());
|
||||||
}
|
}
|
||||||
if (useNativeType!=null && useNativeType) {
|
if (useNativeType != null && useNativeType) {
|
||||||
arguClass = convertToNative(arguClass);
|
arguClass = convertToNative(arguClass);
|
||||||
}
|
}
|
||||||
Class[] arguArray = new Class[arguClass.size()];
|
Class[] arguArray = new Class[arguClass.size()];
|
||||||
arguArray = arguClass.toArray(arguArray);
|
arguArray = arguClass.toArray(arguArray);
|
||||||
Method m = classTo.getMethod(singleToMethod, arguArray);
|
Method m = classTo.getMethod(singleToMethod, arguArray);
|
||||||
|
|
||||||
List<Object> arguValue = new ArrayList<Object>(singleMethodValues.length);
|
List<Object> arguValue = new ArrayList<Object>(singleMethodValues.length);
|
||||||
for (int i=0;i<singleMethodValues.length;i++) {
|
for (int i = 0; i < singleMethodValues.length; i++) {
|
||||||
arguValue.add(singleMethodValues[i]);
|
arguValue.add(singleMethodValues[i]);
|
||||||
}
|
}
|
||||||
Object[] valueArray = new Object[arguValue.size()];
|
Object[] valueArray = new Object[arguValue.size()];
|
||||||
|
|
@ -127,27 +128,27 @@ public class StringSplitConverter extends AbstractStringObjectConverter {
|
||||||
}
|
}
|
||||||
return object;
|
return object;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ObjectConverterException(this,e.getMessage(),e);
|
throw new ObjectConverterException(this, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts object into string.
|
* Converts object into string.
|
||||||
*
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
|
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
|
||||||
* @param object The object to convert to string.
|
* @param object The object to convert to string.
|
||||||
* @param locale The locale to convert the object from.
|
* @param locale The locale to convert the object from.
|
||||||
* @return The string converted from the object.
|
* @return The string converted from the object.
|
||||||
* @throws ObjectConverterException When conversion fails.
|
* @throws ObjectConverterException When conversion fails.
|
||||||
*/
|
*/
|
||||||
public String convertStringBack(Object object,Locale locale) throws ObjectConverterException {
|
public String convertStringBack(Object object, Locale locale) throws ObjectConverterException {
|
||||||
List<StringSplitConverterStep> steps = getOrderedSteps(false);
|
List<StringSplitConverterStep> steps = getOrderedSteps(false);
|
||||||
if (steps.size()!=splitSize) {
|
if (steps.size() != splitSize) {
|
||||||
throw new ObjectConverterException(this,"Step size is wrong; "+steps.size()+" need: "+splitSize);
|
throw new ObjectConverterException(this, "Step size is wrong; " + steps.size() + " need: " + splitSize);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
StringBuilder buf = new StringBuilder(200);
|
StringBuilder buf = new StringBuilder(200);
|
||||||
for (int i=0;i<steps.size();i++) {
|
for (int i = 0; i < steps.size(); i++) {
|
||||||
StringSplitConverterStep step = steps.get(i);
|
StringSplitConverterStep step = steps.get(i);
|
||||||
Method m = classTo.getMethod(step.getFromMethod(), new Class[] {});
|
Method m = classTo.getMethod(step.getFromMethod(), new Class[] {});
|
||||||
Object stepValue = m.invoke(object, new Object[] {});
|
Object stepValue = m.invoke(object, new Object[] {});
|
||||||
|
|
@ -156,12 +157,13 @@ public class StringSplitConverter extends AbstractStringObjectConverter {
|
||||||
}
|
}
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ObjectConverterException(this,e.getMessage(),e);
|
throw new ObjectConverterException(this, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clone this ObjectConverter.
|
* Clone this ObjectConverter.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
|
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
|
||||||
* @return The cloned ObjectConverter.
|
* @return The cloned ObjectConverter.
|
||||||
* @throws CloneNotSupportedException When cloning fails.
|
* @throws CloneNotSupportedException When cloning fails.
|
||||||
|
|
@ -169,20 +171,24 @@ public class StringSplitConverter extends AbstractStringObjectConverter {
|
||||||
@Override
|
@Override
|
||||||
public ObjectConverter clone() throws CloneNotSupportedException {
|
public ObjectConverter clone() throws CloneNotSupportedException {
|
||||||
StringSplitConverter result = new StringSplitConverter();
|
StringSplitConverter result = new StringSplitConverter();
|
||||||
result.converters=cloneConverters();
|
result.converters = cloneConverters();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<StringSplitConverterStep> getOrderedSteps(boolean isTo) {
|
private List<StringSplitConverterStep> getOrderedSteps(boolean isTo) {
|
||||||
List<StringSplitConverterStep> result = new ArrayList<StringSplitConverterStep>(stringSplitConverterSteps.size());
|
List<StringSplitConverterStep> result = new ArrayList<StringSplitConverterStep>(stringSplitConverterSteps.size());
|
||||||
result.addAll(stringSplitConverterSteps);
|
result.addAll(stringSplitConverterSteps);
|
||||||
Collections.sort(stringSplitConverterSteps,new StringSplitConverterStepComparator(isTo));
|
Collections.sort(stringSplitConverterSteps, new StringSplitConverterStepComparator(isTo));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class StringSplitConverterStepComparator implements Comparator<StringSplitConverterStep> {
|
public class StringSplitConverterStepComparator implements Comparator<StringSplitConverterStep> {
|
||||||
boolean isTo = true;
|
boolean isTo = true;
|
||||||
public StringSplitConverterStepComparator(boolean isTo) { this.isTo=isTo; }
|
|
||||||
|
public StringSplitConverterStepComparator(boolean isTo) {
|
||||||
|
this.isTo = isTo;
|
||||||
|
}
|
||||||
|
|
||||||
public int compare(StringSplitConverterStep e1, StringSplitConverterStep e2) {
|
public int compare(StringSplitConverterStep e1, StringSplitConverterStep e2) {
|
||||||
if (isTo) {
|
if (isTo) {
|
||||||
return e1.getToOrder().compareTo(e2.getToOrder());
|
return e1.getToOrder().compareTo(e2.getToOrder());
|
||||||
|
|
@ -191,11 +197,11 @@ public class StringSplitConverter extends AbstractStringObjectConverter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
private List<Class> convertToNative(List<Class> types) throws ObjectConverterException {
|
private List<Class> convertToNative(List<Class> types) throws ObjectConverterException {
|
||||||
List<Class> result = new ArrayList<Class>(types.size());
|
List<Class> result = new ArrayList<Class>(types.size());
|
||||||
for (int i=0;i<types.size();i++) {
|
for (int i = 0; i < types.size(); i++) {
|
||||||
Class<?> clazz = types.get(i);
|
Class<?> clazz = types.get(i);
|
||||||
if (clazz.isAssignableFrom(Integer.class)) {
|
if (clazz.isAssignableFrom(Integer.class)) {
|
||||||
result.add(Integer.TYPE);
|
result.add(Integer.TYPE);
|
||||||
|
|
@ -208,12 +214,12 @@ public class StringSplitConverter extends AbstractStringObjectConverter {
|
||||||
} else if (clazz.isAssignableFrom(Boolean.class)) {
|
} else if (clazz.isAssignableFrom(Boolean.class)) {
|
||||||
result.add(Boolean.TYPE);
|
result.add(Boolean.TYPE);
|
||||||
} else {
|
} else {
|
||||||
throw new ObjectConverterException(this,"Can't convert type to native; "+clazz);
|
throw new ObjectConverterException(this, "Can't convert type to native; " + clazz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the classTo
|
* @return the classTo
|
||||||
*/
|
*/
|
||||||
|
|
@ -269,7 +275,7 @@ public class StringSplitConverter extends AbstractStringObjectConverter {
|
||||||
public void setSingleToMethod(String singleToMethod) {
|
public void setSingleToMethod(String singleToMethod) {
|
||||||
this.singleToMethod = singleToMethod;
|
this.singleToMethod = singleToMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the useNativeType
|
* @return the useNativeType
|
||||||
*/
|
*/
|
||||||
|
|
@ -287,9 +293,11 @@ public class StringSplitConverter extends AbstractStringObjectConverter {
|
||||||
public void addStringSplitConverterStep(StringSplitConverterStep stringSplitConverterStep) {
|
public void addStringSplitConverterStep(StringSplitConverterStep stringSplitConverterStep) {
|
||||||
stringSplitConverterSteps.add(stringSplitConverterStep);
|
stringSplitConverterSteps.add(stringSplitConverterStep);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeStringSplitConverterStep(StringSplitConverterStep stringSplitConverterStep) {
|
public void removeStringSplitConverterStep(StringSplitConverterStep stringSplitConverterStep) {
|
||||||
stringSplitConverterSteps.remove(stringSplitConverterStep);
|
stringSplitConverterSteps.remove(stringSplitConverterStep);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<StringSplitConverterStep> getStringSplitConverterSteps() {
|
public List<StringSplitConverterStep> getStringSplitConverterSteps() {
|
||||||
return stringSplitConverterSteps;
|
return stringSplitConverterSteps;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,70 +37,70 @@ public class StringSplitConverterStep {
|
||||||
private Integer fromOrder = null;
|
private Integer fromOrder = null;
|
||||||
private String toMethod = null;
|
private String toMethod = null;
|
||||||
private Integer toOrder = null;
|
private Integer toOrder = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the objectConverter
|
* @return the objectConverter
|
||||||
*/
|
*/
|
||||||
public ObjectConverter getObjectConverter() {
|
public ObjectConverter getObjectConverter() {
|
||||||
return objectConverter;
|
return objectConverter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param objectConverter the objectConverter to set
|
* @param objectConverter the objectConverter to set
|
||||||
*/
|
*/
|
||||||
public void setObjectConverter(ObjectConverter objectConverter) {
|
public void setObjectConverter(ObjectConverter objectConverter) {
|
||||||
this.objectConverter = objectConverter;
|
this.objectConverter = objectConverter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the fromMethod
|
* @return the fromMethod
|
||||||
*/
|
*/
|
||||||
public String getFromMethod() {
|
public String getFromMethod() {
|
||||||
return fromMethod;
|
return fromMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param fromMethod the fromMethod to set
|
* @param fromMethod the fromMethod to set
|
||||||
*/
|
*/
|
||||||
public void setFromMethod(String fromMethod) {
|
public void setFromMethod(String fromMethod) {
|
||||||
this.fromMethod = fromMethod;
|
this.fromMethod = fromMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the fromOrder
|
* @return the fromOrder
|
||||||
*/
|
*/
|
||||||
public Integer getFromOrder() {
|
public Integer getFromOrder() {
|
||||||
return fromOrder;
|
return fromOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param fromOrder the fromOrder to set
|
* @param fromOrder the fromOrder to set
|
||||||
*/
|
*/
|
||||||
public void setFromOrder(Integer fromOrder) {
|
public void setFromOrder(Integer fromOrder) {
|
||||||
this.fromOrder = fromOrder;
|
this.fromOrder = fromOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the toMethod
|
* @return the toMethod
|
||||||
*/
|
*/
|
||||||
public String getToMethod() {
|
public String getToMethod() {
|
||||||
return toMethod;
|
return toMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param toMethod the toMethod to set
|
* @param toMethod the toMethod to set
|
||||||
*/
|
*/
|
||||||
public void setToMethod(String toMethod) {
|
public void setToMethod(String toMethod) {
|
||||||
this.toMethod = toMethod;
|
this.toMethod = toMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the toOrder
|
* @return the toOrder
|
||||||
*/
|
*/
|
||||||
public Integer getToOrder() {
|
public Integer getToOrder() {
|
||||||
return toOrder;
|
return toOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param toOrder the toOrder to set
|
* @param toOrder the toOrder to set
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -42,18 +42,19 @@ public class URLConverter extends AbstractStringObjectConverter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the convert to class.
|
* Returns the convert to class.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
|
* @see org.x4o.xml.conv.ObjectConverter#getObjectClassTo()
|
||||||
* @return The class to convert to.
|
* @return The class to convert to.
|
||||||
*/
|
*/
|
||||||
public Class<?> getObjectClassTo() {
|
public Class<?> getObjectClassTo() {
|
||||||
return URL.class;
|
return URL.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts string into object.
|
* Converts string into object.
|
||||||
*
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
|
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringTo(java.lang.String, java.util.Locale)
|
||||||
* @param str The string to convert to object.
|
* @param str The string to convert to object.
|
||||||
* @param locale The locale to convert the string from.
|
* @param locale The locale to convert the string from.
|
||||||
* @return The object converted from the string.
|
* @return The object converted from the string.
|
||||||
* @throws ObjectConverterException When conversion fails.
|
* @throws ObjectConverterException When conversion fails.
|
||||||
|
|
@ -62,25 +63,26 @@ public class URLConverter extends AbstractStringObjectConverter {
|
||||||
try {
|
try {
|
||||||
return new URL(str);
|
return new URL(str);
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
throw new ObjectConverterException(this,e.getMessage(),e);
|
throw new ObjectConverterException(this, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts object into string.
|
* Converts object into string.
|
||||||
*
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
|
* @see org.x4o.xml.conv.AbstractStringObjectConverter#convertStringBack(java.lang.Object, java.util.Locale)
|
||||||
* @param obj The object to convert to string.
|
* @param obj The object to convert to string.
|
||||||
* @param locale The locale to convert the object from.
|
* @param locale The locale to convert the object from.
|
||||||
* @return The string converted from the object.
|
* @return The string converted from the object.
|
||||||
* @throws ObjectConverterException When conversion fails.
|
* @throws ObjectConverterException When conversion fails.
|
||||||
*/
|
*/
|
||||||
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
|
public String convertStringBack(Object obj, Locale locale) throws ObjectConverterException {
|
||||||
return ((URL)obj).toString();
|
return ((URL) obj).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clone this ObjectConverter.
|
* Clone this ObjectConverter.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
|
* @see org.x4o.xml.conv.AbstractObjectConverter#clone()
|
||||||
* @return The cloned ObjectConverter.
|
* @return The cloned ObjectConverter.
|
||||||
* @throws CloneNotSupportedException When cloning fails.
|
* @throws CloneNotSupportedException When cloning fails.
|
||||||
|
|
@ -88,7 +90,7 @@ public class URLConverter extends AbstractStringObjectConverter {
|
||||||
@Override
|
@Override
|
||||||
public ObjectConverter clone() throws CloneNotSupportedException {
|
public ObjectConverter clone() throws CloneNotSupportedException {
|
||||||
URLConverter result = new URLConverter();
|
URLConverter result = new URLConverter();
|
||||||
result.converters=cloneConverters();
|
result.converters = cloneConverters();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,30 +41,31 @@ import javax.el.VariableMapper;
|
||||||
* @version 1.0 Sep 14, 2010
|
* @version 1.0 Sep 14, 2010
|
||||||
*/
|
*/
|
||||||
public class X4OELContext extends ELContext {
|
public class X4OELContext extends ELContext {
|
||||||
|
|
||||||
private ELResolver elResolver = null;
|
private ELResolver elResolver = null;
|
||||||
private FunctionMapper functionMapper = null;
|
private FunctionMapper functionMapper = null;
|
||||||
private VariableMapper variableMapper = null;
|
private VariableMapper variableMapper = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a X4OELContext.
|
* Creates a X4OELContext.
|
||||||
*/
|
*/
|
||||||
public X4OELContext() {
|
public X4OELContext() {
|
||||||
|
|
||||||
CompositeELResolver compositeELResolver = new CompositeELResolver();
|
CompositeELResolver compositeELResolver = new CompositeELResolver();
|
||||||
compositeELResolver.add(new X4OELResolver(new HashMap<Object, Object>(100)));
|
compositeELResolver.add(new X4OELResolver(new HashMap<Object, Object>(100)));
|
||||||
compositeELResolver.add(new ArrayELResolver());
|
compositeELResolver.add(new ArrayELResolver());
|
||||||
compositeELResolver.add(new ListELResolver());
|
compositeELResolver.add(new ListELResolver());
|
||||||
compositeELResolver.add(new BeanELResolver());
|
compositeELResolver.add(new BeanELResolver());
|
||||||
compositeELResolver.add(new MapELResolver());
|
compositeELResolver.add(new MapELResolver());
|
||||||
|
|
||||||
elResolver = compositeELResolver;
|
elResolver = compositeELResolver;
|
||||||
functionMapper = new X4OELFunctionMapper();
|
functionMapper = new X4OELFunctionMapper();
|
||||||
variableMapper = new X4OELVariableMapper();
|
variableMapper = new X4OELVariableMapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the ELResolver.
|
* Returns the ELResolver.
|
||||||
|
*
|
||||||
* @return The ELResolver.
|
* @return The ELResolver.
|
||||||
* @see javax.el.ELContext#getELResolver()
|
* @see javax.el.ELContext#getELResolver()
|
||||||
*/
|
*/
|
||||||
|
|
@ -75,6 +76,7 @@ public class X4OELContext extends ELContext {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the FunctionMapper.
|
* Returns the FunctionMapper.
|
||||||
|
*
|
||||||
* @return The FunctionMapper.
|
* @return The FunctionMapper.
|
||||||
* @see javax.el.ELContext#getFunctionMapper()
|
* @see javax.el.ELContext#getFunctionMapper()
|
||||||
*/
|
*/
|
||||||
|
|
@ -85,6 +87,7 @@ public class X4OELContext extends ELContext {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the VariableMapper.
|
* Returns the VariableMapper.
|
||||||
|
*
|
||||||
* @return The VariableMapper.
|
* @return The VariableMapper.
|
||||||
* @see javax.el.ELContext#getVariableMapper()
|
* @see javax.el.ELContext#getVariableMapper()
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -36,53 +36,55 @@ import javax.el.FunctionMapper;
|
||||||
* @version 1.0 Sep 14, 2010
|
* @version 1.0 Sep 14, 2010
|
||||||
*/
|
*/
|
||||||
public class X4OELFunctionMapper extends FunctionMapper {
|
public class X4OELFunctionMapper extends FunctionMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores the el to method function mapping.
|
* Stores the el to method function mapping.
|
||||||
*/
|
*/
|
||||||
private Map<String,Method> functionMap = null;
|
private Map<String, Method> functionMap = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a X4OELFunctionMapper.
|
* Creates a X4OELFunctionMapper.
|
||||||
*/
|
*/
|
||||||
public X4OELFunctionMapper() {
|
public X4OELFunctionMapper() {
|
||||||
functionMap = new HashMap<String,Method>(50);
|
functionMap = new HashMap<String, Method>(50);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolves method el functions.
|
* Resolves method el functions.
|
||||||
* @param prefix The function prefix.
|
*
|
||||||
* @param localName The local name of function.
|
* @param prefix The function prefix.
|
||||||
* @return The resolved function or null is not found.
|
* @param localName The local name of function.
|
||||||
|
* @return The resolved function or null is not found.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Method resolveFunction(String prefix, String localName) {
|
public Method resolveFunction(String prefix, String localName) {
|
||||||
String key = prefix + ":" + localName;
|
String key = prefix + ":" + localName;
|
||||||
return functionMap.get(key);
|
return functionMap.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an static method to the function mapper.
|
* Add an static method to the function mapper.
|
||||||
* @param prefix The function prefix.
|
*
|
||||||
* @param localName The local name of function.
|
* @param prefix The function prefix.
|
||||||
* @param method The method to execute on.
|
* @param localName The local name of function.
|
||||||
|
* @param method The method to execute on.
|
||||||
*/
|
*/
|
||||||
public void addFunction(String prefix, String localName, Method method) {
|
public void addFunction(String prefix, String localName, Method method) {
|
||||||
if(prefix==null || localName==null || method==null) {
|
if (prefix == null || localName == null || method == null) {
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
}
|
}
|
||||||
int modifiers = method.getModifiers();
|
int modifiers = method.getModifiers();
|
||||||
if(!Modifier.isPublic(modifiers)) {
|
if (!Modifier.isPublic(modifiers)) {
|
||||||
throw new IllegalArgumentException("method not public");
|
throw new IllegalArgumentException("method not public");
|
||||||
}
|
}
|
||||||
if(!Modifier.isStatic(modifiers)) {
|
if (!Modifier.isStatic(modifiers)) {
|
||||||
throw new IllegalArgumentException("method not static");
|
throw new IllegalArgumentException("method not static");
|
||||||
}
|
}
|
||||||
Class<?> retType = method.getReturnType();
|
Class<?> retType = method.getReturnType();
|
||||||
if(retType == Void.TYPE) {
|
if (retType == Void.TYPE) {
|
||||||
throw new IllegalArgumentException("method returns void");
|
throw new IllegalArgumentException("method returns void");
|
||||||
}
|
}
|
||||||
|
|
||||||
String key = prefix + ":" + localName;
|
String key = prefix + ":" + localName;
|
||||||
functionMap.put(key, method);
|
functionMap.put(key, method);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,6 @@ import javax.el.ELContext;
|
||||||
import javax.el.ELResolver;
|
import javax.el.ELResolver;
|
||||||
import javax.el.MapELResolver;
|
import javax.el.MapELResolver;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* X4OELResolver simple EL resolver.
|
* X4OELResolver simple EL resolver.
|
||||||
*
|
*
|
||||||
|
|
@ -37,37 +36,39 @@ import javax.el.MapELResolver;
|
||||||
* @version 1.0 Sep 14, 2010
|
* @version 1.0 Sep 14, 2010
|
||||||
*/
|
*/
|
||||||
public class X4OELResolver extends ELResolver {
|
public class X4OELResolver extends ELResolver {
|
||||||
|
|
||||||
private ELResolver delegate = null;
|
private ELResolver delegate = null;
|
||||||
private Map<Object,Object> objectStore = null;
|
private Map<Object, Object> objectStore = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates X4OELResolver which is backed by the objectStore.
|
* Creates X4OELResolver which is backed by the objectStore.
|
||||||
* @param objectStore The objectStore.
|
*
|
||||||
|
* @param objectStore The objectStore.
|
||||||
*/
|
*/
|
||||||
public X4OELResolver(Map<Object, Object> objectStore) {
|
public X4OELResolver(Map<Object, Object> objectStore) {
|
||||||
this.objectStore = objectStore;
|
this.objectStore = objectStore;
|
||||||
delegate = new MapELResolver();
|
delegate = new MapELResolver();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if base object is null and else return objectStore.
|
* Checks if base object is null and else return objectStore.
|
||||||
* @param base The base object to check.
|
*
|
||||||
* @return Returns the base object or objectStore.
|
* @param base The base object to check.
|
||||||
|
* @return Returns the base object or objectStore.
|
||||||
*/
|
*/
|
||||||
private Object checkBase(Object base) {
|
private Object checkBase(Object base) {
|
||||||
if (base==null) {
|
if (base == null) {
|
||||||
return objectStore;
|
return objectStore;
|
||||||
}
|
}
|
||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getValue(ELContext context, Object base, Object property) {
|
public Object getValue(ELContext context, Object base, Object property) {
|
||||||
base = checkBase(base);
|
base = checkBase(base);
|
||||||
return delegate.getValue(context, base, property);
|
return delegate.getValue(context, base, property);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<?> getCommonPropertyType(ELContext context, Object base) {
|
public Class<?> getCommonPropertyType(ELContext context, Object base) {
|
||||||
base = checkBase(base);
|
base = checkBase(base);
|
||||||
|
|
@ -76,7 +77,7 @@ public class X4OELResolver extends ELResolver {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
public Iterator getFeatureDescriptors(ELContext context,Object base) {
|
public Iterator getFeatureDescriptors(ELContext context, Object base) {
|
||||||
base = checkBase(base);
|
base = checkBase(base);
|
||||||
return delegate.getFeatureDescriptors(context, base);
|
return delegate.getFeatureDescriptors(context, base);
|
||||||
}
|
}
|
||||||
|
|
@ -86,7 +87,7 @@ public class X4OELResolver extends ELResolver {
|
||||||
base = checkBase(base);
|
base = checkBase(base);
|
||||||
return delegate.getType(context, base, property);
|
return delegate.getType(context, base, property);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isReadOnly(ELContext context, Object base, Object property) {
|
public boolean isReadOnly(ELContext context, Object base, Object property) {
|
||||||
base = checkBase(base);
|
base = checkBase(base);
|
||||||
|
|
|
||||||
|
|
@ -35,17 +35,17 @@ import javax.el.VariableMapper;
|
||||||
* @version 1.0 Sep 14, 2010
|
* @version 1.0 Sep 14, 2010
|
||||||
*/
|
*/
|
||||||
public class X4OELVariableMapper extends VariableMapper {
|
public class X4OELVariableMapper extends VariableMapper {
|
||||||
|
|
||||||
/** Map to hold all the expressions used. */
|
/** Map to hold all the expressions used. */
|
||||||
private Map<String, ValueExpression> expressions = null;
|
private Map<String, ValueExpression> expressions = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the X4OELVariableMapper.
|
* Creates the X4OELVariableMapper.
|
||||||
*/
|
*/
|
||||||
public X4OELVariableMapper() {
|
public X4OELVariableMapper() {
|
||||||
expressions = new HashMap<String, ValueExpression>();
|
expressions = new HashMap<String, ValueExpression>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see javax.el.VariableMapper#resolveVariable(java.lang.String)
|
* @see javax.el.VariableMapper#resolveVariable(java.lang.String)
|
||||||
* @param var Resolve this var to an ValueExpression.
|
* @param var Resolve this var to an ValueExpression.
|
||||||
|
|
@ -58,7 +58,7 @@ public class X4OELVariableMapper extends VariableMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see javax.el.VariableMapper#setVariable(java.lang.String, javax.el.ValueExpression)
|
* @see javax.el.VariableMapper#setVariable(java.lang.String, javax.el.ValueExpression)
|
||||||
* @param var Resolve this var to an ValueExpression.
|
* @param var Resolve this var to an ValueExpression.
|
||||||
* @param expression The ValueExpression of the var.
|
* @param expression The ValueExpression of the var.
|
||||||
* @return The ValueExpression being set.
|
* @return The ValueExpression being set.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ import javax.el.ExpressionFactory;
|
||||||
import org.x4o.xml.lang.X4OLanguageClassLoader;
|
import org.x4o.xml.lang.X4OLanguageClassLoader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* X4OExpressionFactory finds and loads the needed impl.
|
* X4OExpressionFactory finds and loads the needed impl.
|
||||||
*
|
*
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Apr 7, 2013
|
* @version 1.0 Apr 7, 2013
|
||||||
|
|
@ -37,7 +37,7 @@ public class X4OExpressionFactory {
|
||||||
|
|
||||||
static public final String EL_FACTORY_IMPL_APACHE = "org.apache.el.ExpressionFactoryImpl";
|
static public final String EL_FACTORY_IMPL_APACHE = "org.apache.el.ExpressionFactoryImpl";
|
||||||
static public final String EL_FACTORY_IMPL_ODYSSEUS = "de.odysseus.el.ExpressionFactoryImpl";
|
static public final String EL_FACTORY_IMPL_ODYSSEUS = "de.odysseus.el.ExpressionFactoryImpl";
|
||||||
|
|
||||||
static public ExpressionFactory createExpressionFactory() {
|
static public ExpressionFactory createExpressionFactory() {
|
||||||
ExpressionFactory result = null;
|
ExpressionFactory result = null;
|
||||||
try {
|
try {
|
||||||
|
|
@ -48,17 +48,18 @@ public class X4OExpressionFactory {
|
||||||
Class<?> expressionFactoryClass = X4OLanguageClassLoader.loadClass(EL_FACTORY_IMPL_ODYSSEUS);
|
Class<?> expressionFactoryClass = X4OLanguageClassLoader.loadClass(EL_FACTORY_IMPL_ODYSSEUS);
|
||||||
result = X4OLanguageClassLoader.newInstance(ExpressionFactory.class, expressionFactoryClass);
|
result = X4OLanguageClassLoader.newInstance(ExpressionFactory.class, expressionFactoryClass);
|
||||||
} catch (ClassNotFoundException ee) {
|
} catch (ClassNotFoundException ee) {
|
||||||
throw new RuntimeException("Could not load ExpressionFactory tried: "+EL_FACTORY_IMPL_APACHE+" and "+EL_FACTORY_IMPL_ODYSSEUS+" but could not load one of them.");
|
throw new RuntimeException("Could not load ExpressionFactory tried: " + EL_FACTORY_IMPL_APACHE + " and " + EL_FACTORY_IMPL_ODYSSEUS
|
||||||
|
+ " but could not load one of them.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public ELContext createELContext(Class<?> elContextClass) {
|
static public ELContext createELContext(Class<?> elContextClass) {
|
||||||
try {
|
try {
|
||||||
return X4OLanguageClassLoader.newInstance(ELContext.class, elContextClass);
|
return X4OLanguageClassLoader.newInstance(ELContext.class, elContextClass);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new RuntimeException("Could not create instance of ELContext: "+e.getMessage(),e);
|
throw new RuntimeException("Could not create instance of ELContext: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.eld;
|
package org.x4o.xml.eld;
|
||||||
|
|
||||||
import org.x4o.xml.X4ODriver;
|
import org.x4o.xml.X4ODriver;
|
||||||
import org.x4o.xml.lang.X4OLanguageModule;
|
import org.x4o.xml.lang.X4OLanguageModule;
|
||||||
|
|
@ -35,9 +35,9 @@ public class CelDriver extends X4ODriver<X4OLanguageModule> {
|
||||||
|
|
||||||
/** Defines the identifier of the 'Core Element Language' language. */
|
/** Defines the identifier of the 'Core Element Language' language. */
|
||||||
public static final String LANGUAGE_NAME = "cel";
|
public static final String LANGUAGE_NAME = "cel";
|
||||||
|
|
||||||
/** Defines the versions this langauge knowns. */
|
/** Defines the versions this langauge knowns. */
|
||||||
public static final String[] LANGUAGE_VERSIONS = new String[]{X4ODriver.DEFAULT_LANGUAGE_VERSION};
|
public static final String[] LANGUAGE_VERSIONS = new String[] { X4ODriver.DEFAULT_LANGUAGE_VERSION };
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getLanguageName() {
|
public String getLanguageName() {
|
||||||
|
|
|
||||||
|
|
@ -20,14 +20,13 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.eld;
|
package org.x4o.xml.eld;
|
||||||
|
|
||||||
import org.x4o.xml.X4ODriver;
|
import org.x4o.xml.X4ODriver;
|
||||||
import org.x4o.xml.lang.X4OLanguageModule;
|
import org.x4o.xml.lang.X4OLanguageModule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An Element Language Definition X4O parser.
|
* An Element Language Definition X4O parser. This eld parser config parent x4o parser with the eld x4o parser.
|
||||||
* This eld parser config parent x4o parser with the eld x4o parser.
|
|
||||||
*
|
*
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Aug 20, 2005
|
* @version 1.0 Aug 20, 2005
|
||||||
|
|
@ -36,15 +35,15 @@ public class EldDriver extends X4ODriver<X4OLanguageModule> {
|
||||||
|
|
||||||
/** Defines the identifier of the 'Element Language Description' language. */
|
/** Defines the identifier of the 'Element Language Description' language. */
|
||||||
public static final String LANGUAGE_NAME = "eld";
|
public static final String LANGUAGE_NAME = "eld";
|
||||||
|
|
||||||
/** Defines the identifier of the ELD x4o language. */
|
/** Defines the identifier of the ELD x4o language. */
|
||||||
public static final String[] LANGUAGE_VERSIONS = new String[]{X4ODriver.DEFAULT_LANGUAGE_VERSION};
|
public static final String[] LANGUAGE_VERSIONS = new String[] { X4ODriver.DEFAULT_LANGUAGE_VERSION };
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getLanguageName() {
|
public String getLanguageName() {
|
||||||
return LANGUAGE_NAME;
|
return LANGUAGE_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getLanguageVersions() {
|
public String[] getLanguageVersions() {
|
||||||
return LANGUAGE_VERSIONS;
|
return LANGUAGE_VERSIONS;
|
||||||
|
|
|
||||||
|
|
@ -52,19 +52,20 @@ public class EldModuleLoader implements X4OLanguageModuleLoader {
|
||||||
private final Logger logger;
|
private final Logger logger;
|
||||||
private final String eldResource;
|
private final String eldResource;
|
||||||
private final boolean isEldCore;
|
private final boolean isEldCore;
|
||||||
|
|
||||||
/** The EL key to access the parent language module. */
|
/** The EL key to access the parent language module. */
|
||||||
public static final String EL_PARENT_LANGUAGE_MODULE = "parentLanguageModule";
|
public static final String EL_PARENT_LANGUAGE_MODULE = "parentLanguageModule";
|
||||||
|
|
||||||
/** The EL key to access the parent language element langauge. */
|
/** The EL key to access the parent language element langauge. */
|
||||||
public static final String EL_PARENT_LANGUAGE = "parentLanguage";
|
public static final String EL_PARENT_LANGUAGE = "parentLanguage";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an ELD/CEL module loader.
|
* Creates an ELD/CEL module loader.
|
||||||
* @param eldResource The resource to load.
|
*
|
||||||
* @param isEldCore If true then load CEL else load ELD.
|
* @param eldResource The resource to load.
|
||||||
|
* @param isEldCore If true then load CEL else load ELD.
|
||||||
*/
|
*/
|
||||||
public EldModuleLoader(String eldResource,boolean isEldCore) {
|
public EldModuleLoader(String eldResource, boolean isEldCore) {
|
||||||
if (eldResource == null) {
|
if (eldResource == null) {
|
||||||
throw new NullPointerException("Can't load null eld resource.");
|
throw new NullPointerException("Can't load null eld resource.");
|
||||||
}
|
}
|
||||||
|
|
@ -75,13 +76,15 @@ public class EldModuleLoader implements X4OLanguageModuleLoader {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the ELD language into the module.
|
* Loads the ELD language into the module.
|
||||||
* @param session The session we run in.
|
*
|
||||||
|
* @param session The session we run in.
|
||||||
* @param language The local Language to load for.
|
* @param language The local Language to load for.
|
||||||
* @param module The language module to load it into.
|
* @param module The language module to load it into.
|
||||||
* @throws X4OLanguageModuleLoaderException When eld language could not be loaded.
|
* @throws X4OLanguageModuleLoaderException When eld language could not be loaded.
|
||||||
* @see org.x4o.xml.lang.X4OLanguageModuleLoader#loadLanguageModule(org.x4o.xml.lang.X4OLanguageLocal, org.x4o.xml.lang.X4OLanguageModuleLocal)
|
* @see org.x4o.xml.lang.X4OLanguageModuleLoader#loadLanguageModule(org.x4o.xml.lang.X4OLanguageLocal, org.x4o.xml.lang.X4OLanguageModuleLocal)
|
||||||
*/
|
*/
|
||||||
public void loadLanguageModule(X4OLanguageSession session, X4OLanguageLocal language, X4OLanguageModuleLocal module) throws X4OLanguageModuleLoaderException {
|
public void loadLanguageModule(X4OLanguageSession session, X4OLanguageLocal language, X4OLanguageModuleLocal module)
|
||||||
|
throws X4OLanguageModuleLoaderException {
|
||||||
logger.fine("Loading name eld file from resource: " + eldResource);
|
logger.fine("Loading name eld file from resource: " + eldResource);
|
||||||
try {
|
try {
|
||||||
X4ODriver<?> driver = null;
|
X4ODriver<?> driver = null;
|
||||||
|
|
@ -98,21 +101,23 @@ public class EldModuleLoader implements X4OLanguageModuleLoader {
|
||||||
}
|
}
|
||||||
reader.readResource(eldResource);
|
reader.readResource(eldResource);
|
||||||
} catch (X4OConnectionException e) {
|
} catch (X4OConnectionException e) {
|
||||||
throw new X4OLanguageModuleLoaderException(this,e.getMessage()+" while parsing: "+eldResource,e);
|
throw new X4OLanguageModuleLoaderException(this, e.getMessage() + " while parsing: " + eldResource, e);
|
||||||
} catch (SAXException e) {
|
} catch (SAXException e) {
|
||||||
throw new X4OLanguageModuleLoaderException(this,e.getMessage()+" while parsing: "+eldResource,e);
|
throw new X4OLanguageModuleLoaderException(this, e.getMessage() + " while parsing: " + eldResource, e);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new X4OLanguageModuleLoaderException(this,e.getMessage()+" while parsing: "+eldResource,e);
|
throw new X4OLanguageModuleLoaderException(this, e.getMessage() + " while parsing: " + eldResource, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static X4OLanguage getLanguage(X4OLanguageSession context) {
|
public static X4OLanguage getLanguage(X4OLanguageSession context) {
|
||||||
ValueExpression ee = context.getExpressionLanguageFactory().createValueExpression(context.getExpressionLanguageContext(),"${"+EL_PARENT_LANGUAGE+"}", X4OLanguage.class);
|
ValueExpression ee = context.getExpressionLanguageFactory().createValueExpression(context.getExpressionLanguageContext(),
|
||||||
return (X4OLanguage)ee.getValue(context.getExpressionLanguageContext());
|
"${" + EL_PARENT_LANGUAGE + "}", X4OLanguage.class);
|
||||||
|
return (X4OLanguage) ee.getValue(context.getExpressionLanguageContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static X4OLanguageModule getLanguageModule(X4OLanguageSession context) {
|
public static X4OLanguageModule getLanguageModule(X4OLanguageSession context) {
|
||||||
ValueExpression ee = context.getExpressionLanguageFactory().createValueExpression(context.getExpressionLanguageContext(),"${"+EL_PARENT_LANGUAGE_MODULE+"}", X4OLanguageModule.class);
|
ValueExpression ee = context.getExpressionLanguageFactory().createValueExpression(context.getExpressionLanguageContext(),
|
||||||
return (X4OLanguageModule)ee.getValue(context.getExpressionLanguageContext());
|
"${" + EL_PARENT_LANGUAGE_MODULE + "}", X4OLanguageModule.class);
|
||||||
|
return (X4OLanguageModule) ee.getValue(context.getExpressionLanguageContext());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,8 +51,7 @@ import org.x4o.xml.lang.X4OLanguageModuleLocal;
|
||||||
import org.x4o.xml.lang.X4OLanguageSession;
|
import org.x4o.xml.lang.X4OLanguageSession;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EldModuleLoaderCore provides a few basic elements for the core eld x4o
|
* EldModuleLoaderCore provides a few basic elements for the core eld x4o language.
|
||||||
* language.
|
|
||||||
*
|
*
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Jan 11, 2009
|
* @version 1.0 Jan 11, 2009
|
||||||
|
|
@ -89,11 +88,11 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader {
|
||||||
* @param session The session to run in.
|
* @param session The session to run in.
|
||||||
* @param language The langauge to load for.
|
* @param language The langauge to load for.
|
||||||
* @param languageModule The module to load it in.
|
* @param languageModule The module to load it in.
|
||||||
* @see org.x4o.xml.lang.X4OLanguageModuleLoader#loadLanguageModule(org.x4o.xml.lang.X4OLanguageLocal,
|
* @see org.x4o.xml.lang.X4OLanguageModuleLoader#loadLanguageModule(org.x4o.xml.lang.X4OLanguageLocal, org.x4o.xml.lang.X4OLanguageModuleLocald)
|
||||||
* org.x4o.xml.lang.X4OLanguageModuleLocald)
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void loadLanguageModule(X4OLanguageSession session, X4OLanguageLocal language, X4OLanguageModuleLocal languageModule) throws X4OLanguageModuleLoaderException {
|
public void loadLanguageModule(X4OLanguageSession session, X4OLanguageLocal language, X4OLanguageModuleLocal languageModule)
|
||||||
|
throws X4OLanguageModuleLoaderException {
|
||||||
|
|
||||||
// Config module meta data
|
// Config module meta data
|
||||||
configLanguageModule(languageModule);
|
configLanguageModule(languageModule);
|
||||||
|
|
@ -113,7 +112,8 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader {
|
||||||
// Create cel-root namespace in language for schema support
|
// Create cel-root namespace in language for schema support
|
||||||
ElementNamespace namespaceRoot = createNamespaceContext(language, CEL_ROOT, CEL_ROOT_URI, CEL_ROOT_XSD_URI, CEL_ROOT_XSD_FILE, CEL_ROOT);
|
ElementNamespace namespaceRoot = createNamespaceContext(language, CEL_ROOT, CEL_ROOT_URI, CEL_ROOT_XSD_URI, CEL_ROOT_XSD_FILE, CEL_ROOT);
|
||||||
namespaceRoot.setLanguageRoot(true); // Only define single language root so xsd is (mostly) not cicle import.
|
namespaceRoot.setLanguageRoot(true); // Only define single language root so xsd is (mostly) not cicle import.
|
||||||
ElementClass rootElement = createElementClass(language, "module", language.getLanguageConfiguration().getDefaultElementLanguageModule(), ModuleElement.class, "The module tag is the root xml element for ELD language.");
|
ElementClass rootElement = createElementClass(language, "module", language.getLanguageConfiguration().getDefaultElementLanguageModule(),
|
||||||
|
ModuleElement.class, "The module tag is the root xml element for ELD language.");
|
||||||
rootElement.addElementClassAttribute(createElementClassAttribute(language, "id", true, null));
|
rootElement.addElementClassAttribute(createElementClassAttribute(language, "id", true, null));
|
||||||
rootElement.addElementClassAttribute(createElementClassAttribute(language, "providerHost", true, null));
|
rootElement.addElementClassAttribute(createElementClassAttribute(language, "providerHost", true, null));
|
||||||
namespaceRoot.addElementClass(rootElement);
|
namespaceRoot.addElementClass(rootElement);
|
||||||
|
|
@ -130,14 +130,16 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader {
|
||||||
private void configElementClasses(X4OLanguage language, ElementNamespace namespace) throws X4OLanguageModuleLoaderException {
|
private void configElementClasses(X4OLanguage language, ElementNamespace namespace) throws X4OLanguageModuleLoaderException {
|
||||||
ElementClass ec = null;
|
ElementClass ec = null;
|
||||||
|
|
||||||
namespace.addElementClass(createElementClass(language, "attribute", language.getLanguageConfiguration().getDefaultElementClassAttribute(), null, "Defines xml element attribute."));
|
namespace.addElementClass(createElementClass(language, "attribute", language.getLanguageConfiguration().getDefaultElementClassAttribute(), null,
|
||||||
|
"Defines xml element attribute."));
|
||||||
|
|
||||||
ec = createElementClass(language, "attributeAlias", null, AttributeAliasElement.class, "Adds an attribute alias.");
|
ec = createElementClass(language, "attributeAlias", null, AttributeAliasElement.class, "Adds an attribute alias.");
|
||||||
ec.addElementClassAttribute(createElementClassAttribute(language, "name", true, null));
|
ec.addElementClassAttribute(createElementClassAttribute(language, "name", true, null));
|
||||||
ec.addElementParent(CEL_CORE_URI, "attribute");
|
ec.addElementParent(CEL_CORE_URI, "attribute");
|
||||||
namespace.addElementClass(ec);
|
namespace.addElementClass(ec);
|
||||||
|
|
||||||
namespace.addElementClass(createElementClass(language, "classConverter", ClassConverter.class, null, "Converts string attribute to java class instance."));
|
namespace.addElementClass(
|
||||||
|
createElementClass(language, "classConverter", ClassConverter.class, null, "Converts string attribute to java class instance."));
|
||||||
|
|
||||||
ec = createElementClass(language, "namespace", language.getLanguageConfiguration().getDefaultElementNamespace(), null, "Defines an xml namespace.");
|
ec = createElementClass(language, "namespace", language.getLanguageConfiguration().getDefaultElementNamespace(), null, "Defines an xml namespace.");
|
||||||
ec.addElementClassAttribute(createElementClassAttribute(language, "uri", true, null));
|
ec.addElementClassAttribute(createElementClassAttribute(language, "uri", true, null));
|
||||||
|
|
@ -148,7 +150,8 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader {
|
||||||
ec.addElementClassAttribute(createElementClassAttribute(language, "elementClass", false, new ClassConverter()));
|
ec.addElementClassAttribute(createElementClassAttribute(language, "elementClass", false, new ClassConverter()));
|
||||||
namespace.addElementClass(ec);
|
namespace.addElementClass(ec);
|
||||||
|
|
||||||
ec = createElementClass(language, "elementInterface", language.getLanguageConfiguration().getDefaultElementInterface(), null, "Defines element interface class.");
|
ec = createElementClass(language, "elementInterface", language.getLanguageConfiguration().getDefaultElementInterface(), null,
|
||||||
|
"Defines element interface class.");
|
||||||
ec.addElementClassAttribute(createElementClassAttribute(language, "interfaceClass", false, new ClassConverter()));
|
ec.addElementClassAttribute(createElementClassAttribute(language, "interfaceClass", false, new ClassConverter()));
|
||||||
namespace.addElementClass(ec);
|
namespace.addElementClass(ec);
|
||||||
|
|
||||||
|
|
@ -204,7 +207,8 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader {
|
||||||
languageModule.setDescription("Core Element Language Module Loader");
|
languageModule.setDescription("Core Element Language Module Loader");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startAndAddNamespace(X4OLanguageLocal language, X4OLanguageModuleLocal languageModule, ElementNamespace namespace) throws X4OLanguageModuleLoaderException {
|
private void startAndAddNamespace(X4OLanguageLocal language, X4OLanguageModuleLocal languageModule, ElementNamespace namespace)
|
||||||
|
throws X4OLanguageModuleLoaderException {
|
||||||
try {
|
try {
|
||||||
namespace.getElementNamespaceInstanceProvider().start(language, namespace);
|
namespace.getElementNamespaceInstanceProvider().start(language, namespace);
|
||||||
} catch (ElementNamespaceInstanceProviderException e) {
|
} catch (ElementNamespaceInstanceProviderException e) {
|
||||||
|
|
@ -213,7 +217,8 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader {
|
||||||
languageModule.addElementNamespace(namespace);
|
languageModule.addElementNamespace(namespace);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ElementNamespace createNamespaceContext(X4OLanguageLocal language, String id, String uri, String schemaUri, String schemaResource, String schemaPrefix) throws X4OLanguageModuleLoaderException {
|
private ElementNamespace createNamespaceContext(X4OLanguageLocal language, String id, String uri, String schemaUri, String schemaResource,
|
||||||
|
String schemaPrefix) throws X4OLanguageModuleLoaderException {
|
||||||
logger.finer("Creating " + language.getLanguageName() + " namespace.");
|
logger.finer("Creating " + language.getLanguageName() + " namespace.");
|
||||||
ElementNamespace namespace;
|
ElementNamespace namespace;
|
||||||
try {
|
try {
|
||||||
|
|
@ -222,7 +227,8 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader {
|
||||||
throw new X4OLanguageModuleLoaderException(this, e.getMessage(), e);
|
throw new X4OLanguageModuleLoaderException(this, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
namespace.setElementNamespaceInstanceProvider(X4OLanguageClassLoader.newInstance(ElementNamespaceInstanceProvider.class, language.getLanguageConfiguration().getDefaultElementNamespaceInstanceProvider()));
|
namespace.setElementNamespaceInstanceProvider(X4OLanguageClassLoader.newInstance(ElementNamespaceInstanceProvider.class,
|
||||||
|
language.getLanguageConfiguration().getDefaultElementNamespaceInstanceProvider()));
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new X4OLanguageModuleLoaderException(this, e.getMessage(), e);
|
throw new X4OLanguageModuleLoaderException(this, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
@ -234,7 +240,8 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader {
|
||||||
return namespace;
|
return namespace;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ElementClass createElementClass(X4OLanguage language, String tag, Class<?> objectClass, Class<?> elementClass, String description) throws X4OLanguageModuleLoaderException {
|
private ElementClass createElementClass(X4OLanguage language, String tag, Class<?> objectClass, Class<?> elementClass, String description)
|
||||||
|
throws X4OLanguageModuleLoaderException {
|
||||||
try {
|
try {
|
||||||
ElementClass result = X4OLanguageClassLoader.newInstance(ElementClass.class, language.getLanguageConfiguration().getDefaultElementClass());
|
ElementClass result = X4OLanguageClassLoader.newInstance(ElementClass.class, language.getLanguageConfiguration().getDefaultElementClass());
|
||||||
result.setId(tag);
|
result.setId(tag);
|
||||||
|
|
@ -257,9 +264,11 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader {
|
||||||
* @return The new ElementClassAttribute instance.
|
* @return The new ElementClassAttribute instance.
|
||||||
* @throws X4OLanguageModuleLoaderException When class could not be created.
|
* @throws X4OLanguageModuleLoaderException When class could not be created.
|
||||||
*/
|
*/
|
||||||
private ElementClassAttribute createElementClassAttribute(X4OLanguage language, String name, boolean required, ObjectConverter converter) throws X4OLanguageModuleLoaderException {
|
private ElementClassAttribute createElementClassAttribute(X4OLanguage language, String name, boolean required, ObjectConverter converter)
|
||||||
|
throws X4OLanguageModuleLoaderException {
|
||||||
try {
|
try {
|
||||||
ElementClassAttribute result = X4OLanguageClassLoader.newInstance(ElementClassAttribute.class, language.getLanguageConfiguration().getDefaultElementClassAttribute());
|
ElementClassAttribute result = X4OLanguageClassLoader.newInstance(ElementClassAttribute.class,
|
||||||
|
language.getLanguageConfiguration().getDefaultElementClassAttribute());
|
||||||
result.setId(name);
|
result.setId(name);
|
||||||
if (required) {
|
if (required) {
|
||||||
result.setRequired(required);
|
result.setRequired(required);
|
||||||
|
|
|
||||||
|
|
@ -37,14 +37,14 @@ import org.x4o.xml.lang.task.X4OLanguageTaskExecutor;
|
||||||
*/
|
*/
|
||||||
public class EldDocLanguageTask extends AbstractX4OLanguageTask {
|
public class EldDocLanguageTask extends AbstractX4OLanguageTask {
|
||||||
|
|
||||||
public static final String TASK_ID = "eld-doc";
|
public static final String TASK_ID = "eld-doc";
|
||||||
private static final String TASK_NAME = "ELD DOC Writer Task";
|
private static final String TASK_NAME = "ELD DOC Writer Task";
|
||||||
private static final String TASK_DESC = "Writes out the documentation of the language elements.";
|
private static final String TASK_DESC = "Writes out the documentation of the language elements.";
|
||||||
|
|
||||||
public EldDocLanguageTask() {
|
public EldDocLanguageTask() {
|
||||||
super(TASK_ID,TASK_NAME,TASK_DESC,EldDocWriter.DEFAULT_PROPERTY_CONFIG);
|
super(TASK_ID, TASK_NAME, TASK_DESC, EldDocWriter.DEFAULT_PROPERTY_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes this language task.
|
* Executes this language task.
|
||||||
*/
|
*/
|
||||||
|
|
@ -52,9 +52,9 @@ public class EldDocLanguageTask extends AbstractX4OLanguageTask {
|
||||||
return new X4OLanguageTaskExecutor() {
|
return new X4OLanguageTaskExecutor() {
|
||||||
public void execute(X4OLanguage language) throws X4OLanguageTaskException {
|
public void execute(X4OLanguage language) throws X4OLanguageTaskException {
|
||||||
try {
|
try {
|
||||||
new EldDocWriter(language,config).writeDocumentation();
|
new EldDocWriter(language, config).writeDocumentation();
|
||||||
} catch (ElementException e) {
|
} catch (ElementException e) {
|
||||||
throw new X4OLanguageTaskException(config,e.getMessage(),e);
|
throw new X4OLanguageTaskException(config, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,8 @@ import org.x4o.xml.lang.X4OLanguageSession;
|
||||||
* @version 1.0 Aug 26, 2010
|
* @version 1.0 Aug 26, 2010
|
||||||
*/
|
*/
|
||||||
public class EldDocWriter {
|
public class EldDocWriter {
|
||||||
|
|
||||||
|
//@formatter:off
|
||||||
private final static String DEFAULT_NAME = "X4O ELD DOC";
|
private final static String DEFAULT_NAME = "X4O ELD DOC";
|
||||||
private final static String DEFAULT_DESCRIPTION = "X4O Meta Language Documentation.";
|
private final static String DEFAULT_DESCRIPTION = "X4O Meta Language Documentation.";
|
||||||
|
|
||||||
|
|
@ -116,26 +117,29 @@ public class EldDocWriter {
|
||||||
new PropertyConfigItem(PAGE_PRINT_HELP,Boolean.class,true)
|
new PropertyConfigItem(PAGE_PRINT_HELP,Boolean.class,true)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
//@formatter:on
|
||||||
|
|
||||||
/** The config of this writer. */
|
/** The config of this writer. */
|
||||||
private final SAX3PropertyConfig propertyConfig;
|
private final SAX3PropertyConfig propertyConfig;
|
||||||
|
|
||||||
/** The language to write doc over. */
|
/** The language to write doc over. */
|
||||||
private final X4OLanguage language;
|
private final X4OLanguage language;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an EldDocGenerator for this langauge context.
|
* Creates an EldDocGenerator for this langauge context.
|
||||||
* @param language The language to generate doc for.
|
*
|
||||||
|
* @param language The language to generate doc for.
|
||||||
*/
|
*/
|
||||||
public EldDocWriter(X4OLanguage language,SAX3PropertyConfig parentConfig) {
|
public EldDocWriter(X4OLanguage language, SAX3PropertyConfig parentConfig) {
|
||||||
this.language=language;
|
this.language = language;
|
||||||
this.propertyConfig=new SAX3PropertyConfig(DEFAULT_PROPERTY_CONFIG,PROPERTY_CONTEXT_PREFIX);
|
this.propertyConfig = new SAX3PropertyConfig(DEFAULT_PROPERTY_CONFIG, PROPERTY_CONTEXT_PREFIX);
|
||||||
this.propertyConfig.copyParentProperties(parentConfig);
|
this.propertyConfig.copyParentProperties(parentConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes the language documentation to the base path.
|
* Writes the language documentation to the base path.
|
||||||
* @throws ElementException Is thrown when error is done.
|
*
|
||||||
|
* @throws ElementException Is thrown when error is done.
|
||||||
*/
|
*/
|
||||||
public void writeDocumentation() throws ElementException {
|
public void writeDocumentation() throws ElementException {
|
||||||
try {
|
try {
|
||||||
|
|
@ -147,124 +151,163 @@ public class EldDocWriter {
|
||||||
throw new ElementException(e);
|
throw new ElementException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a fully configured ApiDco object.
|
* Creates a fully configured ApiDco object.
|
||||||
* @return The ApiDoc configured to write eld documentation.
|
*
|
||||||
|
* @return The ApiDoc configured to write eld documentation.
|
||||||
*/
|
*/
|
||||||
private MaisDoc buildLanguageDoc() {
|
private MaisDoc buildLanguageDoc() {
|
||||||
|
|
||||||
// Generic config
|
// Generic config
|
||||||
MaisDoc doc = new MaisDoc();
|
MaisDoc doc = new MaisDoc();
|
||||||
List<String> javadocLinkList = propertyConfig.getPropertyList(JAVADOC_LINK);
|
List<String> javadocLinkList = propertyConfig.getPropertyList(JAVADOC_LINK);
|
||||||
Map<String,String> javadocLinkOfflineMap = propertyConfig.getPropertyMap(JAVADOC_LINK_OFFLINE);
|
Map<String, String> javadocLinkOfflineMap = propertyConfig.getPropertyMap(JAVADOC_LINK_OFFLINE);
|
||||||
if (javadocLinkList!=null) {
|
if (javadocLinkList != null) {
|
||||||
for (String javadocUrl:javadocLinkList) {
|
for (String javadocUrl : javadocLinkList) {
|
||||||
doc.addRemoteClass(new MaisDocRemoteClass(javadocUrl));
|
doc.addRemoteClass(new MaisDocRemoteClass(javadocUrl));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (javadocLinkOfflineMap!=null) {
|
if (javadocLinkOfflineMap != null) {
|
||||||
for (Map.Entry<String,String> offlineLink:javadocLinkOfflineMap.entrySet()) {
|
for (Map.Entry<String, String> offlineLink : javadocLinkOfflineMap.entrySet()) {
|
||||||
doc.addRemoteClass(new MaisDocRemoteClass(offlineLink.getKey(),offlineLink.getValue()));
|
doc.addRemoteClass(new MaisDocRemoteClass(offlineLink.getKey(), offlineLink.getValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
doc.setName( propertyConfig.getPropertyString(DOC_NAME, DEFAULT_NAME));
|
doc.setName(propertyConfig.getPropertyString(DOC_NAME, DEFAULT_NAME));
|
||||||
doc.setDescription( propertyConfig.getPropertyString(DOC_DESCRIPTION, DEFAULT_DESCRIPTION));
|
doc.setDescription(propertyConfig.getPropertyString(DOC_DESCRIPTION, DEFAULT_DESCRIPTION));
|
||||||
doc.setDocAbout( propertyConfig.getPropertyString(DOC_ABOUT, createLanguageAbout()));
|
doc.setDocAbout(propertyConfig.getPropertyString(DOC_ABOUT, createLanguageAbout()));
|
||||||
doc.setDocCopyright( propertyConfig.getPropertyString(DOC_COPYRIGHT, createLanguageCopyright()));
|
doc.setDocCopyright(propertyConfig.getPropertyString(DOC_COPYRIGHT, createLanguageCopyright()));
|
||||||
doc.setDocPageSubTitle( propertyConfig.getPropertyString(DOC_PAGE_SUB_TITLE, createPageSubTitle()));
|
doc.setDocPageSubTitle(propertyConfig.getPropertyString(DOC_PAGE_SUB_TITLE, createPageSubTitle()));
|
||||||
doc.setMetaStyleSheetThema( propertyConfig.getPropertyString(META_STYLESHEET_THEMA));
|
doc.setMetaStyleSheetThema(propertyConfig.getPropertyString(META_STYLESHEET_THEMA));
|
||||||
doc.setMetaStyleSheet( propertyConfig.getPropertyFile(META_STYLESHEET));
|
doc.setMetaStyleSheet(propertyConfig.getPropertyFile(META_STYLESHEET));
|
||||||
List<String> keywords = propertyConfig.getPropertyList(META_KEYWORDS);
|
List<String> keywords = propertyConfig.getPropertyList(META_KEYWORDS);
|
||||||
if (keywords==null) {
|
if (keywords == null) {
|
||||||
keywords = createLanguageKeywords();
|
keywords = createLanguageKeywords();
|
||||||
}
|
}
|
||||||
doc.addMetaKeywordAll(keywords);
|
doc.addMetaKeywordAll(keywords);
|
||||||
doc.setNoFrameAllName("All Elements");
|
doc.setNoFrameAllName("All Elements");
|
||||||
doc.setFrameNavPrintParent(true);
|
doc.setFrameNavPrintParent(true);
|
||||||
doc.setFrameNavPrintParentId(true);
|
doc.setFrameNavPrintParentId(true);
|
||||||
doc.setGroupTypeName("summary", "Summary",1);
|
doc.setGroupTypeName("summary", "Summary", 1);
|
||||||
doc.setGroupTypeName("overview", "Overview",2);
|
doc.setGroupTypeName("overview", "Overview", 2);
|
||||||
doc.setFrameNavConceptClass(ElementClass.class);
|
doc.setFrameNavConceptClass(ElementClass.class);
|
||||||
|
|
||||||
doc.addTreeNodePageModeClass(X4OLanguageSession.class);
|
doc.addTreeNodePageModeClass(X4OLanguageSession.class);
|
||||||
doc.addTreeNodePageModeClass(X4OLanguageModule.class);
|
doc.addTreeNodePageModeClass(X4OLanguageModule.class);
|
||||||
doc.addTreeNodePageModeClass(ElementInterface.class);
|
doc.addTreeNodePageModeClass(ElementInterface.class);
|
||||||
doc.addTreeNodePageModeClass(ElementNamespace.class);
|
doc.addTreeNodePageModeClass(ElementNamespace.class);
|
||||||
|
|
||||||
doc.addAnnotatedClasses(EldDocWriterLanguage.class);
|
doc.addAnnotatedClasses(EldDocWriterLanguage.class);
|
||||||
doc.addAnnotatedClasses(EldDocWriterLanguageModule.class);
|
doc.addAnnotatedClasses(EldDocWriterLanguageModule.class);
|
||||||
doc.addAnnotatedClasses(EldDocWriterElementClass.class);
|
doc.addAnnotatedClasses(EldDocWriterElementClass.class);
|
||||||
doc.addAnnotatedClasses(EldDocWriterElementNamespace.class);
|
doc.addAnnotatedClasses(EldDocWriterElementNamespace.class);
|
||||||
doc.addAnnotatedClasses(EldDocWriterElementInterface.class);
|
doc.addAnnotatedClasses(EldDocWriterElementInterface.class);
|
||||||
|
|
||||||
MaisDocConcept adcRoot = doc.addConcept(new MaisDocConcept(null,C_CONTEXT,X4OLanguage.class));
|
MaisDocConcept adcRoot = doc.addConcept(new MaisDocConcept(null, C_CONTEXT, X4OLanguage.class));
|
||||||
MaisDocConcept adcMod = doc.addConcept(new MaisDocConcept(adcRoot,C_MODULE,X4OLanguageModule.class));
|
MaisDocConcept adcMod = doc.addConcept(new MaisDocConcept(adcRoot, C_MODULE, X4OLanguageModule.class));
|
||||||
MaisDocConcept adcIface = doc.addConcept(new MaisDocConcept(adcMod,C_INTERFACE,ElementInterface.class));
|
MaisDocConcept adcIface = doc.addConcept(new MaisDocConcept(adcMod, C_INTERFACE, ElementInterface.class));
|
||||||
MaisDocConcept adcNs = doc.addConcept(new MaisDocConcept(adcMod,C_NAMESPACE,ElementNamespace.class));
|
MaisDocConcept adcNs = doc.addConcept(new MaisDocConcept(adcMod, C_NAMESPACE, ElementNamespace.class));
|
||||||
MaisDocConcept adcEc = doc.addConcept(new MaisDocConcept(adcNs,C_ELEMENT,ElementClass.class));
|
MaisDocConcept adcEc = doc.addConcept(new MaisDocConcept(adcNs, C_ELEMENT, ElementClass.class));
|
||||||
|
|
||||||
// mm maybe redo something here
|
// mm maybe redo something here
|
||||||
adcMod.addChildConcept(new MaisDocConcept(adcMod,CC_ATTRIBUTE_H,ElementNamespaceAttribute.class));
|
adcMod.addChildConcept(new MaisDocConcept(adcMod, CC_ATTRIBUTE_H, ElementNamespaceAttribute.class));
|
||||||
adcMod.addChildConcept(new MaisDocConcept(adcMod,CC_CONFIGURATOR_G,ElementConfiguratorGlobal.class));
|
adcMod.addChildConcept(new MaisDocConcept(adcMod, CC_CONFIGURATOR_G, ElementConfiguratorGlobal.class));
|
||||||
adcMod.addChildConcept(new MaisDocConcept(adcMod,CC_BINDING,ElementBindingHandler.class));
|
adcMod.addChildConcept(new MaisDocConcept(adcMod, CC_BINDING, ElementBindingHandler.class));
|
||||||
adcIface.addChildConcept(new MaisDocConcept(adcMod,CC_ATTRIBUTE,ElementClassAttribute.class));
|
adcIface.addChildConcept(new MaisDocConcept(adcMod, CC_ATTRIBUTE, ElementClassAttribute.class));
|
||||||
adcIface.addChildConcept(new MaisDocConcept(adcMod,CC_CONFIGURATOR,ElementConfigurator.class));
|
adcIface.addChildConcept(new MaisDocConcept(adcMod, CC_CONFIGURATOR, ElementConfigurator.class));
|
||||||
adcEc.addChildConcept(new MaisDocConcept(adcEc,CC_CONFIGURATOR,ElementConfigurator.class));
|
adcEc.addChildConcept(new MaisDocConcept(adcEc, CC_CONFIGURATOR, ElementConfigurator.class));
|
||||||
adcEc.addChildConcept(new MaisDocConcept(adcEc,CC_ATTRIBUTE,ElementClassAttribute.class));
|
adcEc.addChildConcept(new MaisDocConcept(adcEc, CC_ATTRIBUTE, ElementClassAttribute.class));
|
||||||
|
|
||||||
// Non-tree pages config
|
// Non-tree pages config
|
||||||
if (propertyConfig.getPropertyBoolean(PAGE_PRINT_XTREE)) { doc.addDocPage(EldDocXTreePageWriter.createDocPage()); }
|
if (propertyConfig.getPropertyBoolean(PAGE_PRINT_XTREE)) {
|
||||||
if (propertyConfig.getPropertyBoolean(PAGE_PRINT_TREE)) { doc.addDocPage(DefaultPageWriterTree.createDocPage()); }
|
doc.addDocPage(EldDocXTreePageWriter.createDocPage());
|
||||||
if (propertyConfig.getPropertyBoolean(PAGE_PRINT_INDEX_ALL)) { doc.addDocPage(DefaultPageWriterIndexAll.createDocPage()); }
|
}
|
||||||
if (propertyConfig.getPropertyBoolean(PAGE_PRINT_HELP)) { doc.addDocPage(DefaultPageWriterHelp.createDocPage()); }
|
if (propertyConfig.getPropertyBoolean(PAGE_PRINT_TREE)) {
|
||||||
|
doc.addDocPage(DefaultPageWriterTree.createDocPage());
|
||||||
|
}
|
||||||
|
if (propertyConfig.getPropertyBoolean(PAGE_PRINT_INDEX_ALL)) {
|
||||||
|
doc.addDocPage(DefaultPageWriterIndexAll.createDocPage());
|
||||||
|
}
|
||||||
|
if (propertyConfig.getPropertyBoolean(PAGE_PRINT_HELP)) {
|
||||||
|
doc.addDocPage(DefaultPageWriterHelp.createDocPage());
|
||||||
|
}
|
||||||
|
|
||||||
// Doc tree config
|
// Doc tree config
|
||||||
MaisDocNode rootNode = new MaisDocNode(language,"language",getLanguageNameUpperCase()+" Language","The X4O "+getLanguageNameUpperCase()+" Language");
|
MaisDocNode rootNode = new MaisDocNode(language, "language", getLanguageNameUpperCase() + " Language",
|
||||||
|
"The X4O " + getLanguageNameUpperCase() + " Language");
|
||||||
doc.setRootNode(rootNode);
|
doc.setRootNode(rootNode);
|
||||||
for (X4OLanguageModule mod:language.getLanguageModules()) { MaisDocNode modNode = rootNode.addNode(createNodeLanguageModule(mod));
|
for (X4OLanguageModule mod : language.getLanguageModules()) {
|
||||||
for (ElementBindingHandler bind:mod.getElementBindingHandlers()) { modNode.addNode(createNodeElementBindingHandler(bind)); }
|
MaisDocNode modNode = rootNode.addNode(createNodeLanguageModule(mod));
|
||||||
for (ElementConfiguratorGlobal conf:mod.getElementConfiguratorGlobals()) { modNode.addNode(createNodeElementConfiguratorGlobal(conf)); }
|
for (ElementBindingHandler bind : mod.getElementBindingHandlers()) {
|
||||||
for (ElementInterface iface:mod.getElementInterfaces()) { MaisDocNode ifaceNode = modNode.addNode(createNodeElementInterface(iface));
|
modNode.addNode(createNodeElementBindingHandler(bind));
|
||||||
for (ElementClassAttribute eca:iface.getElementClassAttributes()) { ifaceNode.addNode(createNodeElementClassAttribute(eca)); }
|
}
|
||||||
for (ElementConfigurator conf:iface.getElementConfigurators()) { ifaceNode.addNode(createNodeElementConfigurator(conf)); } }
|
for (ElementConfiguratorGlobal conf : mod.getElementConfiguratorGlobals()) {
|
||||||
for (ElementNamespace ns:mod.getElementNamespaces()) { MaisDocNode nsNode = modNode.addNode(createNodeElementNamespace(ns));
|
modNode.addNode(createNodeElementConfiguratorGlobal(conf));
|
||||||
for (ElementNamespaceAttribute attr:ns.getElementNamespaceAttributes()) { nsNode.addNode(createNodeElementNamespaceAttribute(attr)); }
|
}
|
||||||
for (ElementClass ec:ns.getElementClasses()) { MaisDocNode ecNode = nsNode.addNode(createNodeElementClass(ec));
|
for (ElementInterface iface : mod.getElementInterfaces()) {
|
||||||
for (ElementClassAttribute eca:ec.getElementClassAttributes()) { ecNode.addNode(createNodeElementClassAttribute(eca)); }
|
MaisDocNode ifaceNode = modNode.addNode(createNodeElementInterface(iface));
|
||||||
for (ElementConfigurator conf:ec.getElementConfigurators()) { ecNode.addNode(createNodeElementConfigurator(conf)); } } }
|
for (ElementClassAttribute eca : iface.getElementClassAttributes()) {
|
||||||
|
ifaceNode.addNode(createNodeElementClassAttribute(eca));
|
||||||
|
}
|
||||||
|
for (ElementConfigurator conf : iface.getElementConfigurators()) {
|
||||||
|
ifaceNode.addNode(createNodeElementConfigurator(conf));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (ElementNamespace ns : mod.getElementNamespaces()) {
|
||||||
|
MaisDocNode nsNode = modNode.addNode(createNodeElementNamespace(ns));
|
||||||
|
for (ElementNamespaceAttribute attr : ns.getElementNamespaceAttributes()) {
|
||||||
|
nsNode.addNode(createNodeElementNamespaceAttribute(attr));
|
||||||
|
}
|
||||||
|
for (ElementClass ec : ns.getElementClasses()) {
|
||||||
|
MaisDocNode ecNode = nsNode.addNode(createNodeElementClass(ec));
|
||||||
|
for (ElementClassAttribute eca : ec.getElementClassAttributes()) {
|
||||||
|
ecNode.addNode(createNodeElementClassAttribute(eca));
|
||||||
|
}
|
||||||
|
for (ElementConfigurator conf : ec.getElementConfigurators()) {
|
||||||
|
ecNode.addNode(createNodeElementConfigurator(conf));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
private MaisDocNode createNodeElementBindingHandler(ElementBindingHandler bind) {
|
private MaisDocNode createNodeElementBindingHandler(ElementBindingHandler bind) {
|
||||||
return new MaisDocNode(bind,bind.getId(),bind.getId(),bind.getDescription());
|
return new MaisDocNode(bind, bind.getId(), bind.getId(), bind.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
private MaisDocNode createNodeElementNamespaceAttribute(ElementNamespaceAttribute attr) {
|
private MaisDocNode createNodeElementNamespaceAttribute(ElementNamespaceAttribute attr) {
|
||||||
return new MaisDocNode(attr,attr.getId(),attr.getId(),attr.getDescription());
|
return new MaisDocNode(attr, attr.getId(), attr.getId(), attr.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
private MaisDocNode createNodeElementConfiguratorGlobal(ElementConfiguratorGlobal conf) {
|
private MaisDocNode createNodeElementConfiguratorGlobal(ElementConfiguratorGlobal conf) {
|
||||||
return new MaisDocNode(conf,conf.getId(),conf.getId(),conf.getDescription());
|
return new MaisDocNode(conf, conf.getId(), conf.getId(), conf.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
private MaisDocNode createNodeElementConfigurator(ElementConfigurator conf) {
|
private MaisDocNode createNodeElementConfigurator(ElementConfigurator conf) {
|
||||||
return new MaisDocNode(conf,conf.getId(),conf.getId(),conf.getDescription());
|
return new MaisDocNode(conf, conf.getId(), conf.getId(), conf.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
private MaisDocNode createNodeLanguageModule(X4OLanguageModule mod) {
|
private MaisDocNode createNodeLanguageModule(X4OLanguageModule mod) {
|
||||||
return new MaisDocNode(mod,mod.getId(),mod.getId(),mod.getDescription());
|
return new MaisDocNode(mod, mod.getId(), mod.getId(), mod.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
private MaisDocNode createNodeElementInterface(ElementInterface iface) {
|
private MaisDocNode createNodeElementInterface(ElementInterface iface) {
|
||||||
return new MaisDocNode(iface,iface.getId(),iface.getId(),iface.getDescription());
|
return new MaisDocNode(iface, iface.getId(), iface.getId(), iface.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
private MaisDocNode createNodeElementNamespace(ElementNamespace ns) {
|
private MaisDocNode createNodeElementNamespace(ElementNamespace ns) {
|
||||||
return new MaisDocNode(ns,ns.getId(),ns.getUri(),ns.getDescription());
|
return new MaisDocNode(ns, ns.getId(), ns.getUri(), ns.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
private MaisDocNode createNodeElementClass(ElementClass ec) {
|
private MaisDocNode createNodeElementClass(ElementClass ec) {
|
||||||
return new MaisDocNode(ec,ec.getId(),ec.getId(),ec.getDescription());
|
return new MaisDocNode(ec, ec.getId(), ec.getId(), ec.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
private MaisDocNode createNodeElementClassAttribute(ElementClassAttribute eca) {
|
private MaisDocNode createNodeElementClassAttribute(ElementClassAttribute eca) {
|
||||||
return new MaisDocNode(eca,eca.getId(),eca.getId(),eca.getDescription());
|
return new MaisDocNode(eca, eca.getId(), eca.getId(), eca.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
private String createPageSubTitle() {
|
private String createPageSubTitle() {
|
||||||
StringBuilder buf = new StringBuilder(100);
|
StringBuilder buf = new StringBuilder(100);
|
||||||
buf.append(language.getLanguageName());
|
buf.append(language.getLanguageName());
|
||||||
|
|
@ -273,7 +316,7 @@ public class EldDocWriter {
|
||||||
buf.append(" API");
|
buf.append(" API");
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String createLanguageAbout() {
|
private String createLanguageAbout() {
|
||||||
StringBuilder buf = new StringBuilder(100);
|
StringBuilder buf = new StringBuilder(100);
|
||||||
buf.append("XML X4O Language\n");
|
buf.append("XML X4O Language\n");
|
||||||
|
|
@ -282,7 +325,7 @@ public class EldDocWriter {
|
||||||
buf.append(language.getLanguageVersion());
|
buf.append(language.getLanguageVersion());
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String createLanguageCopyright() {
|
private String createLanguageCopyright() {
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
StringBuilder buf = new StringBuilder(100);
|
StringBuilder buf = new StringBuilder(100);
|
||||||
|
|
@ -294,7 +337,7 @@ public class EldDocWriter {
|
||||||
buf.append("All Rights Reserved.");
|
buf.append("All Rights Reserved.");
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> createLanguageKeywords() {
|
private List<String> createLanguageKeywords() {
|
||||||
List<String> keywords = new ArrayList<String>(10);
|
List<String> keywords = new ArrayList<String>(10);
|
||||||
keywords.add(language.getLanguageName());
|
keywords.add(language.getLanguageName());
|
||||||
|
|
@ -307,7 +350,7 @@ public class EldDocWriter {
|
||||||
keywords.add("documentation");
|
keywords.add("documentation");
|
||||||
return keywords;
|
return keywords;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getLanguageNameUpperCase() {
|
private String getLanguageNameUpperCase() {
|
||||||
return language.getLanguageName().toUpperCase();
|
return language.getLanguageName().toUpperCase();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,15 +50,17 @@ import org.x4o.xml.lang.X4OLanguageModule;
|
||||||
* @version 1.0 May 29, 2013
|
* @version 1.0 May 29, 2013
|
||||||
*/
|
*/
|
||||||
public class EldDocWriterElementClass implements MaisDocContentPrinter {
|
public class EldDocWriterElementClass implements MaisDocContentPrinter {
|
||||||
|
|
||||||
@MaisDocNodeDataConfiguratorMethod(targetClasses={ElementClass.class})
|
@MaisDocNodeDataConfiguratorMethod(targetClasses = { ElementClass.class })
|
||||||
public void configNavBar(MaisDoc doc,MaisDocNode node,MaisDocNodeData data) {
|
public void configNavBar(MaisDoc doc, MaisDocNode node, MaisDocNodeData data) {
|
||||||
/*
|
/*
|
||||||
|
//@formatter:off
|
||||||
ElementClass ec = (ElementClass)node.getUserData();
|
ElementClass ec = (ElementClass)node.getUserData();
|
||||||
Collection<ElementClassAttribute> list = ec.getElementClassAttributes();
|
Collection<ElementClassAttribute> list = ec.getElementClassAttributes();
|
||||||
if (list.isEmpty()) {
|
if (list.isEmpty()) {
|
||||||
clearHrefContentGroupAlways(doc,"summary","attribute");
|
clearHrefContentGroupAlways(doc,"summary","attribute");
|
||||||
}
|
}
|
||||||
|
//@formatter:om
|
||||||
*/
|
*/
|
||||||
clearHrefContentGroup(doc,node,"summary","attribute",ElementClassAttribute.class);
|
clearHrefContentGroup(doc,node,"summary","attribute",ElementClassAttribute.class);
|
||||||
clearHrefContentGroup(doc,node,"summary","configurator",ElementConfigurator.class);
|
clearHrefContentGroup(doc,node,"summary","configurator",ElementConfigurator.class);
|
||||||
|
|
@ -80,6 +82,7 @@ public class EldDocWriterElementClass implements MaisDocContentPrinter {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
//@formatter:off
|
||||||
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={ElementClass.class},nodeBodyOrders={2},contentGroup="attribute",contentGroupType="summary")
|
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={ElementClass.class},nodeBodyOrders={2},contentGroup="attribute",contentGroupType="summary")
|
||||||
public void writeElementX4OAttributeSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
public void writeElementX4OAttributeSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||||
ElementClass ec = (ElementClass)event.getEventObject().getUserData();
|
ElementClass ec = (ElementClass)event.getEventObject().getUserData();
|
||||||
|
|
@ -95,77 +98,79 @@ public class EldDocWriterElementClass implements MaisDocContentPrinter {
|
||||||
}
|
}
|
||||||
writer.docTableEnd();
|
writer.docTableEnd();
|
||||||
}
|
}
|
||||||
|
//@formatter:on
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={ElementClass.class},nodeBodyOrders={10},contentGroup="bean",contentGroupType="summary")
|
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { ElementClass.class }, nodeBodyOrders = {
|
||||||
|
10 }, contentGroup = "bean", contentGroupType = "summary")
|
||||||
public void writeElementObjectPropertiesSummary(MaisDocWriteEvent<MaisDocNode> event) throws IOException {
|
public void writeElementObjectPropertiesSummary(MaisDocWriteEvent<MaisDocNode> event) throws IOException {
|
||||||
ElementClass ec = (ElementClass)event.getEventObject().getUserData();
|
ElementClass ec = (ElementClass) event.getEventObject().getUserData();
|
||||||
Class<?> beanClass = ec.getObjectClass();
|
Class<?> beanClass = ec.getObjectClass();
|
||||||
if (beanClass==null) {
|
if (beanClass == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printApiTableBeanClass(event, beanClass, "Object");
|
printApiTableBeanClass(event, beanClass, "Object");
|
||||||
}
|
}
|
||||||
|
|
||||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.DESCRIPTION_LINKS,targetClasses={ElementClass.class})
|
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.DESCRIPTION_LINKS, targetClasses = { ElementClass.class })
|
||||||
public void writeElementRelationLinks(MaisDocWriteEvent<MaisDocNode> event) throws IOException {
|
public void writeElementRelationLinks(MaisDocWriteEvent<MaisDocNode> event) throws IOException {
|
||||||
MaisDocContentWriter writer = event.getWriter();
|
MaisDocContentWriter writer = event.getWriter();
|
||||||
ElementClass ec = (ElementClass)event.getEventObject().getUserData();
|
ElementClass ec = (ElementClass) event.getEventObject().getUserData();
|
||||||
ElementNamespace ns = (ElementNamespace)event.getEventObject().getParent().getUserData();
|
ElementNamespace ns = (ElementNamespace) event.getEventObject().getParent().getUserData();
|
||||||
X4OLanguageModule mod = (X4OLanguageModule)event.getEventObject().getParent().getParent().getUserData();
|
X4OLanguageModule mod = (X4OLanguageModule) event.getEventObject().getParent().getParent().getUserData();
|
||||||
X4OLanguage language = (X4OLanguage)event.getEventObject().getParent().getParent().getParent().getUserData();
|
X4OLanguage language = (X4OLanguage) event.getEventObject().getParent().getParent().getParent().getUserData();
|
||||||
|
|
||||||
// TODO: this is hacky
|
// TODO: this is hacky
|
||||||
EldDocXTreePageWriter xtree = (EldDocXTreePageWriter)event.getDoc().findDocPageById("overview-xtree").getPageWriters().get(0);
|
EldDocXTreePageWriter xtree = (EldDocXTreePageWriter) event.getDoc().findDocPageById("overview-xtree").getPageWriters().get(0);
|
||||||
|
|
||||||
TreeNode node = xtree.new TreeNode();
|
TreeNode node = xtree.new TreeNode();
|
||||||
node.language=language;
|
node.language = language;
|
||||||
node.module=mod;
|
node.module = mod;
|
||||||
node.namespace=ns;
|
node.namespace = ns;
|
||||||
node.elementClass=ec;
|
node.elementClass = ec;
|
||||||
|
|
||||||
String pathPrefix = "../../../../language/";
|
String pathPrefix = "../../../../language/";
|
||||||
|
|
||||||
List<TreeNode> parents = xtree.findParents(node);
|
List<TreeNode> parents = xtree.findParents(node);
|
||||||
writer.printTagStart(Tag.dl);
|
writer.printTagStart(Tag.dl);
|
||||||
writer.printTagCharacters(Tag.dt,"All Element Parents:");
|
writer.printTagCharacters(Tag.dt, "All Element Parents:");
|
||||||
writer.printTagStart(Tag.dd);
|
writer.printTagStart(Tag.dd);
|
||||||
if (parents.isEmpty()) {
|
if (parents.isEmpty()) {
|
||||||
writer.printCharacters("No parent.");
|
writer.printCharacters("No parent.");
|
||||||
}
|
}
|
||||||
for (int i=0;i<parents.size();i++) {
|
for (int i = 0; i < parents.size(); i++) {
|
||||||
TreeNode n = parents.get(i);
|
TreeNode n = parents.get(i);
|
||||||
String uri = toElementUri(pathPrefix, n.module, n.namespace, n.elementClass);
|
String uri = toElementUri(pathPrefix, n.module, n.namespace, n.elementClass);
|
||||||
writer.printHref(uri, n.namespace.getId()+":"+n.elementClass.getId());
|
writer.printHref(uri, n.namespace.getId() + ":" + n.elementClass.getId());
|
||||||
if (i<parents.size()-1) {
|
if (i < parents.size() - 1) {
|
||||||
writer.printCharacters(", ");
|
writer.printCharacters(", ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writer.printTagEnd(Tag.dd);
|
writer.printTagEnd(Tag.dd);
|
||||||
writer.printTagEnd(Tag.dl);
|
writer.printTagEnd(Tag.dl);
|
||||||
|
|
||||||
List<TreeNode> childs = xtree.findChilderen(node);
|
List<TreeNode> childs = xtree.findChilderen(node);
|
||||||
writer.printTagStart(Tag.dl);
|
writer.printTagStart(Tag.dl);
|
||||||
writer.printTagCharacters(Tag.dt,"All Element Childeren:");
|
writer.printTagCharacters(Tag.dt, "All Element Childeren:");
|
||||||
writer.printTagStart(Tag.dd);
|
writer.printTagStart(Tag.dd);
|
||||||
if (childs.isEmpty()) {
|
if (childs.isEmpty()) {
|
||||||
writer.printCharacters("No childeren.");
|
writer.printCharacters("No childeren.");
|
||||||
}
|
}
|
||||||
for (int i=0;i<childs.size();i++) {
|
for (int i = 0; i < childs.size(); i++) {
|
||||||
TreeNode n = childs.get(i);
|
TreeNode n = childs.get(i);
|
||||||
String uri = toElementUri(pathPrefix, n.module, n.namespace, n.elementClass);
|
String uri = toElementUri(pathPrefix, n.module, n.namespace, n.elementClass);
|
||||||
writer.printHref(uri, n.namespace.getId()+":"+n.elementClass.getId());
|
writer.printHref(uri, n.namespace.getId() + ":" + n.elementClass.getId());
|
||||||
if (i<childs.size()-1) {
|
if (i < childs.size() - 1) {
|
||||||
writer.printCharacters(", ");
|
writer.printCharacters(", ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writer.printTagEnd(Tag.dd);
|
writer.printTagEnd(Tag.dd);
|
||||||
writer.printTagEnd(Tag.dl);
|
writer.printTagEnd(Tag.dl);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String toElementUri(String pathPrefix,X4OLanguageModule mod,ElementNamespace namespace,ElementClass ec) {
|
private String toElementUri(String pathPrefix, X4OLanguageModule mod, ElementNamespace namespace, ElementClass ec) {
|
||||||
StringBuilder buf = new StringBuilder(100);
|
StringBuilder buf = new StringBuilder(100);
|
||||||
if (pathPrefix!=null) {
|
if (pathPrefix != null) {
|
||||||
buf.append(pathPrefix);
|
buf.append(pathPrefix);
|
||||||
}
|
}
|
||||||
buf.append(MaisDocContentWriter.toSafeUri(mod.getId()));
|
buf.append(MaisDocContentWriter.toSafeUri(mod.getId()));
|
||||||
|
|
|
||||||
|
|
@ -45,32 +45,35 @@ import org.xml.sax.SAXException;
|
||||||
* @version 1.0 Aug 17, 2013
|
* @version 1.0 Aug 17, 2013
|
||||||
*/
|
*/
|
||||||
public class EldDocWriterElementInterface implements MaisDocContentPrinter {
|
public class EldDocWriterElementInterface implements MaisDocContentPrinter {
|
||||||
|
|
||||||
@MaisDocNodeDataConfiguratorMethod(targetClasses={ElementInterface.class})
|
@MaisDocNodeDataConfiguratorMethod(targetClasses = { ElementInterface.class })
|
||||||
public void configNavBar(MaisDoc doc,MaisDocNode node,MaisDocNodeData data) {
|
public void configNavBar(MaisDoc doc, MaisDocNode node, MaisDocNodeData data) {
|
||||||
clearHrefContentGroup(doc,node,"summary","attribute",ElementClassAttribute.class);
|
clearHrefContentGroup(doc, node, "summary", "attribute", ElementClassAttribute.class);
|
||||||
clearHrefContentGroup(doc,node,"summary","binding",ElementBindingHandler.class);
|
clearHrefContentGroup(doc, node, "summary", "binding", ElementBindingHandler.class);
|
||||||
clearHrefContentGroup(doc,node,"summary","configurator",ElementConfigurator.class);
|
clearHrefContentGroup(doc, node, "summary", "configurator", ElementConfigurator.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { ElementInterface.class }, nodeBodyOrders = {
|
||||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={ElementInterface.class},nodeBodyOrders={1},contentGroup="interface",contentGroupType="summary")
|
1 }, contentGroup = "interface", contentGroupType = "summary")
|
||||||
public void writeElementNamespaceBeanProperties(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
public void writeElementNamespaceBeanProperties(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||||
printApiTableBean(event,"Interface","description");
|
printApiTableBean(event, "Interface", "description");
|
||||||
}
|
}
|
||||||
|
|
||||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={ElementInterface.class},nodeBodyOrders={2},contentGroup="attribute",contentGroupType="summary")
|
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { ElementInterface.class }, nodeBodyOrders = {
|
||||||
|
2 }, contentGroup = "attribute", contentGroupType = "summary")
|
||||||
public void writeElementClassAttribute(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
public void writeElementClassAttribute(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||||
printApiTable(event,"Element Class Attribute Summary",ElementClassAttribute.class);
|
printApiTable(event, "Element Class Attribute Summary", ElementClassAttribute.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={ElementInterface.class},nodeBodyOrders={3},contentGroup="binding",contentGroupType="summary")
|
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { ElementInterface.class }, nodeBodyOrders = {
|
||||||
|
3 }, contentGroup = "binding", contentGroupType = "summary")
|
||||||
public void writeElementBindingHandler(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
public void writeElementBindingHandler(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||||
printApiTable(event,"Element Binding Handler Summary",ElementBindingHandler.class);
|
printApiTable(event, "Element Binding Handler Summary", ElementBindingHandler.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={ElementInterface.class},nodeBodyOrders={4},contentGroup="configurator",contentGroupType="summary")
|
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { ElementInterface.class }, nodeBodyOrders = {
|
||||||
|
4 }, contentGroup = "configurator", contentGroupType = "summary")
|
||||||
public void writeElementConfigurator(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
public void writeElementConfigurator(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||||
printApiTable(event,"Element Configurator Summary",ElementConfigurator.class);
|
printApiTable(event, "Element Configurator Summary", ElementConfigurator.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,24 +43,26 @@ import org.xml.sax.SAXException;
|
||||||
* @version 1.0 Aug 14, 2013
|
* @version 1.0 Aug 14, 2013
|
||||||
*/
|
*/
|
||||||
public class EldDocWriterElementNamespace implements MaisDocContentPrinter {
|
public class EldDocWriterElementNamespace implements MaisDocContentPrinter {
|
||||||
|
|
||||||
@MaisDocNodeDataConfiguratorMethod(targetClasses={ElementNamespace.class})
|
@MaisDocNodeDataConfiguratorMethod(targetClasses = { ElementNamespace.class })
|
||||||
public void configNavBar(MaisDoc doc,MaisDocNode node,MaisDocNodeData data) {
|
public void configNavBar(MaisDoc doc, MaisDocNode node, MaisDocNodeData data) {
|
||||||
clearHrefContentGroup(doc,node,"summary","element",ElementClass.class);
|
clearHrefContentGroup(doc, node, "summary", "element", ElementClass.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={ElementNamespace.class},nodeBodyOrders={1},contentGroup="namespace",contentGroupType="summary")
|
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { ElementNamespace.class }, nodeBodyOrders = {
|
||||||
|
1 }, contentGroup = "namespace", contentGroupType = "summary")
|
||||||
public void writeElementNamespaceBeanProperties(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
public void writeElementNamespaceBeanProperties(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||||
printApiTableBean(event,"Namespace","description","elementClasses","elementNamespaceInstanceProvider","prefixMapping");
|
printApiTableBean(event, "Namespace", "description", "elementClasses", "elementNamespaceInstanceProvider", "prefixMapping");
|
||||||
}
|
}
|
||||||
|
|
||||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={ElementNamespace.class},nodeBodyOrders={2},contentGroup="element",contentGroupType="summary")
|
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { ElementNamespace.class }, nodeBodyOrders = {
|
||||||
|
2 }, contentGroup = "element", contentGroupType = "summary")
|
||||||
public void writeElementNamespaceElements(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
public void writeElementNamespaceElements(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||||
printApiTable(event,"Element Summary",ElementClass.class);
|
printApiTable(event, "Element Summary", ElementClass.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
//@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY_PAGE,targetClasses={ElementNamespace.class},nodeBodyOrders={2})
|
// @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY_PAGE,targetClasses={ElementNamespace.class},nodeBodyOrders={2})
|
||||||
//public void writeElementNamespaceAttributes(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
// public void writeElementNamespaceAttributes(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||||
// printApiTable(event,"Element Summary",ElementClass.class);
|
// printApiTable(event,"Element Summary",ElementClass.class);
|
||||||
//}
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,47 +47,47 @@ import org.xml.sax.SAXException;
|
||||||
*/
|
*/
|
||||||
public class EldDocWriterLanguage implements MaisDocContentPrinter {
|
public class EldDocWriterLanguage implements MaisDocContentPrinter {
|
||||||
|
|
||||||
// TODO move
|
// TODO move
|
||||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={ElementBindingHandler.class})
|
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { ElementBindingHandler.class })
|
||||||
public void writeElementBindingHandlerBean(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
public void writeElementBindingHandlerBean(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||||
printApiTableBean(event,"BindingHandler","description");
|
printApiTableBean(event, "BindingHandler", "description");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO move
|
// TODO move
|
||||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={ElementConfigurator.class})
|
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { ElementConfigurator.class })
|
||||||
public void writeElementConfiguratorBean(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
public void writeElementConfiguratorBean(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||||
printApiTableBean(event,"Configurator","description");
|
printApiTableBean(event, "Configurator", "description");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO move
|
// TODO move
|
||||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={ElementClassAttribute.class})
|
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { ElementClassAttribute.class })
|
||||||
public void writeElementClassAttributeBean(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
public void writeElementClassAttributeBean(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||||
printApiTableBean(event,"Element Class Attribute","description");
|
printApiTableBean(event, "Element Class Attribute", "description");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { X4OLanguage.class }, nodeBodyOrders = { 1 })
|
||||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={X4OLanguage.class},nodeBodyOrders={1})
|
|
||||||
public void writeLanguageSummary(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
public void writeLanguageSummary(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||||
MaisDocContentWriter writer = event.getWriter();
|
MaisDocContentWriter writer = event.getWriter();
|
||||||
MaisDocNode node = event.getEventObject();
|
MaisDocNode node = event.getEventObject();
|
||||||
X4OLanguage language = (X4OLanguage)node.getUserData();
|
X4OLanguage language = (X4OLanguage) node.getUserData();
|
||||||
int attrHandlers = 0;
|
int attrHandlers = 0;
|
||||||
int bindHandlers = 0;
|
int bindHandlers = 0;
|
||||||
int interFaces = 0;
|
int interFaces = 0;
|
||||||
int eleConfigs = 0;
|
int eleConfigs = 0;
|
||||||
int elements = 0;
|
int elements = 0;
|
||||||
int namespaces = 0;
|
int namespaces = 0;
|
||||||
for (X4OLanguageModule mod:language.getLanguageModules()) {
|
for (X4OLanguageModule mod : language.getLanguageModules()) {
|
||||||
bindHandlers += mod.getElementBindingHandlers().size();
|
bindHandlers += mod.getElementBindingHandlers().size();
|
||||||
interFaces += mod.getElementInterfaces().size();
|
interFaces += mod.getElementInterfaces().size();
|
||||||
eleConfigs += mod.getElementConfiguratorGlobals().size();
|
eleConfigs += mod.getElementConfiguratorGlobals().size();
|
||||||
for (ElementNamespace ns:mod.getElementNamespaces()) {
|
for (ElementNamespace ns : mod.getElementNamespaces()) {
|
||||||
namespaces++;
|
namespaces++;
|
||||||
elements += ns.getElementClasses().size();
|
elements += ns.getElementClasses().size();
|
||||||
attrHandlers += ns.getElementNamespaceAttributes().size();
|
attrHandlers += ns.getElementNamespaceAttributes().size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writer.docTableStart("Language Summary", "Language Stats Summary.",MaisDocContentCss.overviewSummary);
|
writer.docTableStart("Language Summary", "Language Stats Summary.", MaisDocContentCss.overviewSummary);
|
||||||
|
//@formatter:off
|
||||||
writer.docTableHeader("Name", "Value");
|
writer.docTableHeader("Name", "Value");
|
||||||
writer.docTableRow("LanguageName:", ""+language.getLanguageName(), null);
|
writer.docTableRow("LanguageName:", ""+language.getLanguageName(), null);
|
||||||
writer.docTableRow("LanguageVersion:",""+language.getLanguageVersion(),null);
|
writer.docTableRow("LanguageVersion:",""+language.getLanguageVersion(),null);
|
||||||
|
|
@ -99,23 +99,26 @@ public class EldDocWriterLanguage implements MaisDocContentPrinter {
|
||||||
writer.docTableRow("ElementBindingHandlers:",""+bindHandlers,null);
|
writer.docTableRow("ElementBindingHandlers:",""+bindHandlers,null);
|
||||||
writer.docTableRow("ElementConfigurators:",""+eleConfigs,null);
|
writer.docTableRow("ElementConfigurators:",""+eleConfigs,null);
|
||||||
writer.docTableEnd();
|
writer.docTableEnd();
|
||||||
|
//@formatter:on
|
||||||
}
|
}
|
||||||
|
|
||||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={X4OLanguage.class},nodeBodyOrders={2})
|
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { X4OLanguage.class }, nodeBodyOrders = { 2 })
|
||||||
public void writeModulesSummary(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
public void writeModulesSummary(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||||
printApiTable(event,"Module Summary",X4OLanguageModule.class);
|
printApiTable(event, "Module Summary", X4OLanguageModule.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={X4OLanguage.class},nodeBodyOrders={3})
|
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { X4OLanguage.class }, nodeBodyOrders = { 3 })
|
||||||
public void writeNamespaceSummary(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
public void writeNamespaceSummary(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||||
MaisDocContentWriter writer = event.getWriter();
|
MaisDocContentWriter writer = event.getWriter();
|
||||||
MaisDocNode node = event.getEventObject();
|
MaisDocNode node = event.getEventObject();
|
||||||
X4OLanguage language = (X4OLanguage)node.getUserData();
|
X4OLanguage language = (X4OLanguage) node.getUserData();
|
||||||
writer.docTableStart("Namespace Summary", "All Language Namespaces Overview",MaisDocContentCss.overviewSummary);
|
writer.docTableStart("Namespace Summary", "All Language Namespaces Overview", MaisDocContentCss.overviewSummary);
|
||||||
writer.docTableHeader("ID", "URI");
|
writer.docTableHeader("ID", "URI");
|
||||||
for (X4OLanguageModule mod:language.getLanguageModules()) {
|
for (X4OLanguageModule mod : language.getLanguageModules()) {
|
||||||
for (ElementNamespace ns:mod.getElementNamespaces()) {
|
for (ElementNamespace ns : mod.getElementNamespaces()) {
|
||||||
writer.docTableRowLink("language/"+MaisDocContentWriter.toSafeUri(mod.getId())+"/"+MaisDocContentWriter.toSafeUri(ns.getId())+"/index.html",ns.getId(),ns.getUri());
|
writer.docTableRowLink(
|
||||||
|
"language/" + MaisDocContentWriter.toSafeUri(mod.getId()) + "/" + MaisDocContentWriter.toSafeUri(ns.getId()) + "/index.html",
|
||||||
|
ns.getId(), ns.getUri());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writer.docTableEnd();
|
writer.docTableEnd();
|
||||||
|
|
|
||||||
|
|
@ -48,38 +48,43 @@ import org.xml.sax.SAXException;
|
||||||
* @version 1.0 Aug 10, 2013
|
* @version 1.0 Aug 10, 2013
|
||||||
*/
|
*/
|
||||||
public class EldDocWriterLanguageModule implements MaisDocContentPrinter {
|
public class EldDocWriterLanguageModule implements MaisDocContentPrinter {
|
||||||
|
|
||||||
@MaisDocNodeDataConfiguratorMethod(targetClasses={X4OLanguageModule.class})
|
@MaisDocNodeDataConfiguratorMethod(targetClasses = { X4OLanguageModule.class })
|
||||||
public void configNavBar(MaisDoc doc,MaisDocNode node,MaisDocNodeData data) {
|
public void configNavBar(MaisDoc doc, MaisDocNode node, MaisDocNodeData data) {
|
||||||
clearHrefContentGroup(doc,node,"summary","interface",ElementInterface.class);
|
clearHrefContentGroup(doc, node, "summary", "interface", ElementInterface.class);
|
||||||
clearHrefContentGroup(doc,node,"summary","binding",ElementBindingHandler.class);
|
clearHrefContentGroup(doc, node, "summary", "binding", ElementBindingHandler.class);
|
||||||
clearHrefContentGroup(doc,node,"summary","attribute",ElementNamespaceAttribute.class);
|
clearHrefContentGroup(doc, node, "summary", "attribute", ElementNamespaceAttribute.class);
|
||||||
clearHrefContentGroup(doc,node,"summary","configurator",ElementConfigurator.class);
|
clearHrefContentGroup(doc, node, "summary", "configurator", ElementConfigurator.class);
|
||||||
clearHrefContentGroup(doc,node,"summary","namespace",ElementNamespace.class);
|
clearHrefContentGroup(doc, node, "summary", "namespace", ElementNamespace.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={X4OLanguageModule.class},nodeBodyOrders={1},contentGroup="interface",contentGroupType="summary")
|
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { X4OLanguageModule.class }, nodeBodyOrders = {
|
||||||
|
1 }, contentGroup = "interface", contentGroupType = "summary")
|
||||||
public void writeInterfaceSummary(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
public void writeInterfaceSummary(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||||
printApiTable(event,"Interface Summary",ElementInterface.class);
|
printApiTable(event, "Interface Summary", ElementInterface.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={X4OLanguageModule.class},nodeBodyOrders={2},contentGroup="binding",contentGroupType="summary")
|
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { X4OLanguageModule.class }, nodeBodyOrders = {
|
||||||
|
2 }, contentGroup = "binding", contentGroupType = "summary")
|
||||||
public void writeBindingSummary(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
public void writeBindingSummary(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||||
printApiTable(event,"Binding Summary",ElementBindingHandler.class);
|
printApiTable(event, "Binding Summary", ElementBindingHandler.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={X4OLanguageModule.class},nodeBodyOrders={3},contentGroup="attribute",contentGroupType="summary")
|
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { X4OLanguageModule.class }, nodeBodyOrders = {
|
||||||
|
3 }, contentGroup = "attribute", contentGroupType = "summary")
|
||||||
public void writeAttributeSummary(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
public void writeAttributeSummary(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||||
printApiTable(event,"Attribute Summary",ElementNamespaceAttribute.class);
|
printApiTable(event, "Attribute Summary", ElementNamespaceAttribute.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={X4OLanguageModule.class},nodeBodyOrders={4},contentGroup="configurator",contentGroupType="summary")
|
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { X4OLanguageModule.class }, nodeBodyOrders = {
|
||||||
|
4 }, contentGroup = "configurator", contentGroupType = "summary")
|
||||||
public void writeConfigutorSummary(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
public void writeConfigutorSummary(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||||
printApiTable(event,"Configurator Summary",ElementConfigurator.class);
|
printApiTable(event, "Configurator Summary", ElementConfigurator.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={X4OLanguageModule.class},nodeBodyOrders={5},contentGroup="namespace",contentGroupType="summary")
|
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = { X4OLanguageModule.class }, nodeBodyOrders = {
|
||||||
|
5 }, contentGroup = "namespace", contentGroupType = "summary")
|
||||||
public void writeNamespaceSummary(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
public void writeNamespaceSummary(MaisDocWriteEvent<MaisDocNode> event) throws SAXException, IOException {
|
||||||
printApiTable(event,"Namespace Summary",ElementNamespace.class);
|
printApiTable(event, "Namespace Summary", ElementNamespace.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,66 +50,68 @@ import org.x4o.xml.lang.X4OLanguageModule;
|
||||||
* @version 1.0 May 29, 2013
|
* @version 1.0 May 29, 2013
|
||||||
*/
|
*/
|
||||||
public class EldDocXTreePageWriter extends DefaultPageWriterTree implements MaisDocPageWriter {
|
public class EldDocXTreePageWriter extends DefaultPageWriterTree implements MaisDocPageWriter {
|
||||||
|
|
||||||
public static MaisDocPage createDocPage() {
|
public static MaisDocPage createDocPage() {
|
||||||
return new MaisDocPage("overview-xtree","XTree","XTree of dom elements.",new EldDocXTreePageWriter());
|
return new MaisDocPage("overview-xtree", "XTree", "XTree of dom elements.", new EldDocXTreePageWriter());
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: rm this old tree code;
|
// TODO: rm this old tree code;
|
||||||
private void walkTree(TreeNode node,MaisDocContentWriter writer,String pathPrefix) throws IOException {
|
private void walkTree(TreeNode node, MaisDocContentWriter writer, String pathPrefix) throws IOException {
|
||||||
String href = toElementUri(pathPrefix,node.module,node.namespace,node.elementClass);
|
String href = toElementUri(pathPrefix, node.module, node.namespace, node.elementClass);
|
||||||
|
|
||||||
writer.printTagStart(Tag.ul);
|
writer.printTagStart(Tag.ul);
|
||||||
writer.printTagStart(Tag.li,"",null,"circle");
|
writer.printTagStart(Tag.li, "", null, "circle");
|
||||||
writer.printCharacters(node.namespace.getId());
|
writer.printCharacters(node.namespace.getId());
|
||||||
writer.printCharacters(":");
|
writer.printCharacters(":");
|
||||||
writer.printHref(href, node.elementClass.getId(), node.elementClass.getId(), "strong");
|
writer.printHref(href, node.elementClass.getId(), node.elementClass.getId(), "strong");
|
||||||
writer.printTagEnd(Tag.li);
|
writer.printTagEnd(Tag.li);
|
||||||
|
|
||||||
List<TreeNode> childs = findChilderen(node);
|
List<TreeNode> childs = findChilderen(node);
|
||||||
for (TreeNode child:childs) {
|
for (TreeNode child : childs) {
|
||||||
walkTree(child,writer,pathPrefix);
|
walkTree(child, writer, pathPrefix);
|
||||||
}
|
}
|
||||||
writer.printTagEnd(Tag.ul);
|
writer.printTagEnd(Tag.ul);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: remove this
|
* TODO: remove this
|
||||||
|
*
|
||||||
* @see org.x4o.maisdoc.flake.DefaultPageWriterTree#writePageContent(org.x4o.maisdoc.model.MaisDocWriteEvent)
|
* @see org.x4o.maisdoc.flake.DefaultPageWriterTree#writePageContent(org.x4o.maisdoc.model.MaisDocWriteEvent)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void writePageContent(MaisDocWriteEvent<MaisDocPage> e) throws IOException {
|
public void writePageContent(MaisDocWriteEvent<MaisDocPage> e) throws IOException {
|
||||||
//selectRootNode(e.getDoc()); // create
|
// selectRootNode(e.getDoc()); // create
|
||||||
MaisDoc doc = e.getDoc();
|
MaisDoc doc = e.getDoc();
|
||||||
X4OLanguage language = (X4OLanguage)doc.getRootNode().getUserData();
|
X4OLanguage language = (X4OLanguage) doc.getRootNode().getUserData();
|
||||||
|
|
||||||
String pathPrefix = "language/";
|
String pathPrefix = "language/";
|
||||||
|
|
||||||
// temp print old way
|
// temp print old way
|
||||||
List<TreeNode> rootNodes = new ArrayList<TreeNode>(3);
|
List<TreeNode> rootNodes = new ArrayList<TreeNode>(3);
|
||||||
for (X4OLanguageModule mod:language.getLanguageModules()) {
|
for (X4OLanguageModule mod : language.getLanguageModules()) {
|
||||||
for (ElementNamespace ns:mod.getElementNamespaces()) {
|
for (ElementNamespace ns : mod.getElementNamespaces()) {
|
||||||
if (ns.getLanguageRoot()!=null && ns.getLanguageRoot()) {
|
if (ns.getLanguageRoot() != null && ns.getLanguageRoot()) {
|
||||||
// found language root elements.
|
// found language root elements.
|
||||||
for (ElementClass ec:ns.getElementClasses()) {
|
for (ElementClass ec : ns.getElementClasses()) {
|
||||||
TreeNode node = new TreeNode();
|
TreeNode node = new TreeNode();
|
||||||
node.language=language;
|
node.language = language;
|
||||||
node.module=mod;
|
node.module = mod;
|
||||||
node.namespace=ns;
|
node.namespace = ns;
|
||||||
node.elementClass=ec;
|
node.elementClass = ec;
|
||||||
rootNodes.add(node);
|
rootNodes.add(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Collections.sort(rootNodes,new TreeNodeComparator());
|
Collections.sort(rootNodes, new TreeNodeComparator());
|
||||||
for (TreeNode rootNode:rootNodes) {
|
for (TreeNode rootNode : rootNodes) {
|
||||||
walkTree(rootNode,e.getWriter(),pathPrefix);
|
walkTree(rootNode, e.getWriter(), pathPrefix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private String toElementUri(String pathPrefix,X4OLanguageModule mod,ElementNamespace namespace,ElementClass ec) {
|
|
||||||
|
private String toElementUri(String pathPrefix, X4OLanguageModule mod, ElementNamespace namespace, ElementClass ec) {
|
||||||
StringBuilder buf = new StringBuilder(100);
|
StringBuilder buf = new StringBuilder(100);
|
||||||
if (pathPrefix!=null) {
|
if (pathPrefix != null) {
|
||||||
buf.append(pathPrefix);
|
buf.append(pathPrefix);
|
||||||
}
|
}
|
||||||
buf.append(MaisDocContentWriter.toSafeUri(mod.getId()));
|
buf.append(MaisDocContentWriter.toSafeUri(mod.getId()));
|
||||||
|
|
@ -121,9 +123,9 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements Mais
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overrided to select the dom view of the tree.
|
* Overrided to select the dom view of the tree.
|
||||||
|
*
|
||||||
* @see org.x4o.maisdoc.flake.DefaultPageWriterTree#selectRootNode(org.x4o.maisdoc.model.MaisDoc)
|
* @see org.x4o.maisdoc.flake.DefaultPageWriterTree#selectRootNode(org.x4o.maisdoc.model.MaisDoc)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -131,49 +133,47 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements Mais
|
||||||
try {
|
try {
|
||||||
return createXTree(doc);
|
return createXTree(doc);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IllegalStateException("Could not create XTree for: "+doc.getName()+" error: "+e.getMessage(),e);
|
throw new IllegalStateException("Could not create XTree for: " + doc.getName() + " error: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private MaisDocNode createXTree(MaisDoc doc) throws IOException {
|
private MaisDocNode createXTree(MaisDoc doc) throws IOException {
|
||||||
|
|
||||||
X4OLanguage language = (X4OLanguage)doc.getRootNode().getUserData();
|
X4OLanguage language = (X4OLanguage) doc.getRootNode().getUserData();
|
||||||
MaisDocNode root = new MaisDocNode(language,"root","Root","Language root");
|
MaisDocNode root = new MaisDocNode(language, "root", "Root", "Language root");
|
||||||
|
|
||||||
List<TreeNode> rootNodes = new ArrayList<TreeNode>(3);
|
List<TreeNode> rootNodes = new ArrayList<TreeNode>(3);
|
||||||
for (X4OLanguageModule mod:language.getLanguageModules()) {
|
for (X4OLanguageModule mod : language.getLanguageModules()) {
|
||||||
for (ElementNamespace ns:mod.getElementNamespaces()) {
|
for (ElementNamespace ns : mod.getElementNamespaces()) {
|
||||||
if (ns.getLanguageRoot()!=null && ns.getLanguageRoot()) {
|
if (ns.getLanguageRoot() != null && ns.getLanguageRoot()) {
|
||||||
// found language root elements.
|
// found language root elements.
|
||||||
for (ElementClass ec:ns.getElementClasses()) {
|
for (ElementClass ec : ns.getElementClasses()) {
|
||||||
TreeNode node = new TreeNode();
|
TreeNode node = new TreeNode();
|
||||||
node.language=language;
|
node.language = language;
|
||||||
node.module=mod;
|
node.module = mod;
|
||||||
node.namespace=ns;
|
node.namespace = ns;
|
||||||
node.elementClass=ec;
|
node.elementClass = ec;
|
||||||
rootNodes.add(node);
|
rootNodes.add(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Collections.sort(rootNodes,new TreeNodeComparator());
|
Collections.sort(rootNodes, new TreeNodeComparator());
|
||||||
for (TreeNode rootNode:rootNodes) {
|
for (TreeNode rootNode : rootNodes) {
|
||||||
walkTree(rootNode,"../");
|
walkTree(rootNode, "../");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void walkTree(TreeNode node,String pathPrefix) throws IOException {
|
private void walkTree(TreeNode node, String pathPrefix) throws IOException {
|
||||||
//String href = toElementUri(pathPrefix,node.module,node.namespace,node.elementClass);
|
// String href = toElementUri(pathPrefix,node.module,node.namespace,node.elementClass);
|
||||||
List<TreeNode> childs = findChilderen(node);
|
List<TreeNode> childs = findChilderen(node);
|
||||||
for (TreeNode child:childs) {
|
for (TreeNode child : childs) {
|
||||||
walkTree(child,pathPrefix);
|
walkTree(child, pathPrefix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class TreeNode {
|
class TreeNode {
|
||||||
X4OLanguage language;
|
X4OLanguage language;
|
||||||
X4OLanguageModule module;
|
X4OLanguageModule module;
|
||||||
|
|
@ -182,150 +182,148 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements Mais
|
||||||
TreeNode parent;
|
TreeNode parent;
|
||||||
int indent = 0;
|
int indent = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TreeNode> findChilderen(TreeNode node) {
|
public List<TreeNode> findChilderen(TreeNode node) {
|
||||||
List<TreeNode> result = new ArrayList<TreeNode>(10);
|
List<TreeNode> result = new ArrayList<TreeNode>(10);
|
||||||
|
|
||||||
if (node.indent>20) {
|
if (node.indent > 20) {
|
||||||
return result; // hard fail limit
|
return result; // hard fail limit
|
||||||
}
|
}
|
||||||
for (X4OLanguageModule mod:node.language.getLanguageModules()) {
|
for (X4OLanguageModule mod : node.language.getLanguageModules()) {
|
||||||
for (ElementNamespace ns:mod.getElementNamespaces()) {
|
for (ElementNamespace ns : mod.getElementNamespaces()) {
|
||||||
for (ElementClass ec:ns.getElementClasses()) {
|
for (ElementClass ec : ns.getElementClasses()) {
|
||||||
TreeNode n=null;
|
TreeNode n = null;
|
||||||
List<String> tags = ec.getElementParents(node.namespace.getUri());
|
List<String> tags = ec.getElementParents(node.namespace.getUri());
|
||||||
if (tags!=null && tags.contains(node.elementClass.getId())) {
|
if (tags != null && tags.contains(node.elementClass.getId())) {
|
||||||
n = new TreeNode();
|
n = new TreeNode();
|
||||||
n.language=node.language;
|
n.language = node.language;
|
||||||
n.module=mod;
|
n.module = mod;
|
||||||
n.namespace=ns;
|
n.namespace = ns;
|
||||||
n.elementClass=ec;
|
n.elementClass = ec;
|
||||||
n.indent=node.indent+1;
|
n.indent = node.indent + 1;
|
||||||
n.parent=node;
|
n.parent = node;
|
||||||
} else {
|
} else {
|
||||||
if (ec.getObjectClass()==null) {
|
if (ec.getObjectClass() == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Check interfaces of parent , and see if child tag is there.
|
// Check interfaces of parent , and see if child tag is there.
|
||||||
for (ElementInterface ei:node.language.findElementInterfaces(ec.getObjectClass())) {
|
for (ElementInterface ei : node.language.findElementInterfaces(ec.getObjectClass())) {
|
||||||
List<String> eiTags = ei.getElementParents(node.namespace.getUri());
|
List<String> eiTags = ei.getElementParents(node.namespace.getUri());
|
||||||
if (eiTags!=null && eiTags.contains(node.elementClass.getId())) {
|
if (eiTags != null && eiTags.contains(node.elementClass.getId())) {
|
||||||
n = new TreeNode();
|
n = new TreeNode();
|
||||||
n.language=node.language;
|
n.language = node.language;
|
||||||
n.module=mod;
|
n.module = mod;
|
||||||
n.namespace=ns;
|
n.namespace = ns;
|
||||||
n.elementClass=ec;
|
n.elementClass = ec;
|
||||||
n.indent=node.indent+1;
|
n.indent = node.indent + 1;
|
||||||
n.parent=node;
|
n.parent = node;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.elementClass.getObjectClass()==null) {
|
if (node.elementClass.getObjectClass() == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
List<ElementBindingHandler> binds = node.language.findElementBindingHandlers(node.elementClass.getObjectClass(), ec.getObjectClass());
|
List<ElementBindingHandler> binds = node.language.findElementBindingHandlers(node.elementClass.getObjectClass(), ec.getObjectClass());
|
||||||
if (binds.isEmpty()==false) {
|
if (binds.isEmpty() == false) {
|
||||||
n = new TreeNode();
|
n = new TreeNode();
|
||||||
n.language=node.language;
|
n.language = node.language;
|
||||||
n.module=mod;
|
n.module = mod;
|
||||||
n.namespace=ns;
|
n.namespace = ns;
|
||||||
n.elementClass=ec;
|
n.elementClass = ec;
|
||||||
n.indent=node.indent+1;
|
n.indent = node.indent + 1;
|
||||||
n.parent=node;
|
n.parent = node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (n!=null && isInTree(node,n)==false) {
|
if (n != null && isInTree(node, n) == false) {
|
||||||
result.add(n);
|
result.add(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Collections.sort(result,new TreeNodeComparator());
|
Collections.sort(result, new TreeNodeComparator());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isInTree(TreeNode node,TreeNode checkNode) {
|
private boolean isInTree(TreeNode node, TreeNode checkNode) {
|
||||||
|
|
||||||
if ( node.namespace.getUri().equals(checkNode.namespace.getUri()) &&
|
if (node.namespace.getUri().equals(checkNode.namespace.getUri()) && node.elementClass.getId().equals(checkNode.elementClass.getId())) {
|
||||||
node.elementClass.getId().equals(checkNode.elementClass.getId())
|
|
||||||
) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (node.parent!=null) {
|
if (node.parent != null) {
|
||||||
return isInTree(node.parent,checkNode);
|
return isInTree(node.parent, checkNode);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TreeNode> findParents(TreeNode node) {
|
public List<TreeNode> findParents(TreeNode node) {
|
||||||
List<TreeNode> result = new ArrayList<TreeNode>(10);
|
List<TreeNode> result = new ArrayList<TreeNode>(10);
|
||||||
TreeNode n=null;
|
TreeNode n = null;
|
||||||
for (X4OLanguageModule mod:node.language.getLanguageModules()) {
|
for (X4OLanguageModule mod : node.language.getLanguageModules()) {
|
||||||
for (ElementNamespace ns:mod.getElementNamespaces()) {
|
for (ElementNamespace ns : mod.getElementNamespaces()) {
|
||||||
|
|
||||||
List<String> tags = node.elementClass.getElementParents(ns.getUri());
|
List<String> tags = node.elementClass.getElementParents(ns.getUri());
|
||||||
if (tags!=null) {
|
if (tags != null) {
|
||||||
for (ElementClass ec:ns.getElementClasses()) {
|
for (ElementClass ec : ns.getElementClasses()) {
|
||||||
if (tags.contains(ec.getId())) {
|
if (tags.contains(ec.getId())) {
|
||||||
n = new TreeNode();
|
n = new TreeNode();
|
||||||
n.language=node.language;
|
n.language = node.language;
|
||||||
n.module=mod;
|
n.module = mod;
|
||||||
n.namespace=ns;
|
n.namespace = ns;
|
||||||
n.elementClass=ec;
|
n.elementClass = ec;
|
||||||
n.indent=node.indent+1;
|
n.indent = node.indent + 1;
|
||||||
n.parent=node;
|
n.parent = node;
|
||||||
result.add(n);
|
result.add(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (ElementClass ec:ns.getElementClasses()) {
|
for (ElementClass ec : ns.getElementClasses()) {
|
||||||
|
|
||||||
// Check interfaces of parent , and see if child tag is there.
|
// Check interfaces of parent , and see if child tag is there.
|
||||||
if (node.elementClass.getObjectClass()!=null) {
|
if (node.elementClass.getObjectClass() != null) {
|
||||||
for (ElementInterface ei:node.language.findElementInterfaces(node.elementClass.getObjectClass())) {
|
for (ElementInterface ei : node.language.findElementInterfaces(node.elementClass.getObjectClass())) {
|
||||||
List<String> eiTags = ei.getElementParents(ns.getUri());
|
List<String> eiTags = ei.getElementParents(ns.getUri());
|
||||||
if (eiTags!=null && eiTags.contains(ec.getId())) {
|
if (eiTags != null && eiTags.contains(ec.getId())) {
|
||||||
n = new TreeNode();
|
n = new TreeNode();
|
||||||
n.language=node.language;
|
n.language = node.language;
|
||||||
n.module=mod;
|
n.module = mod;
|
||||||
n.namespace=ns;
|
n.namespace = ns;
|
||||||
n.elementClass=ec;
|
n.elementClass = ec;
|
||||||
n.indent=node.indent+1;
|
n.indent = node.indent + 1;
|
||||||
n.parent=node;
|
n.parent = node;
|
||||||
result.add(n);
|
result.add(n);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ec.getObjectClass()==null) {
|
if (ec.getObjectClass() == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (node.elementClass.getObjectClass()==null) {
|
if (node.elementClass.getObjectClass() == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
List<ElementBindingHandler> binds = node.language.findElementBindingHandlers(ec.getObjectClass(),node.elementClass.getObjectClass());
|
List<ElementBindingHandler> binds = node.language.findElementBindingHandlers(ec.getObjectClass(), node.elementClass.getObjectClass());
|
||||||
if (binds.isEmpty()==false) {
|
if (binds.isEmpty() == false) {
|
||||||
n = new TreeNode();
|
n = new TreeNode();
|
||||||
n.language=node.language;
|
n.language = node.language;
|
||||||
n.module=mod;
|
n.module = mod;
|
||||||
n.namespace=ns;
|
n.namespace = ns;
|
||||||
n.elementClass=ec;
|
n.elementClass = ec;
|
||||||
n.indent=node.indent+1;
|
n.indent = node.indent + 1;
|
||||||
n.parent=node;
|
n.parent = node;
|
||||||
if (isInTree(node,n)==false) {
|
if (isInTree(node, n) == false) {
|
||||||
result.add(n);
|
result.add(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Collections.sort(result,new TreeNodeComparator());
|
Collections.sort(result, new TreeNodeComparator());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
class TreeNodeComparator implements Comparator<TreeNode> {
|
class TreeNodeComparator implements Comparator<TreeNode> {
|
||||||
public int compare(TreeNode o1,TreeNode o2) {
|
public int compare(TreeNode o1, TreeNode o2) {
|
||||||
return o1.elementClass.getId().compareTo(o2.elementClass.getId());
|
return o1.elementClass.getId().compareTo(o2.elementClass.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,19 +36,20 @@ public class AttributeAliasElement extends AbstractElement {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the xml attribute 'name' to ElementClassAttribute as attribute alias.
|
* Add the xml attribute 'name' to ElementClassAttribute as attribute alias.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.element.AbstractElement#doElementEnd()
|
* @see org.x4o.xml.element.AbstractElement#doElementEnd()
|
||||||
* @throws ElementException When name attribute is not set or when parent element object is not ElementClassAttribute interface.
|
* @throws ElementException When name attribute is not set or when parent element object is not ElementClassAttribute interface.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void doElementEnd() throws ElementException {
|
public void doElementEnd() throws ElementException {
|
||||||
String alias = getAttributes().get("name");
|
String alias = getAttributes().get("name");
|
||||||
if (alias==null) {
|
if (alias == null) {
|
||||||
throw new ElementException("'name' attribute is not set on: "+getElementClass().getId());
|
throw new ElementException("'name' attribute is not set on: " + getElementClass().getId());
|
||||||
}
|
}
|
||||||
if (getParent().getElementObject() instanceof ElementClassAttribute) {
|
if (getParent().getElementObject() instanceof ElementClassAttribute) {
|
||||||
((ElementClassAttribute)getParent().getElementObject()).addAttributeAlias(alias);
|
((ElementClassAttribute) getParent().getElementObject()).addAttributeAlias(alias);
|
||||||
} else {
|
} else {
|
||||||
throw new ElementException("Wrong parent class is not ElementClassAttribute but: "+getParent().getElementObject());
|
throw new ElementException("Wrong parent class is not ElementClassAttribute but: " + getParent().getElementObject());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,33 +38,36 @@ import org.x4o.xml.lang.X4OLanguageClassLoader;
|
||||||
* @version 1.0 Jan 21, 2007
|
* @version 1.0 Jan 21, 2007
|
||||||
*/
|
*/
|
||||||
public class BeanElement extends AbstractElement {
|
public class BeanElement extends AbstractElement {
|
||||||
|
|
||||||
private List<Object> constructorArguments = null;
|
private List<Object> constructorArguments = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a BeanElement.
|
* Creates a BeanElement.
|
||||||
*/
|
*/
|
||||||
public BeanElement() {
|
public BeanElement() {
|
||||||
constructorArguments = new ArrayList<Object>(3);
|
constructorArguments = new ArrayList<Object>(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On start of element create the element object, filled from the bean.class attribute.
|
* On start of element create the element object, filled from the bean.class attribute.
|
||||||
|
*
|
||||||
* @throws ElementException When bean could not be created.
|
* @throws ElementException When bean could not be created.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void doElementStart() throws ElementException {
|
public void doElementStart() throws ElementException {
|
||||||
String className = getAttributes().get("bean.class");
|
String className = getAttributes().get("bean.class");
|
||||||
if("".equals(className) | className==null) { throw new ElementException("Set the bean.class attribute"); }
|
if ("".equals(className) | className == null) {
|
||||||
|
throw new ElementException("Set the bean.class attribute");
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
Class<?> beanClass = X4OLanguageClassLoader.loadClass(className);
|
Class<?> beanClass = X4OLanguageClassLoader.loadClass(className);
|
||||||
if (constructorArguments.isEmpty()) {
|
if (constructorArguments.isEmpty()) {
|
||||||
setElementObject(X4OLanguageClassLoader.newInstance(beanClass));
|
setElementObject(X4OLanguageClassLoader.newInstance(beanClass));
|
||||||
} else {
|
} else {
|
||||||
Class<?>[] arguClass = new Class<?>[constructorArguments.size()];
|
Class<?>[] arguClass = new Class<?>[constructorArguments.size()];
|
||||||
constructorArguments.toArray(arguClass);
|
constructorArguments.toArray(arguClass);
|
||||||
Constructor<?> c = beanClass.getConstructor(arguClass);
|
Constructor<?> c = beanClass.getConstructor(arguClass);
|
||||||
setElementObject(c.newInstance(constructorArguments));
|
setElementObject(c.newInstance(constructorArguments));
|
||||||
}
|
}
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new ElementException(e);
|
throw new ElementException(e);
|
||||||
|
|
@ -79,14 +82,15 @@ public class BeanElement extends AbstractElement {
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
throw new ElementException(e);
|
throw new ElementException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add bean constructor arguments.
|
* Add bean constructor arguments.
|
||||||
* @param argu The argument to add to constructor.
|
*
|
||||||
|
* @param argu The argument to add to constructor.
|
||||||
*/
|
*/
|
||||||
public void addConstuctorArgument(Object argu) {
|
public void addConstuctorArgument(Object argu) {
|
||||||
if (argu==null) {
|
if (argu == null) {
|
||||||
throw new NullPointerException("Can't add null argument for constructor.");
|
throw new NullPointerException("Can't add null argument for constructor.");
|
||||||
}
|
}
|
||||||
constructorArguments.add(argu);
|
constructorArguments.add(argu);
|
||||||
|
|
|
||||||
|
|
@ -33,15 +33,16 @@ import org.x4o.xml.element.ElementException;
|
||||||
* @version 1.0 Jan 13, 2009
|
* @version 1.0 Jan 13, 2009
|
||||||
*/
|
*/
|
||||||
public class DescriptionElement extends AbstractElement {
|
public class DescriptionElement extends AbstractElement {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the description element and validates that it is not root and parent is meta base.
|
* Starts the description element and validates that it is not root and parent is meta base.
|
||||||
* @throws ElementException When parent element object is not meta base object.
|
*
|
||||||
|
* @throws ElementException When parent element object is not meta base object.
|
||||||
* @see org.x4o.xml.element.AbstractElement#doElementStart()
|
* @see org.x4o.xml.element.AbstractElement#doElementStart()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void doElementStart() throws ElementException {
|
public void doElementStart() throws ElementException {
|
||||||
if (getParent()==null) {
|
if (getParent() == null) {
|
||||||
throw new ElementException("can't be a root tag");
|
throw new ElementException("can't be a root tag");
|
||||||
}
|
}
|
||||||
if (getParent().getElementObject() instanceof ElementMetaBase == false) {
|
if (getParent().getElementObject() instanceof ElementMetaBase == false) {
|
||||||
|
|
@ -51,8 +52,9 @@ public class DescriptionElement extends AbstractElement {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The description elememt body characters are stored as element object.
|
* The description elememt body characters are stored as element object.
|
||||||
* @param characters The text of the description.
|
*
|
||||||
* @throws ElementException When super has error.
|
* @param characters The text of the description.
|
||||||
|
* @throws ElementException When super has error.
|
||||||
* @see org.x4o.xml.element.AbstractElement#doCharacters(java.lang.String)
|
* @see org.x4o.xml.element.AbstractElement#doCharacters(java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -63,16 +65,17 @@ public class DescriptionElement extends AbstractElement {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ends the description element and sets the description on the parent.
|
* Ends the description element and sets the description on the parent.
|
||||||
* @throws ElementException When parent element object is not meta base object.
|
*
|
||||||
|
* @throws ElementException When parent element object is not meta base object.
|
||||||
* @see org.x4o.xml.element.AbstractElement#doElementEnd()
|
* @see org.x4o.xml.element.AbstractElement#doElementEnd()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void doElementEnd() throws ElementException {
|
public void doElementEnd() throws ElementException {
|
||||||
if (getElementObject()==null) {
|
if (getElementObject() == null) {
|
||||||
throw new ElementException("description is not set.");
|
throw new ElementException("description is not set.");
|
||||||
}
|
}
|
||||||
if (getParent().getElementObject() instanceof ElementMetaBase) {
|
if (getParent().getElementObject() instanceof ElementMetaBase) {
|
||||||
((ElementMetaBase)getParent().getElementObject()).setDescription(getElementObject().toString());
|
((ElementMetaBase) getParent().getElementObject()).setDescription(getElementObject().toString());
|
||||||
} else {
|
} else {
|
||||||
throw new ElementException("Wrong parent class is not ElementClass");
|
throw new ElementException("Wrong parent class is not ElementClass");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,17 +41,17 @@ public class ElementClassAddParentElement extends AbstractElement {
|
||||||
@Override
|
@Override
|
||||||
public void doElementEnd() throws ElementException {
|
public void doElementEnd() throws ElementException {
|
||||||
String tag = getAttributes().get("tag");
|
String tag = getAttributes().get("tag");
|
||||||
if (tag==null) {
|
if (tag == null) {
|
||||||
throw new ElementException("'tag' attribute is not set on: "+getElementClass().getId());
|
throw new ElementException("'tag' attribute is not set on: " + getElementClass().getId());
|
||||||
}
|
}
|
||||||
String namespaceUri = getAttributes().get("uri");
|
String namespaceUri = getAttributes().get("uri");
|
||||||
if (namespaceUri==null) {
|
if (namespaceUri == null) {
|
||||||
namespaceUri = getParent().getParent().getAttributes().get("uri"); // copy uri from namespace element.
|
namespaceUri = getParent().getParent().getAttributes().get("uri"); // copy uri from namespace element.
|
||||||
}
|
}
|
||||||
if (getParent().getElementObject() instanceof ElementClassBase) {
|
if (getParent().getElementObject() instanceof ElementClassBase) {
|
||||||
((ElementClassBase)getParent().getElementObject()).addElementParent(namespaceUri,tag);
|
((ElementClassBase) getParent().getElementObject()).addElementParent(namespaceUri, tag);
|
||||||
} else {
|
} else {
|
||||||
throw new ElementException("Wrong parent class is not ElementClassBase but: "+getParent().getElementObject());
|
throw new ElementException("Wrong parent class is not ElementClassBase but: " + getParent().getElementObject());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.eld.lang;
|
package org.x4o.xml.eld.lang;
|
||||||
|
|
||||||
import org.x4o.xml.conv.ObjectConverter;
|
import org.x4o.xml.conv.ObjectConverter;
|
||||||
import org.x4o.xml.element.AbstractElementBindingHandler;
|
import org.x4o.xml.element.AbstractElementBindingHandler;
|
||||||
|
|
@ -36,11 +36,8 @@ import org.x4o.xml.element.ElementClassAttribute;
|
||||||
*/
|
*/
|
||||||
public class ElementClassAttributeBindingHandler extends AbstractElementBindingHandler<ElementClassAttribute> {
|
public class ElementClassAttributeBindingHandler extends AbstractElementBindingHandler<ElementClassAttribute> {
|
||||||
|
|
||||||
|
private final static Class<?>[] CLASSES_CHILD = new Class[] { ObjectConverter.class };
|
||||||
private final static Class<?>[] CLASSES_CHILD = new Class[] {
|
|
||||||
ObjectConverter.class
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
||||||
*/
|
*/
|
||||||
|
|
@ -58,16 +55,16 @@ public class ElementClassAttributeBindingHandler extends AbstractElementBindingH
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
* @see org.x4o.xml.element.AbstractElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void bindChild(Element childElement,ElementClassAttribute parentObject,Object childObject) throws ElementBindingHandlerException {
|
public void bindChild(Element childElement, ElementClassAttribute parentObject, Object childObject) throws ElementBindingHandlerException {
|
||||||
if (childObject instanceof ObjectConverter) {
|
if (childObject instanceof ObjectConverter) {
|
||||||
parentObject.setObjectConverter((ObjectConverter)childObject);
|
parentObject.setObjectConverter((ObjectConverter) childObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void createChilderen(Element parentElement,ElementClassAttribute parentObject) throws ElementBindingHandlerException {
|
public void createChilderen(Element parentElement, ElementClassAttribute parentObject) throws ElementBindingHandlerException {
|
||||||
createChild(parentElement, parentObject.getObjectConverter());
|
createChild(parentElement, parentObject.getObjectConverter());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.eld.lang;
|
package org.x4o.xml.eld.lang;
|
||||||
|
|
||||||
import org.x4o.xml.element.AbstractElementBindingHandler;
|
import org.x4o.xml.element.AbstractElementBindingHandler;
|
||||||
import org.x4o.xml.element.Element;
|
import org.x4o.xml.element.Element;
|
||||||
|
|
@ -30,19 +30,15 @@ import org.x4o.xml.element.ElementClassAttribute;
|
||||||
import org.x4o.xml.element.ElementConfigurator;
|
import org.x4o.xml.element.ElementConfigurator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This ElementBindingHandler adds the ElementClassAttributeConverter and the
|
* This ElementBindingHandler adds the ElementClassAttributeConverter and the ElementConfigurator to the ElementClass.
|
||||||
* ElementConfigurator to the ElementClass.
|
|
||||||
*
|
*
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Jan 31, 2007
|
* @version 1.0 Jan 31, 2007
|
||||||
*/
|
*/
|
||||||
public class ElementClassBindingHandler extends AbstractElementBindingHandler<ElementClass> {
|
public class ElementClassBindingHandler extends AbstractElementBindingHandler<ElementClass> {
|
||||||
|
|
||||||
private final static Class<?>[] CLASSES_CHILD = new Class[] {
|
private final static Class<?>[] CLASSES_CHILD = new Class[] { ElementClassAttribute.class, ElementConfigurator.class };
|
||||||
ElementClassAttribute.class,
|
|
||||||
ElementConfigurator.class
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
||||||
*/
|
*/
|
||||||
|
|
@ -60,23 +56,23 @@ public class ElementClassBindingHandler extends AbstractElementBindingHandler<El
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
* @see org.x4o.xml.element.AbstractElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void bindChild(Element childElement,ElementClass parent, Object childObject) throws ElementBindingHandlerException {
|
public void bindChild(Element childElement, ElementClass parent, Object childObject) throws ElementBindingHandlerException {
|
||||||
if (childObject instanceof ElementClassAttribute) {
|
if (childObject instanceof ElementClassAttribute) {
|
||||||
parent.addElementClassAttribute((ElementClassAttribute)childObject);
|
parent.addElementClassAttribute((ElementClassAttribute) childObject);
|
||||||
}
|
}
|
||||||
if (childObject instanceof ElementConfigurator) {
|
if (childObject instanceof ElementConfigurator) {
|
||||||
parent.addElementConfigurators((ElementConfigurator)childObject);
|
parent.addElementConfigurators((ElementConfigurator) childObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void createChilderen(Element parentElement,ElementClass parent) throws ElementBindingHandlerException {
|
public void createChilderen(Element parentElement, ElementClass parent) throws ElementBindingHandlerException {
|
||||||
for (ElementClassAttribute child:parent.getElementClassAttributes()) {
|
for (ElementClassAttribute child : parent.getElementClassAttributes()) {
|
||||||
createChild(parentElement, child);
|
createChild(parentElement, child);
|
||||||
}
|
}
|
||||||
for (ElementConfigurator child:parent.getElementConfigurators()) {
|
for (ElementConfigurator child : parent.getElementConfigurators()) {
|
||||||
createChild(parentElement, child);
|
createChild(parentElement, child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.eld.lang;
|
package org.x4o.xml.eld.lang;
|
||||||
|
|
||||||
import org.x4o.xml.element.AbstractElementBindingHandler;
|
import org.x4o.xml.element.AbstractElementBindingHandler;
|
||||||
import org.x4o.xml.element.Element;
|
import org.x4o.xml.element.Element;
|
||||||
|
|
@ -36,12 +36,9 @@ import org.x4o.xml.element.ElementInterface;
|
||||||
* @version 1.0 Aug 21, 2012
|
* @version 1.0 Aug 21, 2012
|
||||||
*/
|
*/
|
||||||
public class ElementInterfaceBindingHandler extends AbstractElementBindingHandler<ElementInterface> {
|
public class ElementInterfaceBindingHandler extends AbstractElementBindingHandler<ElementInterface> {
|
||||||
|
|
||||||
private final static Class<?>[] CLASSES_CHILD = new Class[] {
|
private final static Class<?>[] CLASSES_CHILD = new Class[] { ElementClassAttribute.class, ElementConfigurator.class };
|
||||||
ElementClassAttribute.class,
|
|
||||||
ElementConfigurator.class
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
||||||
*/
|
*/
|
||||||
|
|
@ -59,23 +56,23 @@ public class ElementInterfaceBindingHandler extends AbstractElementBindingHandle
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
* @see org.x4o.xml.element.AbstractElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void bindChild(Element childElement,ElementInterface parent, Object childObject) throws ElementBindingHandlerException {
|
public void bindChild(Element childElement, ElementInterface parent, Object childObject) throws ElementBindingHandlerException {
|
||||||
if (childObject instanceof ElementClassAttribute) {
|
if (childObject instanceof ElementClassAttribute) {
|
||||||
parent.addElementClassAttribute((ElementClassAttribute)childObject);
|
parent.addElementClassAttribute((ElementClassAttribute) childObject);
|
||||||
}
|
}
|
||||||
if (childObject instanceof ElementConfigurator) {
|
if (childObject instanceof ElementConfigurator) {
|
||||||
parent.addElementConfigurators((ElementConfigurator)childObject);
|
parent.addElementConfigurators((ElementConfigurator) childObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void createChilderen(Element parentElement,ElementInterface parent) throws ElementBindingHandlerException {
|
public void createChilderen(Element parentElement, ElementInterface parent) throws ElementBindingHandlerException {
|
||||||
for (ElementClassAttribute child:parent.getElementClassAttributes()) {
|
for (ElementClassAttribute child : parent.getElementClassAttributes()) {
|
||||||
createChild(parentElement, child);
|
createChild(parentElement, child);
|
||||||
}
|
}
|
||||||
for (ElementConfigurator child:parent.getElementConfigurators()) {
|
for (ElementConfigurator child : parent.getElementConfigurators()) {
|
||||||
createChild(parentElement, child);
|
createChild(parentElement, child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.eld.lang;
|
package org.x4o.xml.eld.lang;
|
||||||
|
|
||||||
import org.x4o.xml.eld.EldModuleLoader;
|
import org.x4o.xml.eld.EldModuleLoader;
|
||||||
import org.x4o.xml.element.AbstractElementBindingHandler;
|
import org.x4o.xml.element.AbstractElementBindingHandler;
|
||||||
|
|
@ -44,16 +44,11 @@ import org.x4o.xml.lang.X4OLanguageModuleLocal;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Jan 19, 2007
|
* @version 1.0 Jan 19, 2007
|
||||||
*/
|
*/
|
||||||
public class ElementModuleBindingHandler extends AbstractElementBindingHandler<X4OLanguageModuleLocal> {
|
public class ElementModuleBindingHandler extends AbstractElementBindingHandler<X4OLanguageModuleLocal> {
|
||||||
|
|
||||||
private final static Class<?>[] CLASSES_CHILD = new Class[] {
|
private final static Class<?>[] CLASSES_CHILD = new Class[] { ElementInterface.class, ElementNamespace.class, ElementBindingHandler.class,
|
||||||
ElementInterface.class,
|
ElementConfiguratorGlobal.class, };
|
||||||
ElementNamespace.class,
|
|
||||||
ElementBindingHandler.class,
|
|
||||||
ElementConfiguratorGlobal.class,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
||||||
*/
|
*/
|
||||||
|
|
@ -71,105 +66,101 @@ public class ElementModuleBindingHandler extends AbstractElementBindingHandler<
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
* @see org.x4o.xml.element.AbstractElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void bindChild(Element childElement,X4OLanguageModuleLocal languageModule, Object childObject) throws ElementBindingHandlerException {
|
public void bindChild(Element childElement, X4OLanguageModuleLocal languageModule, Object childObject) throws ElementBindingHandlerException {
|
||||||
|
|
||||||
X4OLanguage x4oParsingContext = EldModuleLoader.getLanguage(childElement.getLanguageSession());
|
X4OLanguage x4oParsingContext = EldModuleLoader.getLanguage(childElement.getLanguageSession());
|
||||||
if (x4oParsingContext==null) {
|
if (x4oParsingContext == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (languageModule==null) {
|
if (languageModule == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (childObject instanceof ElementInterface) {
|
if (childObject instanceof ElementInterface) {
|
||||||
ElementInterface elementInterface = (ElementInterface)childObject;
|
ElementInterface elementInterface = (ElementInterface) childObject;
|
||||||
languageModule.addElementInterface(elementInterface);
|
languageModule.addElementInterface(elementInterface);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (childObject instanceof ElementNamespace) {
|
if (childObject instanceof ElementNamespace) {
|
||||||
ElementNamespace elementNamespace = (ElementNamespace)childObject;
|
ElementNamespace elementNamespace = (ElementNamespace) childObject;
|
||||||
|
|
||||||
if (elementNamespace.getId()==null) {
|
if (elementNamespace.getId() == null) {
|
||||||
throw new NullPointerException("Can add elementNamespace without id.");
|
throw new NullPointerException("Can add elementNamespace without id.");
|
||||||
}
|
}
|
||||||
// TODO: no language here so move to EL default on eld attribute tag
|
// TODO: no language here so move to EL default on eld attribute tag
|
||||||
if (elementNamespace.getId()!=null) {
|
if (elementNamespace.getId() != null) {
|
||||||
StringBuilder buf = new StringBuilder(30);
|
StringBuilder buf = new StringBuilder(30);
|
||||||
for (char c:elementNamespace.getId().toLowerCase().toCharArray()) {
|
for (char c : elementNamespace.getId().toLowerCase().toCharArray()) {
|
||||||
if (Character.isLetter(c)) {buf.append(c);}
|
if (Character.isLetter(c)) {
|
||||||
if (Character.isDigit(c)) {buf.append(c);}
|
buf.append(c);
|
||||||
if ('-'==c) {buf.append(c);}
|
}
|
||||||
|
if (Character.isDigit(c)) {
|
||||||
|
buf.append(c);
|
||||||
|
}
|
||||||
|
if ('-' == c) {
|
||||||
|
buf.append(c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
String id = buf.toString();
|
String id = buf.toString();
|
||||||
elementNamespace.setId(id);
|
elementNamespace.setId(id);
|
||||||
}
|
}
|
||||||
if (elementNamespace.getUri()==null) {
|
if (elementNamespace.getUri() == null) {
|
||||||
elementNamespace.setUri(
|
elementNamespace.setUri(
|
||||||
"http://"+languageModule.getProviderHost()+
|
"http://" + languageModule.getProviderHost() + "/xml/ns/" + x4oParsingContext.getLanguageName() + "-" + elementNamespace.getId());
|
||||||
"/xml/ns/"+x4oParsingContext.getLanguageName()+
|
|
||||||
"-"+elementNamespace.getId());
|
|
||||||
}
|
}
|
||||||
if (elementNamespace.getSchemaUri()==null) {
|
if (elementNamespace.getSchemaUri() == null) {
|
||||||
elementNamespace.setSchemaUri(
|
elementNamespace.setSchemaUri("http://" + languageModule.getProviderHost() + "/xml/ns/" + x4oParsingContext.getLanguageName() + "-"
|
||||||
"http://"+languageModule.getProviderHost()+
|
+ elementNamespace.getId() + "-" + x4oParsingContext.getLanguageVersion() + ".xsd");
|
||||||
"/xml/ns/"+x4oParsingContext.getLanguageName()+
|
|
||||||
"-"+elementNamespace.getId()+
|
|
||||||
"-"+x4oParsingContext.getLanguageVersion()+
|
|
||||||
".xsd"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
if (elementNamespace.getSchemaResource()==null) {
|
if (elementNamespace.getSchemaResource() == null) {
|
||||||
elementNamespace.setSchemaResource(
|
elementNamespace.setSchemaResource(
|
||||||
x4oParsingContext.getLanguageName()+
|
x4oParsingContext.getLanguageName() + "-" + elementNamespace.getId() + "-" + x4oParsingContext.getLanguageVersion() + ".xsd");
|
||||||
"-"+elementNamespace.getId()+
|
|
||||||
"-"+x4oParsingContext.getLanguageVersion()+
|
|
||||||
".xsd"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
if (elementNamespace.getSchemaPrefix()==null) {
|
if (elementNamespace.getSchemaPrefix() == null) {
|
||||||
elementNamespace.setSchemaPrefix(elementNamespace.getId());
|
elementNamespace.setSchemaPrefix(elementNamespace.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
elementNamespace.setElementNamespaceInstanceProvider(X4OLanguageClassLoader.newInstance(ElementNamespaceInstanceProvider.class, childElement.getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementNamespaceInstanceProvider()));
|
elementNamespace.setElementNamespaceInstanceProvider(X4OLanguageClassLoader.newInstance(ElementNamespaceInstanceProvider.class,
|
||||||
|
childElement.getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementNamespaceInstanceProvider()));
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new ElementBindingHandlerException("Error loading: "+e.getMessage(),e);
|
throw new ElementBindingHandlerException("Error loading: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
||||||
elementNamespace.getElementNamespaceInstanceProvider().start(x4oParsingContext, elementNamespace);
|
elementNamespace.getElementNamespaceInstanceProvider().start(x4oParsingContext, elementNamespace);
|
||||||
} catch (ElementNamespaceInstanceProviderException e) {
|
} catch (ElementNamespaceInstanceProviderException e) {
|
||||||
throw new ElementBindingHandlerException("Error starting: "+e.getMessage(),e);
|
throw new ElementBindingHandlerException("Error starting: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
languageModule.addElementNamespace(elementNamespace);
|
languageModule.addElementNamespace(elementNamespace);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (childObject instanceof ElementBindingHandler) {
|
if (childObject instanceof ElementBindingHandler) {
|
||||||
ElementBindingHandler elementBindingHandler = (ElementBindingHandler)childObject;
|
ElementBindingHandler elementBindingHandler = (ElementBindingHandler) childObject;
|
||||||
languageModule.addElementBindingHandler(elementBindingHandler);
|
languageModule.addElementBindingHandler(elementBindingHandler);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (childObject instanceof ElementConfiguratorGlobal) {
|
if (childObject instanceof ElementConfiguratorGlobal) {
|
||||||
ElementConfiguratorGlobal elementConfigurator = (ElementConfiguratorGlobal)childObject;
|
ElementConfiguratorGlobal elementConfigurator = (ElementConfiguratorGlobal) childObject;
|
||||||
languageModule.addElementConfiguratorGlobal(elementConfigurator);
|
languageModule.addElementConfiguratorGlobal(elementConfigurator);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void createChilderen(Element parentElement,X4OLanguageModuleLocal parent) throws ElementBindingHandlerException {
|
public void createChilderen(Element parentElement, X4OLanguageModuleLocal parent) throws ElementBindingHandlerException {
|
||||||
for (ElementInterface child:parent.getElementInterfaces()) {
|
for (ElementInterface child : parent.getElementInterfaces()) {
|
||||||
createChild(parentElement, child);
|
createChild(parentElement, child);
|
||||||
}
|
}
|
||||||
for (ElementNamespace child:parent.getElementNamespaces()) {
|
for (ElementNamespace child : parent.getElementNamespaces()) {
|
||||||
createChild(parentElement, child);
|
createChild(parentElement, child);
|
||||||
}
|
}
|
||||||
for (ElementBindingHandler child:parent.getElementBindingHandlers()) {
|
for (ElementBindingHandler child : parent.getElementBindingHandlers()) {
|
||||||
createChild(parentElement, child);
|
createChild(parentElement, child);
|
||||||
}
|
}
|
||||||
for (ElementConfiguratorGlobal child:parent.getElementConfiguratorGlobals()) {
|
for (ElementConfiguratorGlobal child : parent.getElementConfiguratorGlobals()) {
|
||||||
createChild(parentElement, child);
|
createChild(parentElement, child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.eld.lang;
|
package org.x4o.xml.eld.lang;
|
||||||
|
|
||||||
import org.x4o.xml.element.AbstractElementBindingHandler;
|
import org.x4o.xml.element.AbstractElementBindingHandler;
|
||||||
import org.x4o.xml.element.Element;
|
import org.x4o.xml.element.Element;
|
||||||
|
|
@ -37,11 +37,8 @@ import org.x4o.xml.element.ElementNamespaceAttribute;
|
||||||
*/
|
*/
|
||||||
public class ElementNamespaceBindingHandler extends AbstractElementBindingHandler<ElementNamespace> {
|
public class ElementNamespaceBindingHandler extends AbstractElementBindingHandler<ElementNamespace> {
|
||||||
|
|
||||||
private final static Class<?>[] CLASSES_CHILD = new Class[] {
|
private final static Class<?>[] CLASSES_CHILD = new Class[] { ElementClass.class, ElementNamespaceAttribute.class };
|
||||||
ElementClass.class,
|
|
||||||
ElementNamespaceAttribute.class
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
||||||
*/
|
*/
|
||||||
|
|
@ -59,29 +56,29 @@ public class ElementNamespaceBindingHandler extends AbstractElementBindingHandle
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
* @see org.x4o.xml.element.AbstractElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void bindChild(Element childElement,ElementNamespace parent, Object childObject) throws ElementBindingHandlerException {
|
public void bindChild(Element childElement, ElementNamespace parent, Object childObject) throws ElementBindingHandlerException {
|
||||||
if (childObject instanceof ElementClass) {
|
if (childObject instanceof ElementClass) {
|
||||||
ElementClass elementClass = (ElementClass)childObject;
|
ElementClass elementClass = (ElementClass) childObject;
|
||||||
if (elementClass.getId()==null && elementClass.getObjectClass()!=null) {
|
if (elementClass.getId() == null && elementClass.getObjectClass() != null) {
|
||||||
elementClass.setId(elementClass.getObjectClass().getSimpleName()); // TODO: move to defaults layer
|
elementClass.setId(elementClass.getObjectClass().getSimpleName()); // TODO: move to defaults layer
|
||||||
}
|
}
|
||||||
parent.addElementClass(elementClass);
|
parent.addElementClass(elementClass);
|
||||||
}
|
}
|
||||||
if (childObject instanceof ElementNamespaceAttribute) {
|
if (childObject instanceof ElementNamespaceAttribute) {
|
||||||
ElementNamespaceAttribute elementNamespaceAttribute = (ElementNamespaceAttribute)childObject;
|
ElementNamespaceAttribute elementNamespaceAttribute = (ElementNamespaceAttribute) childObject;
|
||||||
parent.addElementNamespaceAttribute(elementNamespaceAttribute);
|
parent.addElementNamespaceAttribute(elementNamespaceAttribute);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void createChilderen(Element parentElement,ElementNamespace parent) throws ElementBindingHandlerException {
|
public void createChilderen(Element parentElement, ElementNamespace parent) throws ElementBindingHandlerException {
|
||||||
for (ElementClass child:parent.getElementClasses()) {
|
for (ElementClass child : parent.getElementClasses()) {
|
||||||
createChild(parentElement, child);
|
createChild(parentElement, child);
|
||||||
}
|
}
|
||||||
for (ElementNamespaceAttribute child:parent.getElementNamespaceAttributes()) {
|
for (ElementNamespaceAttribute child : parent.getElementNamespaceAttributes()) {
|
||||||
createChild(parentElement, child);
|
createChild(parentElement, child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.eld.lang;
|
package org.x4o.xml.eld.lang;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -46,32 +46,32 @@ public class ElementRefectionBindingHandler extends AbstractElementBindingHandle
|
||||||
private String addMethod = null;
|
private String addMethod = null;
|
||||||
private String getMethod = null;
|
private String getMethod = null;
|
||||||
private String skipChilderenClassRegex = null;
|
private String skipChilderenClassRegex = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
||||||
*/
|
*/
|
||||||
public Class<?> getBindParentClass() {
|
public Class<?> getBindParentClass() {
|
||||||
return parentClass;
|
return parentClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindChildClasses()
|
* @see org.x4o.xml.element.ElementBindingHandler#getBindChildClasses()
|
||||||
*/
|
*/
|
||||||
public Class<?>[] getBindChildClasses() {
|
public Class<?>[] getBindChildClasses() {
|
||||||
return new Class[] {childClass};
|
return new Class[] { childClass };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
* @see org.x4o.xml.element.AbstractElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings(value = {"unchecked", "rawtypes"})
|
@SuppressWarnings(value = { "unchecked", "rawtypes" })
|
||||||
public void bindChild(Element childElement, Object parentObject, Object childObject) throws ElementBindingHandlerException {
|
public void bindChild(Element childElement, Object parentObject, Object childObject) throws ElementBindingHandlerException {
|
||||||
if (parentClass==null | childClass==null) {
|
if (parentClass == null | childClass == null) {
|
||||||
throw new IllegalStateException("Missing property: parentClass="+parentClass+" childClass="+childClass+" addMethod="+addMethod+".");
|
throw new IllegalStateException("Missing property: parentClass=" + parentClass + " childClass=" + childClass + " addMethod=" + addMethod + ".");
|
||||||
}
|
}
|
||||||
if (property != null) { // Tmp hanky code here...
|
if (property != null) { // Tmp hanky code here...
|
||||||
try {
|
try {
|
||||||
String pop = property.substring(0,1).toUpperCase() + property.substring(1);
|
String pop = property.substring(0, 1).toUpperCase() + property.substring(1);
|
||||||
Method propType = parentObject.getClass().getMethod("get" + pop);
|
Method propType = parentObject.getClass().getMethod("get" + pop);
|
||||||
if (List.class.isAssignableFrom(propType.getReturnType())) {
|
if (List.class.isAssignableFrom(propType.getReturnType())) {
|
||||||
Object data = childElement.getLanguageSession().getElementObjectPropertyValue().getProperty(parentObject, property);
|
Object data = childElement.getLanguageSession().getElementObjectPropertyValue().getProperty(parentObject, property);
|
||||||
|
|
@ -81,22 +81,23 @@ public class ElementRefectionBindingHandler extends AbstractElementBindingHandle
|
||||||
data = childElement.getLanguageSession().getElementObjectPropertyValue().getProperty(parentObject, property);
|
data = childElement.getLanguageSession().getElementObjectPropertyValue().getProperty(parentObject, property);
|
||||||
}
|
}
|
||||||
if (data instanceof Collection) {
|
if (data instanceof Collection) {
|
||||||
Collection dataCollection = (Collection)data;
|
Collection dataCollection = (Collection) data;
|
||||||
dataCollection.add(childObject);
|
dataCollection.add(childObject);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw new ElementBindingHandlerException("Unhandled property collection type: "+data.getClass()+" on: "+parentObject.getClass()+" id:"+getId());
|
throw new ElementBindingHandlerException(
|
||||||
|
"Unhandled property collection type: " + data.getClass() + " on: " + parentObject.getClass() + " id:" + getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
childElement.getLanguageSession().getElementObjectPropertyValue().setProperty(parentObject, property, childObject);
|
childElement.getLanguageSession().getElementObjectPropertyValue().setProperty(parentObject, property, childObject);
|
||||||
return;
|
return;
|
||||||
} catch (/*ElementObjectPropertyValueException |*/ Exception e) {
|
} catch (/* ElementObjectPropertyValueException | */ Exception e) {
|
||||||
throw new ElementBindingHandlerException(getId() + " error " + e.getMessage(), e);
|
throw new ElementBindingHandlerException(getId() + " error " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: remove old...
|
// TODO: remove old...
|
||||||
Method[] ms = parentObject.getClass().getMethods();
|
Method[] ms = parentObject.getClass().getMethods();
|
||||||
for (Method m:ms) {
|
for (Method m : ms) {
|
||||||
Class<?>[] types = m.getParameterTypes();
|
Class<?>[] types = m.getParameterTypes();
|
||||||
if (types.length == 0) {
|
if (types.length == 0) {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -104,28 +105,28 @@ public class ElementRefectionBindingHandler extends AbstractElementBindingHandle
|
||||||
if (types.length > 1) {
|
if (types.length > 1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (addMethod.equalsIgnoreCase(m.getName())==false) {
|
if (addMethod.equalsIgnoreCase(m.getName()) == false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (types[0].isAssignableFrom(childClass)) {
|
if (types[0].isAssignableFrom(childClass)) {
|
||||||
try {
|
try {
|
||||||
m.invoke(parentObject, childObject);
|
m.invoke(parentObject, childObject);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ElementBindingHandlerException("Error invoke binding method of: "+getId()+" error: "+e.getMessage(),e);
|
throw new ElementBindingHandlerException("Error invoke binding method of: " + getId() + " error: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new ElementBindingHandlerException("Could not find method: "+addMethod+" on: "+parentObject.getClass()+" id:"+getId());
|
throw new ElementBindingHandlerException("Could not find method: " + addMethod + " on: " + parentObject.getClass() + " id:" + getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void createChilderen(Element parentElement,Object parentObject) throws ElementBindingHandlerException {
|
public void createChilderen(Element parentElement, Object parentObject) throws ElementBindingHandlerException {
|
||||||
if (parentClass==null | childClass==null) {
|
if (parentClass == null | childClass == null) {
|
||||||
throw new IllegalStateException("Missing property: parentClass="+parentClass+" childClass="+childClass+" getMethod="+getMethod+".");
|
throw new IllegalStateException("Missing property: parentClass=" + parentClass + " childClass=" + childClass + " getMethod=" + getMethod + ".");
|
||||||
}
|
}
|
||||||
if (property != null) {
|
if (property != null) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -137,43 +138,44 @@ public class ElementRefectionBindingHandler extends AbstractElementBindingHandle
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Method[] ms = parentObject.getClass().getMethods();
|
Method[] ms = parentObject.getClass().getMethods();
|
||||||
for (Method m:ms) {
|
for (Method m : ms) {
|
||||||
Class<?>[] types = m.getParameterTypes();
|
Class<?>[] types = m.getParameterTypes();
|
||||||
if (types.length != 0) {
|
if (types.length != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (getMethod.equalsIgnoreCase(m.getName())==false) {
|
if (getMethod.equalsIgnoreCase(m.getName()) == false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Object result;
|
Object result;
|
||||||
try {
|
try {
|
||||||
result = m.invoke(parentObject, new Object[]{});
|
result = m.invoke(parentObject, new Object[] {});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ElementBindingHandlerException("Invoke error: "+e.getMessage()+" from: "+getMethod+" on: "+parentObject+" id:"+getId(),e);
|
throw new ElementBindingHandlerException("Invoke error: " + e.getMessage() + " from: " + getMethod + " on: " + parentObject + " id:" + getId(),
|
||||||
}
|
e);
|
||||||
|
}
|
||||||
createSafeChildLoop(parentElement, result);
|
createSafeChildLoop(parentElement, result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw new ElementBindingHandlerException("Could not find method: "+getMethod+" on: "+parentObject.getClass()+" id:"+getId());
|
throw new ElementBindingHandlerException("Could not find method: " + getMethod + " on: " + parentObject.getClass() + " id:" + getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
protected void createSafeChildLoop(Element parentElement,Object result) throws ElementBindingHandlerException {
|
protected void createSafeChildLoop(Element parentElement, Object result) throws ElementBindingHandlerException {
|
||||||
if (result==null) {
|
if (result == null) {
|
||||||
return; // null is no childeren
|
return; // null is no childeren
|
||||||
}
|
}
|
||||||
if (result instanceof List) {
|
if (result instanceof List) {
|
||||||
for (Object o:(List)result) {
|
for (Object o : (List) result) {
|
||||||
createSafeChild(parentElement, o);
|
createSafeChild(parentElement, o);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else if (result instanceof Collection) {
|
} else if (result instanceof Collection) {
|
||||||
for (Object o:(Collection)result) {
|
for (Object o : (Collection) result) {
|
||||||
createSafeChild(parentElement, o);
|
createSafeChild(parentElement, o);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else if (result.getClass().isArray()) {
|
} else if (result.getClass().isArray()) {
|
||||||
for (Object o:(Object[])result) {
|
for (Object o : (Object[]) result) {
|
||||||
createSafeChild(parentElement, o);
|
createSafeChild(parentElement, o);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
@ -181,102 +183,104 @@ public class ElementRefectionBindingHandler extends AbstractElementBindingHandle
|
||||||
createSafeChild(parentElement, result);
|
createSafeChild(parentElement, result);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
throw new ElementBindingHandlerException("Unsupported return type: "+result.getClass()+" need: "+childClass+" from: "+getMethod+" on: "+parentElement.getElementObject().getClass()+" id:"+getId());
|
throw new ElementBindingHandlerException("Unsupported return type: " + result.getClass() + " need: " + childClass + " from: " + getMethod + " on: "
|
||||||
|
+ parentElement.getElementObject().getClass() + " id:" + getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only create child when class matches and regex doesn't exclude it.
|
* Only create child when class matches and regex doesn't exclude it.
|
||||||
* @param parentElement The element to create childeren for.
|
*
|
||||||
* @param childObject The childObject.
|
* @param parentElement The element to create childeren for.
|
||||||
|
* @param childObject The childObject.
|
||||||
*/
|
*/
|
||||||
protected void createSafeChild(Element parentElement,Object childObject) {
|
protected void createSafeChild(Element parentElement, Object childObject) {
|
||||||
if (childClass.isAssignableFrom(childObject.getClass())==false) {
|
if (childClass.isAssignableFrom(childObject.getClass()) == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (skipChilderenClassRegex!=null && childObject.getClass().getName().matches(skipChilderenClassRegex)) {
|
if (skipChilderenClassRegex != null && childObject.getClass().getName().matches(skipChilderenClassRegex)) {
|
||||||
return; // skip
|
return; // skip
|
||||||
}
|
}
|
||||||
createChild(parentElement,childObject);
|
createChild(parentElement, childObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the parentClass
|
* @return the parentClass
|
||||||
*/
|
*/
|
||||||
public Class<?> getParentClass() {
|
public Class<?> getParentClass() {
|
||||||
return parentClass;
|
return parentClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param parentClass the parentClass to set
|
* @param parentClass the parentClass to set
|
||||||
*/
|
*/
|
||||||
public void setParentClass(Class<?> parentClass) {
|
public void setParentClass(Class<?> parentClass) {
|
||||||
this.parentClass = parentClass;
|
this.parentClass = parentClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the childClass
|
* @return the childClass
|
||||||
*/
|
*/
|
||||||
public Class<?> getChildClass() {
|
public Class<?> getChildClass() {
|
||||||
return childClass;
|
return childClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param childClass the childClass to set
|
* @param childClass the childClass to set
|
||||||
*/
|
*/
|
||||||
public void setChildClass(Class<?> childClass) {
|
public void setChildClass(Class<?> childClass) {
|
||||||
this.childClass = childClass;
|
this.childClass = childClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the addMethod
|
* @return the addMethod
|
||||||
*/
|
*/
|
||||||
public String getAddMethod() {
|
public String getAddMethod() {
|
||||||
return addMethod;
|
return addMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param addMethod the addMethod to set
|
* @param addMethod the addMethod to set
|
||||||
*/
|
*/
|
||||||
public void setAddMethod(String addMethod) {
|
public void setAddMethod(String addMethod) {
|
||||||
this.addMethod = addMethod;
|
this.addMethod = addMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the getMethod
|
* @return the getMethod
|
||||||
*/
|
*/
|
||||||
public String getGetMethod() {
|
public String getGetMethod() {
|
||||||
return getMethod;
|
return getMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param getMethod the getMethod to set
|
* @param getMethod the getMethod to set
|
||||||
*/
|
*/
|
||||||
public void setGetMethod(String getMethod) {
|
public void setGetMethod(String getMethod) {
|
||||||
this.getMethod = getMethod;
|
this.getMethod = getMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the property
|
* @return the property
|
||||||
*/
|
*/
|
||||||
public String getProperty() {
|
public String getProperty() {
|
||||||
return property;
|
return property;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param property the property to set
|
* @param property the property to set
|
||||||
*/
|
*/
|
||||||
public void setProperty(String property) {
|
public void setProperty(String property) {
|
||||||
this.property = property;
|
this.property = property;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the skipChilderenClassRegex
|
* @return the skipChilderenClassRegex
|
||||||
*/
|
*/
|
||||||
public String getSkipChilderenClassRegex() {
|
public String getSkipChilderenClassRegex() {
|
||||||
return skipChilderenClassRegex;
|
return skipChilderenClassRegex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param skipChilderenClassRegex the skipChilderenClassRegex to set
|
* @param skipChilderenClassRegex the skipChilderenClassRegex to set
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -35,14 +35,14 @@ import org.x4o.xml.lang.X4OLanguageModule;
|
||||||
* @version 1.0 Aug 20, 2012
|
* @version 1.0 Aug 20, 2012
|
||||||
*/
|
*/
|
||||||
public class ModuleElement extends AbstractElement {
|
public class ModuleElement extends AbstractElement {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.AbstractElement#doElementStart()
|
* @see org.x4o.xml.element.AbstractElement#doElementStart()
|
||||||
* @throws ElementException When module element is used and non-root element.
|
* @throws ElementException When module element is used and non-root element.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void doElementStart() throws ElementException {
|
public void doElementStart() throws ElementException {
|
||||||
if (getParent()!=null) {
|
if (getParent() != null) {
|
||||||
throw new ElementException("Need to be root tag");
|
throw new ElementException("Need to be root tag");
|
||||||
}
|
}
|
||||||
X4OLanguageModule elementLanguageModule = EldModuleLoader.getLanguageModule(getLanguageSession());
|
X4OLanguageModule elementLanguageModule = EldModuleLoader.getLanguageModule(getLanguageSession());
|
||||||
|
|
|
||||||
|
|
@ -38,14 +38,14 @@ public class NextAttributeElement extends AbstractElement {
|
||||||
@Override
|
@Override
|
||||||
public void doElementRun() throws ElementException {
|
public void doElementRun() throws ElementException {
|
||||||
String param = getAttributes().get("attributeName");
|
String param = getAttributes().get("attributeName");
|
||||||
if (param==null) {
|
if (param == null) {
|
||||||
throw new ElementException("attributeName may not be null");
|
throw new ElementException("attributeName may not be null");
|
||||||
}
|
}
|
||||||
if (getParent()==null) {
|
if (getParent() == null) {
|
||||||
throw new ElementException("can't be a root tag");
|
throw new ElementException("can't be a root tag");
|
||||||
}
|
}
|
||||||
if (getParent().getElementObject() instanceof ElementNamespaceAttribute) {
|
if (getParent().getElementObject() instanceof ElementNamespaceAttribute) {
|
||||||
((ElementNamespaceAttribute)getParent().getElementObject()).addNextAttribute(param);
|
((ElementNamespaceAttribute) getParent().getElementObject()).addNextAttribute(param);
|
||||||
} else {
|
} else {
|
||||||
throw new ElementException("Wrong parent class");
|
throw new ElementException("Wrong parent class");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,13 +41,13 @@ public class SkipPhaseElement extends AbstractElement {
|
||||||
@Override
|
@Override
|
||||||
public void doElementEnd() throws ElementException {
|
public void doElementEnd() throws ElementException {
|
||||||
String phase = getAttributes().get("name");
|
String phase = getAttributes().get("name");
|
||||||
if (phase==null) {
|
if (phase == null) {
|
||||||
throw new ElementException("'name' attribute is not set on: "+getElementClass().getId());
|
throw new ElementException("'name' attribute is not set on: " + getElementClass().getId());
|
||||||
}
|
}
|
||||||
if (getParent().getElementObject() instanceof ElementClass) {
|
if (getParent().getElementObject() instanceof ElementClass) {
|
||||||
((ElementClass)getParent().getElementObject()).addSkipPhase(phase);
|
((ElementClass) getParent().getElementObject()).addSkipPhase(phase);
|
||||||
} else {
|
} else {
|
||||||
throw new ElementException("Wrong parent class is not ElementClassAttribute but: "+getParent().getElementObject());
|
throw new ElementException("Wrong parent class is not ElementClassAttribute but: " + getParent().getElementObject());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.eld.lang;
|
package org.x4o.xml.eld.lang;
|
||||||
|
|
||||||
import org.x4o.xml.conv.text.StringSplitConverter;
|
import org.x4o.xml.conv.text.StringSplitConverter;
|
||||||
import org.x4o.xml.conv.text.StringSplitConverterStep;
|
import org.x4o.xml.conv.text.StringSplitConverterStep;
|
||||||
|
|
@ -36,11 +36,8 @@ import org.x4o.xml.element.ElementBindingHandlerException;
|
||||||
*/
|
*/
|
||||||
public class StringSplitConverterBindingHandler extends AbstractElementBindingHandler<StringSplitConverter> {
|
public class StringSplitConverterBindingHandler extends AbstractElementBindingHandler<StringSplitConverter> {
|
||||||
|
|
||||||
|
private final static Class<?>[] CLASSES_CHILD = new Class[] { StringSplitConverterStep.class };
|
||||||
private final static Class<?>[] CLASSES_CHILD = new Class[] {
|
|
||||||
StringSplitConverterStep.class
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
||||||
*/
|
*/
|
||||||
|
|
@ -58,9 +55,9 @@ public class StringSplitConverterBindingHandler extends AbstractElementBindingHa
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
* @see org.x4o.xml.element.AbstractElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void bindChild(Element childElement,StringSplitConverter parent, Object childObject) throws ElementBindingHandlerException {
|
public void bindChild(Element childElement, StringSplitConverter parent, Object childObject) throws ElementBindingHandlerException {
|
||||||
if (childObject instanceof StringSplitConverterStep) {
|
if (childObject instanceof StringSplitConverterStep) {
|
||||||
parent.addStringSplitConverterStep((StringSplitConverterStep)childObject);
|
parent.addStringSplitConverterStep((StringSplitConverterStep) childObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -68,8 +65,8 @@ public class StringSplitConverterBindingHandler extends AbstractElementBindingHa
|
||||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void createChilderen(Element parentElement,StringSplitConverter parentObject) throws ElementBindingHandlerException {
|
public void createChilderen(Element parentElement, StringSplitConverter parentObject) throws ElementBindingHandlerException {
|
||||||
for (StringSplitConverterStep child:parentObject.getStringSplitConverterSteps()) {
|
for (StringSplitConverterStep child : parentObject.getStringSplitConverterSteps()) {
|
||||||
createChild(parentElement, child);
|
createChild(parentElement, child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.eld.lang;
|
package org.x4o.xml.eld.lang;
|
||||||
|
|
||||||
import org.x4o.xml.conv.ObjectConverter;
|
import org.x4o.xml.conv.ObjectConverter;
|
||||||
import org.x4o.xml.conv.text.StringSplitConverterStep;
|
import org.x4o.xml.conv.text.StringSplitConverterStep;
|
||||||
|
|
@ -36,11 +36,8 @@ import org.x4o.xml.element.ElementBindingHandlerException;
|
||||||
*/
|
*/
|
||||||
public class StringSplitConverterStepBindingHandler extends AbstractElementBindingHandler<StringSplitConverterStep> {
|
public class StringSplitConverterStepBindingHandler extends AbstractElementBindingHandler<StringSplitConverterStep> {
|
||||||
|
|
||||||
|
private final static Class<?>[] CLASSES_CHILD = new Class[] { ObjectConverter.class };
|
||||||
private final static Class<?>[] CLASSES_CHILD = new Class[] {
|
|
||||||
ObjectConverter.class
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
||||||
*/
|
*/
|
||||||
|
|
@ -58,17 +55,17 @@ public class StringSplitConverterStepBindingHandler extends AbstractElementBindi
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
* @see org.x4o.xml.element.AbstractElementBindingHandler#bindChild(org.x4o.xml.element.Element, java.lang.Object, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void bindChild(Element childElement,StringSplitConverterStep parent, Object childObject) throws ElementBindingHandlerException {
|
public void bindChild(Element childElement, StringSplitConverterStep parent, Object childObject) throws ElementBindingHandlerException {
|
||||||
if (childObject instanceof ObjectConverter) {
|
if (childObject instanceof ObjectConverter) {
|
||||||
parent.setObjectConverter((ObjectConverter)childObject);
|
parent.setObjectConverter((ObjectConverter) childObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
* @see org.x4o.xml.element.AbstractElementBindingHandler#createChilderen(org.x4o.xml.element.Element, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void createChilderen(Element parentElement,StringSplitConverterStep parentObject) throws ElementBindingHandlerException {
|
public void createChilderen(Element parentElement, StringSplitConverterStep parentObject) throws ElementBindingHandlerException {
|
||||||
createChild(parentElement, parentObject.getObjectConverter());
|
createChild(parentElement, parentObject.getObjectConverter());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,15 +38,15 @@ import org.xml.sax.SAXException;
|
||||||
* @version 1.0 Aug 22, 2012
|
* @version 1.0 Aug 22, 2012
|
||||||
*/
|
*/
|
||||||
public class EldXsdLanguageTask extends AbstractX4OLanguageTask {
|
public class EldXsdLanguageTask extends AbstractX4OLanguageTask {
|
||||||
|
|
||||||
public static final String TASK_ID = "eld-xsd";
|
public static final String TASK_ID = "eld-xsd";
|
||||||
private static final String TASK_NAME = "ELD XSD Writer Task";
|
private static final String TASK_NAME = "ELD XSD Writer Task";
|
||||||
private static final String TASK_DESC = "Writes out the schema of the language elements.";
|
private static final String TASK_DESC = "Writes out the schema of the language elements.";
|
||||||
|
|
||||||
public EldXsdLanguageTask() {
|
public EldXsdLanguageTask() {
|
||||||
super(TASK_ID,TASK_NAME,TASK_DESC,EldXsdWriter.DEFAULT_PROPERTY_CONFIG);
|
super(TASK_ID, TASK_NAME, TASK_DESC, EldXsdWriter.DEFAULT_PROPERTY_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes this language task.
|
* Executes this language task.
|
||||||
*/
|
*/
|
||||||
|
|
@ -54,11 +54,11 @@ public class EldXsdLanguageTask extends AbstractX4OLanguageTask {
|
||||||
return new X4OLanguageTaskExecutor() {
|
return new X4OLanguageTaskExecutor() {
|
||||||
public void execute(X4OLanguage language) throws X4OLanguageTaskException {
|
public void execute(X4OLanguage language) throws X4OLanguageTaskException {
|
||||||
try {
|
try {
|
||||||
new EldXsdWriter(language,config).writeSchema();
|
new EldXsdWriter(language, config).writeSchema();
|
||||||
} catch (SAXException e) {
|
} catch (SAXException e) {
|
||||||
throw new X4OLanguageTaskException(config,e.getMessage(),e);
|
throw new X4OLanguageTaskException(config, e.getMessage(), e);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new X4OLanguageTaskException(config,e.getMessage(),e);
|
throw new X4OLanguageTaskException(config, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -39,16 +39,17 @@ import org.x4o.xml.lang.X4OLanguage;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EldXsdWriter creates XML Schema files from a x4o language.
|
* EldXsdWriter creates XML Schema files from a x4o language.
|
||||||
*
|
*
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Aug 8, 2012
|
* @version 1.0 Aug 8, 2012
|
||||||
*/
|
*/
|
||||||
public class EldXsdWriter {
|
public class EldXsdWriter {
|
||||||
|
|
||||||
private final static String PROPERTY_CONTEXT_PREFIX = SAX3PropertyConfig.X4O_PROPERTIES_PREFIX+"eld-xsd/";
|
private final static String PROPERTY_CONTEXT_PREFIX = SAX3PropertyConfig.X4O_PROPERTIES_PREFIX + "eld-xsd/";
|
||||||
public final static SAX3PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
public final static SAX3PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
||||||
|
|
||||||
|
//@formatter:off
|
||||||
public final static String OUTPUT_PATH = PROPERTY_CONTEXT_PREFIX+"output/path";
|
public final static String OUTPUT_PATH = PROPERTY_CONTEXT_PREFIX+"output/path";
|
||||||
public final static String OUTPUT_DOCUMENTATION = PROPERTY_CONTEXT_PREFIX+"output/documentation";
|
public final static String OUTPUT_DOCUMENTATION = PROPERTY_CONTEXT_PREFIX+"output/documentation";
|
||||||
public final static String FILTER_NAMESPACE = PROPERTY_CONTEXT_PREFIX+"filter/namespace";
|
public final static String FILTER_NAMESPACE = PROPERTY_CONTEXT_PREFIX+"filter/namespace";
|
||||||
|
|
@ -78,59 +79,60 @@ public class EldXsdWriter {
|
||||||
new PropertyConfigItem(PROLOG_XMLNS_DESC_ENABLE, Boolean.class, true)
|
new PropertyConfigItem(PROLOG_XMLNS_DESC_ENABLE, Boolean.class, true)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
//@formatter:on
|
||||||
|
|
||||||
private final X4OLanguage language;
|
private final X4OLanguage language;
|
||||||
private final SAX3PropertyConfig propertyConfig;
|
private final SAX3PropertyConfig propertyConfig;
|
||||||
|
|
||||||
public EldXsdWriter(X4OLanguage language,SAX3PropertyConfig parentConfig) {
|
public EldXsdWriter(X4OLanguage language, SAX3PropertyConfig parentConfig) {
|
||||||
this.language=language;
|
this.language = language;
|
||||||
this.propertyConfig=new SAX3PropertyConfig(DEFAULT_PROPERTY_CONFIG,PROPERTY_CONTEXT_PREFIX);
|
this.propertyConfig = new SAX3PropertyConfig(DEFAULT_PROPERTY_CONFIG, PROPERTY_CONTEXT_PREFIX);
|
||||||
this.propertyConfig.copyParentProperties(parentConfig);
|
this.propertyConfig.copyParentProperties(parentConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkNamespace(ElementNamespace ns) {
|
private void checkNamespace(ElementNamespace ns) {
|
||||||
if (ns.getSchemaResource()==null) {
|
if (ns.getSchemaResource() == null) {
|
||||||
throw new NullPointerException("Can't generate xsd for namespace without schemaResource uri: "+ns.getUri());
|
throw new NullPointerException("Can't generate xsd for namespace without schemaResource uri: " + ns.getUri());
|
||||||
}
|
}
|
||||||
if (ns.getSchemaResource().length()==0) {
|
if (ns.getSchemaResource().length() == 0) {
|
||||||
throw new NullPointerException("Can't generate xsd for namespace with empty schemaResource uri: "+ns.getUri());
|
throw new NullPointerException("Can't generate xsd for namespace with empty schemaResource uri: " + ns.getUri());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeSchema() throws SAXException, IOException {
|
public void writeSchema() throws SAXException, IOException {
|
||||||
File basePath = propertyConfig.getPropertyFile(OUTPUT_PATH);
|
File basePath = propertyConfig.getPropertyFile(OUTPUT_PATH);
|
||||||
String encoding = propertyConfig.getPropertyString(SAX3WriterXml.OUTPUT_ENCODING);
|
String encoding = propertyConfig.getPropertyString(SAX3WriterXml.OUTPUT_ENCODING);
|
||||||
String namespace = propertyConfig.getPropertyString(FILTER_NAMESPACE);
|
String namespace = propertyConfig.getPropertyString(FILTER_NAMESPACE);
|
||||||
if (basePath==null) {
|
if (basePath == null) {
|
||||||
throw new NullPointerException("Can't write schema to null output path.");
|
throw new NullPointerException("Can't write schema to null output path.");
|
||||||
}
|
}
|
||||||
if (!basePath.exists()) {
|
if (!basePath.exists()) {
|
||||||
basePath.mkdirs();
|
basePath.mkdirs();
|
||||||
}
|
}
|
||||||
if (namespace!=null) {
|
if (namespace != null) {
|
||||||
ElementNamespace ns = language.findElementNamespace(namespace);
|
ElementNamespace ns = language.findElementNamespace(namespace);
|
||||||
if (ns==null) {
|
if (ns == null) {
|
||||||
throw new NullPointerException("Could not find namespace: "+namespace);
|
throw new NullPointerException("Could not find namespace: " + namespace);
|
||||||
}
|
}
|
||||||
checkNamespace(ns);
|
checkNamespace(ns);
|
||||||
File outputFile = new File(basePath.getAbsolutePath()+File.separatorChar+ns.getSchemaResource());
|
File outputFile = new File(basePath.getAbsolutePath() + File.separatorChar + ns.getSchemaResource());
|
||||||
Writer wr = new OutputStreamWriter(new FileOutputStream(outputFile), encoding);
|
Writer wr = new OutputStreamWriter(new FileOutputStream(outputFile), encoding);
|
||||||
try {
|
try {
|
||||||
SAX3WriterXsd xsdWriter = new SAX3WriterXsd(wr,encoding);
|
SAX3WriterXsd xsdWriter = new SAX3WriterXsd(wr, encoding);
|
||||||
xsdWriter.getPropertyConfig().copyParentProperties(propertyConfig);
|
xsdWriter.getPropertyConfig().copyParentProperties(propertyConfig);
|
||||||
generateSchema(ns.getUri(), xsdWriter);
|
generateSchema(ns.getUri(), xsdWriter);
|
||||||
} finally {
|
} finally {
|
||||||
wr.close();
|
wr.close();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (X4OLanguageModule mod:language.getLanguageModules()) {
|
for (X4OLanguageModule mod : language.getLanguageModules()) {
|
||||||
for (ElementNamespace ns:mod.getElementNamespaces()) {
|
for (ElementNamespace ns : mod.getElementNamespaces()) {
|
||||||
checkNamespace(ns);
|
checkNamespace(ns);
|
||||||
File outputFile = new File(basePath.getAbsolutePath()+File.separatorChar+ns.getSchemaResource());
|
File outputFile = new File(basePath.getAbsolutePath() + File.separatorChar + ns.getSchemaResource());
|
||||||
Writer wr = new OutputStreamWriter(new FileOutputStream(outputFile), encoding);
|
Writer wr = new OutputStreamWriter(new FileOutputStream(outputFile), encoding);
|
||||||
try {
|
try {
|
||||||
SAX3WriterXsd xsdWriter = new SAX3WriterXsd(wr,encoding);
|
SAX3WriterXsd xsdWriter = new SAX3WriterXsd(wr, encoding);
|
||||||
xsdWriter.getPropertyConfig().copyParentProperties(propertyConfig);
|
xsdWriter.getPropertyConfig().copyParentProperties(propertyConfig);
|
||||||
generateSchema(ns.getUri(), xsdWriter);
|
generateSchema(ns.getUri(), xsdWriter);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
@ -139,27 +141,27 @@ public class EldXsdWriter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateSchema(String namespaceUri,SAX3WriterXsd xsdWriter) throws IOException {
|
private void generateSchema(String namespaceUri, SAX3WriterXsd xsdWriter) throws IOException {
|
||||||
ElementNamespace ns = language.findElementNamespace(namespaceUri);
|
ElementNamespace ns = language.findElementNamespace(namespaceUri);
|
||||||
if (ns==null) {
|
if (ns == null) {
|
||||||
throw new NullPointerException("Could not find namespace: "+namespaceUri);
|
throw new NullPointerException("Could not find namespace: " + namespaceUri);
|
||||||
}
|
}
|
||||||
String filterElement = propertyConfig.getPropertyString(FILTER_ELEMENT);
|
String filterElement = propertyConfig.getPropertyString(FILTER_ELEMENT);
|
||||||
EldXsdWriterElement xsdWriterElement = new EldXsdWriterElement(xsdWriter,language,propertyConfig);
|
EldXsdWriterElement xsdWriterElement = new EldXsdWriterElement(xsdWriter, language, propertyConfig);
|
||||||
xsdWriterElement.startNamespaces(namespaceUri);
|
xsdWriterElement.startNamespaces(namespaceUri);
|
||||||
xsdWriterElement.startSchema(ns);
|
xsdWriterElement.startSchema(ns);
|
||||||
for (ElementClass ec:ns.getElementClasses()) {
|
for (ElementClass ec : ns.getElementClasses()) {
|
||||||
if (filterElement!=null && !ec.getId().equals(filterElement)) {
|
if (filterElement != null && !ec.getId().equals(filterElement)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
xsdWriterElement.writeElementClass(ec,ns);
|
xsdWriterElement.writeElementClass(ec, ns);
|
||||||
}
|
}
|
||||||
for (ElementClass ec:ns.getElementClasses()) {
|
for (ElementClass ec : ns.getElementClasses()) {
|
||||||
if (filterElement!=null && !ec.getId().equals(filterElement)) {
|
if (filterElement != null && !ec.getId().equals(filterElement)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
xsdWriterElement.writeElement(ec,ns);
|
xsdWriterElement.writeElement(ec, ns);
|
||||||
}
|
}
|
||||||
xsdWriterElement.endSchema();
|
xsdWriterElement.endSchema();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.eld.xsd;
|
package org.x4o.xml.eld.xsd;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
@ -59,35 +59,35 @@ import org.xml.sax.helpers.AttributesImpl;
|
||||||
* @version 1.0 Aug 8, 2012
|
* @version 1.0 Aug 8, 2012
|
||||||
*/
|
*/
|
||||||
public class EldXsdWriterElement {
|
public class EldXsdWriterElement {
|
||||||
|
|
||||||
private SAX3PropertyConfig propertyConfig;
|
private SAX3PropertyConfig propertyConfig;
|
||||||
protected X4OLanguage language = null;
|
protected X4OLanguage language = null;
|
||||||
protected SAX3WriterXsd xsdWriter = null;
|
protected SAX3WriterXsd xsdWriter = null;
|
||||||
protected String writeNamespace = null;
|
protected String writeNamespace = null;
|
||||||
protected Map<String, String> namespaces = null;
|
protected Map<String, String> namespaces = null;
|
||||||
|
|
||||||
public EldXsdWriterElement(SAX3WriterXsd xsdWriter,X4OLanguage language,SAX3PropertyConfig propertyConfig) {
|
public EldXsdWriterElement(SAX3WriterXsd xsdWriter, X4OLanguage language, SAX3PropertyConfig propertyConfig) {
|
||||||
this.xsdWriter=xsdWriter;
|
this.xsdWriter = xsdWriter;
|
||||||
this.language=language;
|
this.language = language;
|
||||||
this.propertyConfig=propertyConfig;
|
this.propertyConfig = propertyConfig;
|
||||||
this.namespaces=new HashMap<String,String>(10);
|
this.namespaces = new HashMap<String, String>(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startNamespace(String uri,String prefixNamespace) {
|
private void startNamespace(String uri, String prefixNamespace) {
|
||||||
String prefix = namespaces.get(uri);
|
String prefix = namespaces.get(uri);
|
||||||
if (prefix!=null) {
|
if (prefix != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (uri.equals(writeNamespace)) {
|
if (uri.equals(writeNamespace)) {
|
||||||
namespaces.put(uri, "this");
|
namespaces.put(uri, "this");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (prefixNamespace!=null) {
|
if (prefixNamespace != null) {
|
||||||
namespaces.put(uri, prefixNamespace); // let user define it
|
namespaces.put(uri, prefixNamespace); // let user define it
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
StringBuilder buf = new StringBuilder(20);
|
StringBuilder buf = new StringBuilder(20);
|
||||||
for (char c:uri.toLowerCase().toCharArray()) {
|
for (char c : uri.toLowerCase().toCharArray()) {
|
||||||
if (Character.isLetter(c)) {
|
if (Character.isLetter(c)) {
|
||||||
buf.append(c);
|
buf.append(c);
|
||||||
}
|
}
|
||||||
|
|
@ -107,37 +107,37 @@ public class EldXsdWriterElement {
|
||||||
}
|
}
|
||||||
namespaces.put(uri, prefix);
|
namespaces.put(uri, prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startNamespaces(String namespaceUri) {
|
public void startNamespaces(String namespaceUri) {
|
||||||
|
|
||||||
this.writeNamespace=namespaceUri;
|
this.writeNamespace = namespaceUri;
|
||||||
this.namespaces.clear();
|
this.namespaces.clear();
|
||||||
|
|
||||||
// redo this mess, add nice find for binding handlers
|
// redo this mess, add nice find for binding handlers
|
||||||
for (X4OLanguageModule modContext:language.getLanguageModules()) {
|
for (X4OLanguageModule modContext : language.getLanguageModules()) {
|
||||||
for (ElementNamespace nsContext:modContext.getElementNamespaces()) {
|
for (ElementNamespace nsContext : modContext.getElementNamespaces()) {
|
||||||
for (ElementClass ec:nsContext.getElementClasses()) {
|
for (ElementClass ec : nsContext.getElementClasses()) {
|
||||||
Class<?> objectClass = null;
|
Class<?> objectClass = null;
|
||||||
if (ec.getObjectClass()!=null) {
|
if (ec.getObjectClass() != null) {
|
||||||
objectClass = ec.getObjectClass();
|
objectClass = ec.getObjectClass();
|
||||||
for (X4OLanguageModule mod:language.getLanguageModules()) {
|
for (X4OLanguageModule mod : language.getLanguageModules()) {
|
||||||
for (ElementNamespace ns:mod.getElementNamespaces()) {
|
for (ElementNamespace ns : mod.getElementNamespaces()) {
|
||||||
for (ElementClass checkClass:ns.getElementClasses()) {
|
for (ElementClass checkClass : ns.getElementClasses()) {
|
||||||
if (checkClass.getObjectClass()==null) {
|
if (checkClass.getObjectClass() == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Class<?> checkObjectClass = checkClass.getObjectClass();
|
Class<?> checkObjectClass = checkClass.getObjectClass();
|
||||||
List<ElementBindingHandler> b = language.findElementBindingHandlers(objectClass,checkObjectClass);
|
List<ElementBindingHandler> b = language.findElementBindingHandlers(objectClass, checkObjectClass);
|
||||||
if (b.isEmpty()==false) {
|
if (b.isEmpty() == false) {
|
||||||
startNamespace(ns.getUri(),ns.getSchemaPrefix());
|
startNamespace(ns.getUri(), ns.getSchemaPrefix());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (ElementInterface ei:language.findElementInterfaces(objectClass)) {
|
for (ElementInterface ei : language.findElementInterfaces(objectClass)) {
|
||||||
List<String> eiTags = ei.getElementParents(namespaceUri);
|
List<String> eiTags = ei.getElementParents(namespaceUri);
|
||||||
if (eiTags!=null) {
|
if (eiTags != null) {
|
||||||
startNamespace(nsContext.getUri(),nsContext.getSchemaPrefix());
|
startNamespace(nsContext.getUri(), nsContext.getSchemaPrefix());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -145,10 +145,9 @@ public class EldXsdWriterElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static final String COMMENT_FORMAT = "%1$-20s %2$s";
|
private static final String COMMENT_FORMAT = "%1$-20s %2$s";
|
||||||
|
|
||||||
private void prologWriteGenerator() throws IOException {
|
private void prologWriteGenerator() throws IOException {
|
||||||
if (propertyConfig.getPropertyBoolean(EldXsdWriter.PROLOG_SEPERATOR_ENABLE)) {
|
if (propertyConfig.getPropertyBoolean(EldXsdWriter.PROLOG_SEPERATOR_ENABLE)) {
|
||||||
xsdWriter.printComment(propertyConfig.getPropertyString(EldXsdWriter.PROLOG_SEPERATOR_LINE));
|
xsdWriter.printComment(propertyConfig.getPropertyString(EldXsdWriter.PROLOG_SEPERATOR_LINE));
|
||||||
|
|
@ -161,26 +160,26 @@ public class EldXsdWriterElement {
|
||||||
String generatedBy = propertyConfig.getPropertyString(EldXsdWriter.PROLOG_GENERATED_BY, EldXsdWriter.class.getSimpleName());
|
String generatedBy = propertyConfig.getPropertyString(EldXsdWriter.PROLOG_GENERATED_BY, EldXsdWriter.class.getSimpleName());
|
||||||
String generatedVersion = propertyConfig.getPropertyString(EldXsdWriter.PROLOG_GENERATED_VERSION);
|
String generatedVersion = propertyConfig.getPropertyString(EldXsdWriter.PROLOG_GENERATED_VERSION);
|
||||||
StringBuilder b = new StringBuilder();
|
StringBuilder b = new StringBuilder();
|
||||||
b.append(chEnter + chTab + String.format(COMMENT_FORMAT,"GeneratedBy:",generatedBy));
|
b.append(chEnter + chTab + String.format(COMMENT_FORMAT, "GeneratedBy:", generatedBy));
|
||||||
b.append(chEnter + chTab + String.format(COMMENT_FORMAT,"GeneratedDate:",new Date()));
|
b.append(chEnter + chTab + String.format(COMMENT_FORMAT, "GeneratedDate:", new Date()));
|
||||||
if (generatedVersion != null && !generatedVersion.isEmpty()) {
|
if (generatedVersion != null && !generatedVersion.isEmpty()) {
|
||||||
b.append(chEnter + chTab + String.format(COMMENT_FORMAT,"GeneratedVersion:",generatedVersion));
|
b.append(chEnter + chTab + String.format(COMMENT_FORMAT, "GeneratedVersion:", generatedVersion));
|
||||||
}
|
}
|
||||||
b.append(chEnter + chTab + String.format(COMMENT_FORMAT,"LanguageName:",language.getLanguageName()));
|
b.append(chEnter + chTab + String.format(COMMENT_FORMAT, "LanguageName:", language.getLanguageName()));
|
||||||
b.append(chEnter + chTab + String.format(COMMENT_FORMAT,"LanguageVersion:",language.getLanguageVersion()));
|
b.append(chEnter + chTab + String.format(COMMENT_FORMAT, "LanguageVersion:", language.getLanguageVersion()));
|
||||||
b.append(chEnter);
|
b.append(chEnter);
|
||||||
xsdWriter.printComment(b.toString());
|
xsdWriter.printComment(b.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void prologWriteNSMeta(ElementNamespace ns) throws IOException {
|
private void prologWriteNSMeta(ElementNamespace ns) throws IOException {
|
||||||
String chEnter = propertyConfig.getPropertyString(SAX3WriterXml.OUTPUT_CHAR_NEWLINE);
|
String chEnter = propertyConfig.getPropertyString(SAX3WriterXml.OUTPUT_CHAR_NEWLINE);
|
||||||
String chTab = propertyConfig.getPropertyString(SAX3WriterXml.OUTPUT_CHAR_TAB);
|
String chTab = propertyConfig.getPropertyString(SAX3WriterXml.OUTPUT_CHAR_TAB);
|
||||||
if (propertyConfig.getPropertyBoolean(EldXsdWriter.PROLOG_XMLNS_INFO_ENABLE)) {
|
if (propertyConfig.getPropertyBoolean(EldXsdWriter.PROLOG_XMLNS_INFO_ENABLE)) {
|
||||||
StringBuilder b = new StringBuilder();
|
StringBuilder b = new StringBuilder();
|
||||||
b.append(chEnter + chTab + String.format(COMMENT_FORMAT,"NSId:",ns.getId()));
|
b.append(chEnter + chTab + String.format(COMMENT_FORMAT, "NSId:", ns.getId()));
|
||||||
b.append(chEnter + chTab + String.format(COMMENT_FORMAT,"NSName:",ns.getName()));
|
b.append(chEnter + chTab + String.format(COMMENT_FORMAT, "NSName:", ns.getName()));
|
||||||
b.append(chEnter + chTab + String.format(COMMENT_FORMAT,"NSUri:",ns.getUri()));
|
b.append(chEnter + chTab + String.format(COMMENT_FORMAT, "NSUri:", ns.getUri()));
|
||||||
b.append(chEnter + chTab + String.format(COMMENT_FORMAT,"NSUriSchema:",ns.getSchemaUri()));
|
b.append(chEnter + chTab + String.format(COMMENT_FORMAT, "NSUriSchema:", ns.getSchemaUri()));
|
||||||
b.append(chEnter);
|
b.append(chEnter);
|
||||||
xsdWriter.printComment(b.toString());
|
xsdWriter.printComment(b.toString());
|
||||||
}
|
}
|
||||||
|
|
@ -204,15 +203,15 @@ public class EldXsdWriterElement {
|
||||||
xsdWriter.printComment(buf.toString());
|
xsdWriter.printComment(buf.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startSchema(ElementNamespace ns) throws IOException {
|
public void startSchema(ElementNamespace ns) throws IOException {
|
||||||
|
|
||||||
xsdWriter.startDocument();
|
xsdWriter.startDocument();
|
||||||
|
|
||||||
prologWriteGenerator();
|
prologWriteGenerator();
|
||||||
prologWriteNSMeta(ns);
|
prologWriteNSMeta(ns);
|
||||||
|
|
||||||
for (String uri:namespaces.keySet()) {
|
for (String uri : namespaces.keySet()) {
|
||||||
String prefix = namespaces.get(uri);
|
String prefix = namespaces.get(uri);
|
||||||
try {
|
try {
|
||||||
xsdWriter.getContentWriterWrapped().startPrefixMapping(prefix, uri);
|
xsdWriter.getContentWriterWrapped().startPrefixMapping(prefix, uri);
|
||||||
|
|
@ -220,25 +219,25 @@ public class EldXsdWriterElement {
|
||||||
throw new IOException(e);
|
throw new IOException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AttributesImpl atts = new AttributesImpl();
|
AttributesImpl atts = new AttributesImpl();
|
||||||
atts.addAttribute ("", "version", "", "", "1.0");
|
atts.addAttribute("", "version", "", "", "1.0");
|
||||||
atts.addAttribute ("", "elementFormDefault", "", "", "qualified");
|
atts.addAttribute("", "elementFormDefault", "", "", "qualified");
|
||||||
atts.addAttribute ("", "attributeFormDefault", "", "", "unqualified");
|
atts.addAttribute("", "attributeFormDefault", "", "", "unqualified");
|
||||||
atts.addAttribute ("", "targetNamespace", "", "", ns.getUri());
|
atts.addAttribute("", "targetNamespace", "", "", ns.getUri());
|
||||||
xsdWriter.printTagStart(Tag.schema, atts);
|
xsdWriter.printTagStart(Tag.schema, atts);
|
||||||
|
|
||||||
for (String uri:namespaces.keySet()) {
|
for (String uri : namespaces.keySet()) {
|
||||||
if (ns.getUri().equals(uri)) {
|
if (ns.getUri().equals(uri)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ElementNamespace nsContext = language.findElementNamespace(uri);
|
ElementNamespace nsContext = language.findElementNamespace(uri);
|
||||||
xsdWriter.printXsdImport(nsContext.getUri(), nsContext.getSchemaResource());
|
xsdWriter.printXsdImport(nsContext.getUri(), nsContext.getSchemaResource());
|
||||||
}
|
}
|
||||||
|
|
||||||
writeNamespaceAttributes(ns);
|
writeNamespaceAttributes(ns);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void endSchema() throws IOException {
|
public void endSchema() throws IOException {
|
||||||
xsdWriter.printTagEnd(Tag.schema);
|
xsdWriter.printTagEnd(Tag.schema);
|
||||||
try {
|
try {
|
||||||
|
|
@ -248,122 +247,122 @@ public class EldXsdWriterElement {
|
||||||
}
|
}
|
||||||
xsdWriter.endDocument();
|
xsdWriter.endDocument();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeNamespaceAttributes(ElementNamespace ns) throws IOException {
|
private void writeNamespaceAttributes(ElementNamespace ns) throws IOException {
|
||||||
for (ElementNamespaceAttribute eah:ns.getElementNamespaceAttributes()) {
|
for (ElementNamespaceAttribute eah : ns.getElementNamespaceAttributes()) {
|
||||||
AttributesImpl atts = new AttributesImpl();
|
AttributesImpl atts = new AttributesImpl();
|
||||||
atts.addAttribute ("", "name", "", "", eah.getAttributeName());
|
atts.addAttribute("", "name", "", "", eah.getAttributeName());
|
||||||
atts.addAttribute ("", "type", "", "", "string");
|
atts.addAttribute("", "type", "", "", "string");
|
||||||
writeElementAttribute(eah,atts);
|
writeElementAttribute(eah, atts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeElementClass(ElementClass ec,ElementNamespace nsWrite) throws IOException {
|
public void writeElementClass(ElementClass ec, ElementNamespace nsWrite) throws IOException {
|
||||||
|
|
||||||
AttributesImpl atts = new AttributesImpl();
|
AttributesImpl atts = new AttributesImpl();
|
||||||
if (nsWrite.getLanguageRoot()!=null && nsWrite.getLanguageRoot()) {
|
if (nsWrite.getLanguageRoot() != null && nsWrite.getLanguageRoot()) {
|
||||||
atts.addAttribute ("", "name", "", "", ec.getId());
|
atts.addAttribute("", "name", "", "", ec.getId());
|
||||||
xsdWriter.printTagStart(Tag.element, atts);// Only in the language root xsd there is an element.
|
xsdWriter.printTagStart(Tag.element, atts);// Only in the language root xsd there is an element.
|
||||||
|
|
||||||
atts = new AttributesImpl();
|
atts = new AttributesImpl();
|
||||||
xsdWriter.printTagStart(Tag.complexType, atts);
|
xsdWriter.printTagStart(Tag.complexType, atts);
|
||||||
} else {
|
} else {
|
||||||
atts.addAttribute ("", "name", "", "", ec.getId()+"Type");
|
atts.addAttribute("", "name", "", "", ec.getId() + "Type");
|
||||||
xsdWriter.printTagStart(Tag.complexType, atts);
|
xsdWriter.printTagStart(Tag.complexType, atts);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ec.getSchemaContentBase()!=null) {
|
if (ec.getSchemaContentBase() != null) {
|
||||||
atts = new AttributesImpl();
|
atts = new AttributesImpl();
|
||||||
if (ec.getSchemaContentComplex()!=null && ec.getSchemaContentComplex()) {
|
if (ec.getSchemaContentComplex() != null && ec.getSchemaContentComplex()) {
|
||||||
if (ec.getSchemaContentMixed()!=null && ec.getSchemaContentMixed()) {
|
if (ec.getSchemaContentMixed() != null && ec.getSchemaContentMixed()) {
|
||||||
atts.addAttribute ("", "mixed", "", "", "true");
|
atts.addAttribute("", "mixed", "", "", "true");
|
||||||
}
|
}
|
||||||
xsdWriter.printTagStart(Tag.complexContent, atts);
|
xsdWriter.printTagStart(Tag.complexContent, atts);
|
||||||
} else {
|
} else {
|
||||||
xsdWriter.printTagStart(Tag.simpleContent, atts);
|
xsdWriter.printTagStart(Tag.simpleContent, atts);
|
||||||
}
|
}
|
||||||
atts = new AttributesImpl();
|
atts = new AttributesImpl();
|
||||||
atts.addAttribute ("", "base", "", "", ec.getSchemaContentBase());
|
atts.addAttribute("", "base", "", "", ec.getSchemaContentBase());
|
||||||
xsdWriter.printTagStart(Tag.extension, atts);
|
xsdWriter.printTagStart(Tag.extension, atts);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ec.getSchemaContentBase()==null) {
|
if (ec.getSchemaContentBase() == null) {
|
||||||
atts = new AttributesImpl();
|
atts = new AttributesImpl();
|
||||||
atts.addAttribute ("", "minOccurs", "", "", "0"); // TODO: make unordered elements
|
atts.addAttribute("", "minOccurs", "", "", "0"); // TODO: make unordered elements
|
||||||
atts.addAttribute ("", "maxOccurs", "", "", "unbounded");
|
atts.addAttribute("", "maxOccurs", "", "", "unbounded");
|
||||||
xsdWriter.printTagStart(Tag.choice, atts);
|
xsdWriter.printTagStart(Tag.choice, atts);
|
||||||
|
|
||||||
for (X4OLanguageModule mod:language.getLanguageModules()) {
|
for (X4OLanguageModule mod : language.getLanguageModules()) {
|
||||||
for (ElementNamespace ns:mod.getElementNamespaces()) {
|
for (ElementNamespace ns : mod.getElementNamespaces()) {
|
||||||
writeElementClassNamespaces(ec,nsWrite,ns);
|
writeElementClassNamespaces(ec, nsWrite, ns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xsdWriter.printTagEnd(Tag.choice);
|
xsdWriter.printTagEnd(Tag.choice);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> attrNames = new ArrayList<String>(30);
|
List<String> attrNames = new ArrayList<String>(30);
|
||||||
for (ElementClassAttribute eca:ec.getElementClassAttributes()) {
|
for (ElementClassAttribute eca : ec.getElementClassAttributes()) {
|
||||||
attrNames.add(eca.getId());
|
attrNames.add(eca.getId());
|
||||||
atts = new AttributesImpl();
|
atts = new AttributesImpl();
|
||||||
atts.addAttribute ("", "name", "", "", eca.getId());
|
atts.addAttribute("", "name", "", "", eca.getId());
|
||||||
atts.addAttribute ("", "type", "", "", "string");
|
atts.addAttribute("", "type", "", "", "string");
|
||||||
if (eca.getRequired()!=null && eca.getRequired()) {
|
if (eca.getRequired() != null && eca.getRequired()) {
|
||||||
atts.addAttribute ("", "use", "", "", "required");
|
atts.addAttribute("", "use", "", "", "required");
|
||||||
}
|
}
|
||||||
writeElementAttribute(eca,atts);
|
writeElementAttribute(eca, atts);
|
||||||
|
|
||||||
for (String alias:eca.getAttributeAliases()) {
|
for (String alias : eca.getAttributeAliases()) {
|
||||||
attrNames.add(alias);
|
attrNames.add(alias);
|
||||||
atts = new AttributesImpl();
|
atts = new AttributesImpl();
|
||||||
atts.addAttribute ("", "name", "", "", alias);
|
atts.addAttribute("", "name", "", "", alias);
|
||||||
atts.addAttribute ("", "type", "", "", "string");
|
atts.addAttribute("", "type", "", "", "string");
|
||||||
writeElementAttribute(null,atts);
|
writeElementAttribute(null, atts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ec.getAutoAttributes()!=null && ec.getAutoAttributes()==false) {
|
if (ec.getAutoAttributes() != null && ec.getAutoAttributes() == false) {
|
||||||
// oke, reverse this if and rm whitespace.
|
// oke, reverse this if and rm whitespace.
|
||||||
try {
|
try {
|
||||||
xsdWriter.getContentWriterWrapped().ignorableWhitespace(' ');
|
xsdWriter.getContentWriterWrapped().ignorableWhitespace(' ');
|
||||||
} catch (SAXException e) {
|
} catch (SAXException e) {
|
||||||
throw new IOException(e);
|
throw new IOException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (ec.getObjectClass()!=null) {
|
if (ec.getObjectClass() != null) {
|
||||||
for (Method m:ec.getObjectClass().getMethods()) {
|
for (Method m : ec.getObjectClass().getMethods()) {
|
||||||
if (m.getName().startsWith("set")) {
|
if (m.getName().startsWith("set")) {
|
||||||
String n = m.getName().substring(3);
|
String n = m.getName().substring(3);
|
||||||
if (m.getParameterTypes().length==0) {
|
if (m.getParameterTypes().length == 0) {
|
||||||
continue; // set without parameters
|
continue; // set without parameters
|
||||||
}
|
}
|
||||||
if (n.length()<2) {
|
if (n.length() < 2) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
n = n.substring(0,1).toLowerCase()+n.substring(1,n.length());
|
n = n.substring(0, 1).toLowerCase() + n.substring(1, n.length());
|
||||||
if (attrNames.contains(n)) {
|
if (attrNames.contains(n)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
attrNames.add(n);
|
attrNames.add(n);
|
||||||
atts = new AttributesImpl();
|
atts = new AttributesImpl();
|
||||||
atts.addAttribute ("", "name", "", "", n);
|
atts.addAttribute("", "name", "", "", n);
|
||||||
|
|
||||||
Class<?> type = m.getParameterTypes()[0]; // TODO make full list for auto attribute type resolving.
|
Class<?> type = m.getParameterTypes()[0]; // TODO make full list for auto attribute type resolving.
|
||||||
if (type.equals(Object.class)) {
|
if (type.equals(Object.class)) {
|
||||||
atts.addAttribute ("", "type", "", "", "string");// object is always string because is always assignable
|
atts.addAttribute("", "type", "", "", "string");// object is always string because is always assignable
|
||||||
} else if (type.isAssignableFrom(Boolean.class) | type.isAssignableFrom(Boolean.TYPE)) {
|
} else if (type.isAssignableFrom(Boolean.class) | type.isAssignableFrom(Boolean.TYPE)) {
|
||||||
atts.addAttribute ("", "type", "", "", "boolean");
|
atts.addAttribute("", "type", "", "", "boolean");
|
||||||
} else if (type.isAssignableFrom(Integer.class) | type.isAssignableFrom(Integer.TYPE)) {
|
} else if (type.isAssignableFrom(Integer.class) | type.isAssignableFrom(Integer.TYPE)) {
|
||||||
atts.addAttribute ("", "type", "", "", "integer");
|
atts.addAttribute("", "type", "", "", "integer");
|
||||||
} else if (type.isAssignableFrom(Long.class) | type.isAssignableFrom(Long.TYPE)) {
|
} else if (type.isAssignableFrom(Long.class) | type.isAssignableFrom(Long.TYPE)) {
|
||||||
atts.addAttribute ("", "type", "", "", "long");
|
atts.addAttribute("", "type", "", "", "long");
|
||||||
} else if (type.isAssignableFrom(Float.class) | type.isAssignableFrom(Float.TYPE)) {
|
} else if (type.isAssignableFrom(Float.class) | type.isAssignableFrom(Float.TYPE)) {
|
||||||
atts.addAttribute ("", "type", "", "", "float");
|
atts.addAttribute("", "type", "", "", "float");
|
||||||
} else if (type.isAssignableFrom(Double.class) | type.isAssignableFrom(Double.TYPE)) {
|
} else if (type.isAssignableFrom(Double.class) | type.isAssignableFrom(Double.TYPE)) {
|
||||||
atts.addAttribute ("", "type", "", "", "double");
|
atts.addAttribute("", "type", "", "", "double");
|
||||||
} else {
|
} else {
|
||||||
atts.addAttribute ("", "type", "", "", "string");
|
atts.addAttribute("", "type", "", "", "string");
|
||||||
}
|
}
|
||||||
xsdWriter.printTagStartEnd(Tag.attribute, atts);
|
xsdWriter.printTagStartEnd(Tag.attribute, atts);
|
||||||
}
|
}
|
||||||
|
|
@ -373,97 +372,96 @@ public class EldXsdWriterElement {
|
||||||
xsdWriter.printTagStartEnd(Tag.anyAttribute, atts);
|
xsdWriter.printTagStartEnd(Tag.anyAttribute, atts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ec.getSchemaContentBase()!=null) {
|
if (ec.getSchemaContentBase() != null) {
|
||||||
xsdWriter.printTagEnd(Tag.extension);
|
xsdWriter.printTagEnd(Tag.extension);
|
||||||
if (ec.getSchemaContentComplex()!=null && ec.getSchemaContentComplex()) {
|
if (ec.getSchemaContentComplex() != null && ec.getSchemaContentComplex()) {
|
||||||
xsdWriter.printTagEnd(Tag.complexContent);
|
xsdWriter.printTagEnd(Tag.complexContent);
|
||||||
} else {
|
} else {
|
||||||
xsdWriter.printTagEnd(Tag.simpleContent);
|
xsdWriter.printTagEnd(Tag.simpleContent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xsdWriter.printTagEnd(Tag.complexType);
|
xsdWriter.printTagEnd(Tag.complexType);
|
||||||
if (nsWrite.getLanguageRoot()!=null && nsWrite.getLanguageRoot()) {
|
if (nsWrite.getLanguageRoot() != null && nsWrite.getLanguageRoot()) {
|
||||||
xsdWriter.printTagEnd(Tag.element);
|
xsdWriter.printTagEnd(Tag.element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeElementClassNamespaces(ElementClass ecWrite,ElementNamespace nsWrite,ElementNamespace ns) throws IOException {
|
private void writeElementClassNamespaces(ElementClass ecWrite, ElementNamespace nsWrite, ElementNamespace ns) throws IOException {
|
||||||
AttributesImpl atts = new AttributesImpl();
|
AttributesImpl atts = new AttributesImpl();
|
||||||
List<String> refElements = new ArrayList<String>(20);
|
List<String> refElements = new ArrayList<String>(20);
|
||||||
for (ElementClass checkClass:ns.getElementClasses()) {
|
for (ElementClass checkClass : ns.getElementClasses()) {
|
||||||
List<String> parents = checkClass.getElementParents(nsWrite.getUri());
|
List<String> parents = checkClass.getElementParents(nsWrite.getUri());
|
||||||
if (parents!=null && parents.contains(ecWrite.getId())) {
|
if (parents != null && parents.contains(ecWrite.getId())) {
|
||||||
refElements.add(checkClass.getId());
|
refElements.add(checkClass.getId());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (checkClass.getObjectClass()==null) {
|
if (checkClass.getObjectClass() == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (ElementInterface ei:language.findElementInterfaces(checkClass.getObjectClass())) {
|
for (ElementInterface ei : language.findElementInterfaces(checkClass.getObjectClass())) {
|
||||||
parents = ei.getElementParents(nsWrite.getUri());
|
parents = ei.getElementParents(nsWrite.getUri());
|
||||||
if (parents!=null && parents.contains(ecWrite.getId())) {
|
if (parents != null && parents.contains(ecWrite.getId())) {
|
||||||
refElements.add(checkClass.getId());
|
refElements.add(checkClass.getId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ecWrite.getObjectClass()==null) {
|
if (ecWrite.getObjectClass() == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Class<?> objectClass = ecWrite.getObjectClass();
|
Class<?> objectClass = ecWrite.getObjectClass();
|
||||||
Class<?> checkObjectClass = checkClass.getObjectClass();
|
Class<?> checkObjectClass = checkClass.getObjectClass();
|
||||||
List<ElementBindingHandler> b = language.findElementBindingHandlers(objectClass,checkObjectClass);
|
List<ElementBindingHandler> b = language.findElementBindingHandlers(objectClass, checkObjectClass);
|
||||||
if (b.isEmpty()==false) {
|
if (b.isEmpty() == false) {
|
||||||
refElements.add(checkClass.getId());
|
refElements.add(checkClass.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (refElements.isEmpty()==false) {
|
if (refElements.isEmpty() == false) {
|
||||||
Set<String> s = new HashSet<String>(refElements.size());
|
Set<String> s = new HashSet<String>(refElements.size());
|
||||||
s.addAll(refElements);
|
s.addAll(refElements);
|
||||||
List<String> r = new ArrayList<String>(s.size());
|
List<String> r = new ArrayList<String>(s.size());
|
||||||
r.addAll(s);
|
r.addAll(s);
|
||||||
Collections.sort(r);
|
Collections.sort(r);
|
||||||
|
|
||||||
String prefix = namespaces.get(ns.getUri());
|
String prefix = namespaces.get(ns.getUri());
|
||||||
for (String refElement:r) {
|
for (String refElement : r) {
|
||||||
atts = new AttributesImpl();
|
atts = new AttributesImpl();
|
||||||
if (nsWrite.getLanguageRoot()!=null && nsWrite.getLanguageRoot()) {
|
if (nsWrite.getLanguageRoot() != null && nsWrite.getLanguageRoot()) {
|
||||||
atts.addAttribute ("", "ref", "", "", prefix+":"+refElement);
|
atts.addAttribute("", "ref", "", "", prefix + ":" + refElement);
|
||||||
} else if (nsWrite.getUri().equals(ns.getUri())==false) {
|
} else if (nsWrite.getUri().equals(ns.getUri()) == false) {
|
||||||
atts.addAttribute ("", "ref", "", "", prefix+":"+refElement);
|
atts.addAttribute("", "ref", "", "", prefix + ":" + refElement);
|
||||||
} else {
|
} else {
|
||||||
atts.addAttribute ("", "name", "", "", refElement);
|
atts.addAttribute("", "name", "", "", refElement);
|
||||||
atts.addAttribute ("", "type", "", "", prefix+":"+refElement+"Type");
|
atts.addAttribute("", "type", "", "", prefix + ":" + refElement + "Type");
|
||||||
}
|
}
|
||||||
xsdWriter.printTagStartEnd(Tag.element,atts);
|
xsdWriter.printTagStartEnd(Tag.element, atts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void writeElement(ElementClass ec, ElementNamespace nsWrite) throws IOException {
|
||||||
public void writeElement(ElementClass ec,ElementNamespace nsWrite) throws IOException {
|
if (nsWrite.getLanguageRoot() != null && nsWrite.getLanguageRoot()) {
|
||||||
if (nsWrite.getLanguageRoot()!=null && nsWrite.getLanguageRoot()) {
|
|
||||||
return; // is done in writeElementClass
|
return; // is done in writeElementClass
|
||||||
}
|
}
|
||||||
AttributesImpl atts = new AttributesImpl();
|
AttributesImpl atts = new AttributesImpl();
|
||||||
atts.addAttribute ("", "name", "", "", ec.getId());
|
atts.addAttribute("", "name", "", "", ec.getId());
|
||||||
atts.addAttribute ("", "type", "", "", "this:"+ec.getId()+"Type");
|
atts.addAttribute("", "type", "", "", "this:" + ec.getId() + "Type");
|
||||||
xsdWriter.printTagStart(Tag.element,atts);
|
xsdWriter.printTagStart(Tag.element, atts);
|
||||||
writeElementMetaBase(ec);
|
writeElementMetaBase(ec);
|
||||||
xsdWriter.printTagEnd(Tag.element);
|
xsdWriter.printTagEnd(Tag.element);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeElementAttribute(ElementMetaBase base,AttributesImpl atts) throws IOException {
|
private void writeElementAttribute(ElementMetaBase base, AttributesImpl atts) throws IOException {
|
||||||
xsdWriter.printTagStart(Tag.attribute,atts);
|
xsdWriter.printTagStart(Tag.attribute, atts);
|
||||||
writeElementMetaBase(base);
|
writeElementMetaBase(base);
|
||||||
xsdWriter.printTagEnd(Tag.attribute);
|
xsdWriter.printTagEnd(Tag.attribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeElementMetaBase(ElementMetaBase base) throws IOException {
|
private void writeElementMetaBase(ElementMetaBase base) throws IOException {
|
||||||
if (base==null) {
|
if (base == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (base.getDescription()==null) {
|
if (base.getDescription() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!propertyConfig.getPropertyBoolean(EldXsdWriter.OUTPUT_DOCUMENTATION)) {
|
if (!propertyConfig.getPropertyBoolean(EldXsdWriter.OUTPUT_DOCUMENTATION)) {
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
@ -47,46 +47,47 @@ public abstract class AbstractElement implements Element {
|
||||||
/** The ElementClass */
|
/** The ElementClass */
|
||||||
private ElementClass elementClass = null;
|
private ElementClass elementClass = null;
|
||||||
/** The attributes */
|
/** The attributes */
|
||||||
private Map<String,String> attributes = new HashMap<String,String>(10);
|
private Map<String, String> attributes = new HashMap<String, String>(10);
|
||||||
/** The Childeren */
|
/** The Childeren */
|
||||||
private List<Element> childeren = new ArrayList<Element>(10);
|
private List<Element> childeren = new ArrayList<Element>(10);
|
||||||
/** All Childeren */
|
/** All Childeren */
|
||||||
private List<Element> allChilderen = new ArrayList<Element>(10);
|
private List<Element> allChilderen = new ArrayList<Element>(10);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Element#doElementStart()
|
* @see Element#doElementStart()
|
||||||
*/
|
*/
|
||||||
public void doElementStart() throws ElementException {
|
public void doElementStart() throws ElementException {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Element#doElementEnd()
|
* @see Element#doElementEnd()
|
||||||
*/
|
*/
|
||||||
public void doElementEnd() throws ElementException {
|
public void doElementEnd() throws ElementException {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Element#doElementRun()
|
* @see Element#doElementRun()
|
||||||
*/
|
*/
|
||||||
public void doElementRun() throws ElementException {
|
public void doElementRun() throws ElementException {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Element#setParent(Element)
|
* @see Element#setParent(Element)
|
||||||
*/
|
*/
|
||||||
public void setParent(Element element) {
|
public void setParent(Element element) {
|
||||||
parent = element;
|
parent = element;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Element#getParent()
|
* @see Element#getParent()
|
||||||
*/
|
*/
|
||||||
public Element getParent() {
|
public Element getParent() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cleans the attributes and elements(class) and context.
|
* Cleans the attributes and elements(class) and context.
|
||||||
|
*
|
||||||
* @see Element#release()
|
* @see Element#release()
|
||||||
*/
|
*/
|
||||||
public void release() throws ElementException {
|
public void release() throws ElementException {
|
||||||
|
|
@ -98,28 +99,28 @@ public abstract class AbstractElement implements Element {
|
||||||
childeren.clear(); // we do not release childeren, x4o does that
|
childeren.clear(); // we do not release childeren, x4o does that
|
||||||
allChilderen.clear();
|
allChilderen.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Element#getElementObject()
|
* @see Element#getElementObject()
|
||||||
*/
|
*/
|
||||||
public Object getElementObject() {
|
public Object getElementObject() {
|
||||||
return elementObject;
|
return elementObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Element#setElementObject(Object)
|
* @see Element#setElementObject(Object)
|
||||||
*/
|
*/
|
||||||
public void setElementObject(Object object) {
|
public void setElementObject(Object object) {
|
||||||
elementObject=object;
|
elementObject = object;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Element#setLanguageSession(X4OLanguageSession)
|
* @see Element#setLanguageSession(X4OLanguageSession)
|
||||||
*/
|
*/
|
||||||
public void setLanguageSession(X4OLanguageSession languageSession) {
|
public void setLanguageSession(X4OLanguageSession languageSession) {
|
||||||
this.languageSession=languageSession;
|
this.languageSession = languageSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Element#getLanguageSession()
|
* @see Element#getLanguageSession()
|
||||||
*/
|
*/
|
||||||
|
|
@ -132,7 +133,8 @@ public abstract class AbstractElement implements Element {
|
||||||
*/
|
*/
|
||||||
public void doCharacters(String characters) throws ElementException {
|
public void doCharacters(String characters) throws ElementException {
|
||||||
try {
|
try {
|
||||||
Element e = X4OLanguageClassLoader.newInstance(Element.class, getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementBodyCharacters());
|
Element e = X4OLanguageClassLoader.newInstance(Element.class,
|
||||||
|
getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementBodyCharacters());
|
||||||
e.setElementObject(characters);
|
e.setElementObject(characters);
|
||||||
addChild(e);
|
addChild(e);
|
||||||
} catch (ClassNotFoundException exception) {
|
} catch (ClassNotFoundException exception) {
|
||||||
|
|
@ -145,7 +147,8 @@ public abstract class AbstractElement implements Element {
|
||||||
*/
|
*/
|
||||||
public void doComment(String comment) throws ElementException {
|
public void doComment(String comment) throws ElementException {
|
||||||
try {
|
try {
|
||||||
Element e = X4OLanguageClassLoader.newInstance(Element.class, getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementBodyComment());
|
Element e = X4OLanguageClassLoader.newInstance(Element.class,
|
||||||
|
getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementBodyComment());
|
||||||
e.setElementObject(comment);
|
e.setElementObject(comment);
|
||||||
addChild(e);
|
addChild(e);
|
||||||
} catch (ClassNotFoundException exception) {
|
} catch (ClassNotFoundException exception) {
|
||||||
|
|
@ -158,7 +161,8 @@ public abstract class AbstractElement implements Element {
|
||||||
*/
|
*/
|
||||||
public void doIgnorableWhitespace(String space) throws ElementException {
|
public void doIgnorableWhitespace(String space) throws ElementException {
|
||||||
try {
|
try {
|
||||||
Element e = X4OLanguageClassLoader.newInstance(Element.class, getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementBodyWhitespace());
|
Element e = X4OLanguageClassLoader.newInstance(Element.class,
|
||||||
|
getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementBodyWhitespace());
|
||||||
e.setElementObject(space);
|
e.setElementObject(space);
|
||||||
addChild(e);
|
addChild(e);
|
||||||
} catch (ClassNotFoundException exception) {
|
} catch (ClassNotFoundException exception) {
|
||||||
|
|
@ -170,9 +174,9 @@ public abstract class AbstractElement implements Element {
|
||||||
* @see org.x4o.xml.element.Element#setElementClass(ElementClass)
|
* @see org.x4o.xml.element.Element#setElementClass(ElementClass)
|
||||||
*/
|
*/
|
||||||
public void setElementClass(ElementClass elementClass) {
|
public void setElementClass(ElementClass elementClass) {
|
||||||
this.elementClass=elementClass;
|
this.elementClass = elementClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.Element#getElementClass()
|
* @see org.x4o.xml.element.Element#getElementClass()
|
||||||
*/
|
*/
|
||||||
|
|
@ -188,9 +192,9 @@ public abstract class AbstractElement implements Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.Element#setAttribute(java.lang.String, java.lang.String)
|
* @see org.x4o.xml.element.Element#setAttribute(java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void setAttribute(String name,String value) {
|
public void setAttribute(String name, String value) {
|
||||||
attributes.put(name, value);
|
attributes.put(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -200,7 +204,7 @@ public abstract class AbstractElement implements Element {
|
||||||
public List<Element> getChilderen() {
|
public List<Element> getChilderen() {
|
||||||
return childeren;
|
return childeren;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.Element#addChild(Element)
|
* @see org.x4o.xml.element.Element#addChild(Element)
|
||||||
*/
|
*/
|
||||||
|
|
@ -210,7 +214,7 @@ public abstract class AbstractElement implements Element {
|
||||||
childeren.add(element);
|
childeren.add(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.Element#removeChild(Element)
|
* @see org.x4o.xml.element.Element#removeChild(Element)
|
||||||
*/
|
*/
|
||||||
|
|
@ -235,6 +239,7 @@ public abstract class AbstractElement implements Element {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defaults to false.
|
* Defaults to false.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.element.Element#isTransformingTree()
|
* @see org.x4o.xml.element.Element#isTransformingTree()
|
||||||
*/
|
*/
|
||||||
public boolean isTransformingTree() {
|
public boolean isTransformingTree() {
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An AbstractElementBindingHandler.<br>
|
* An AbstractElementBindingHandler.<br>
|
||||||
|
|
@ -33,30 +32,31 @@ package org.x4o.xml.element;
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractElementBindingHandler<T> extends AbstractElementMetaBase implements ElementBindingHandler {
|
public abstract class AbstractElementBindingHandler<T> extends AbstractElementMetaBase implements ElementBindingHandler {
|
||||||
|
|
||||||
abstract public void bindChild(Element childElement,T parentObject,Object childObject) throws ElementBindingHandlerException;
|
abstract public void bindChild(Element childElement, T parentObject, Object childObject) throws ElementBindingHandlerException;
|
||||||
|
|
||||||
abstract public void createChilderen(Element parentElement,T parentObject) throws ElementBindingHandlerException;
|
abstract public void createChilderen(Element parentElement, T parentObject) throws ElementBindingHandlerException;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void bindChild(Element childElement) throws ElementBindingHandlerException {
|
public void bindChild(Element childElement) throws ElementBindingHandlerException {
|
||||||
bindChild(childElement,(T)childElement.getParent().getElementObject(), childElement.getElementObject());
|
bindChild(childElement, (T) childElement.getParent().getElementObject(), childElement.getElementObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void createChilderen(Element parentElement) throws ElementBindingHandlerException {
|
public void createChilderen(Element parentElement) throws ElementBindingHandlerException {
|
||||||
createChilderen(parentElement,(T)parentElement.getElementObject());
|
createChilderen(parentElement, (T) parentElement.getElementObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createChild(Element parentElement,Object childObject) {
|
protected void createChild(Element parentElement, Object childObject) {
|
||||||
if (childObject==null) {
|
if (childObject == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (parentElement==null) {
|
if (parentElement == null) {
|
||||||
throw new NullPointerException("Can't create child with null parent.");
|
throw new NullPointerException("Can't create child with null parent.");
|
||||||
}
|
}
|
||||||
Element childElement = parentElement.getLanguageSession().getLanguage().createElementInstance(parentElement.getLanguageSession(), childObject.getClass());
|
Element childElement = parentElement.getLanguageSession().getLanguage().createElementInstance(parentElement.getLanguageSession(),
|
||||||
if (childElement==null) {
|
childObject.getClass());
|
||||||
throw new NullPointerException("Could not find Element for child: "+childObject.getClass());
|
if (childElement == null) {
|
||||||
|
throw new NullPointerException("Could not find Element for child: " + childObject.getClass());
|
||||||
}
|
}
|
||||||
childElement.setElementObject(childObject);
|
childElement.setElementObject(childObject);
|
||||||
childElement.setParent(parentElement);
|
childElement.setParent(parentElement);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -40,11 +40,11 @@ public abstract class AbstractElementClass extends AbstractElementClassBase impl
|
||||||
private Boolean schemaContentComplex = null;
|
private Boolean schemaContentComplex = null;
|
||||||
private Boolean schemaContentMixed = null;
|
private Boolean schemaContentMixed = null;
|
||||||
private List<String> skipPhases = null;
|
private List<String> skipPhases = null;
|
||||||
|
|
||||||
public AbstractElementClass() {
|
public AbstractElementClass() {
|
||||||
skipPhases = new ArrayList<String>(3);
|
skipPhases = new ArrayList<String>(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ElementClass#getElementClass()
|
* @see ElementClass#getElementClass()
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -40,11 +40,11 @@ public abstract class AbstractElementClassAttribute extends AbstractElementMetaB
|
||||||
private List<String> attributeAliases = null;
|
private List<String> attributeAliases = null;
|
||||||
private Boolean required = null;
|
private Boolean required = null;
|
||||||
private Boolean runResolveEL = null;
|
private Boolean runResolveEL = null;
|
||||||
//private Boolean runInterfaces = null;
|
// private Boolean runInterfaces = null;
|
||||||
private Boolean runConverters = null;
|
private Boolean runConverters = null;
|
||||||
private Boolean runBeanValue = null;
|
private Boolean runBeanValue = null;
|
||||||
private Integer writeOrder = null;
|
private Integer writeOrder = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a AbstractElementClassAttribute.
|
* Creates a AbstractElementClassAttribute.
|
||||||
*/
|
*/
|
||||||
|
|
@ -54,6 +54,7 @@ public abstract class AbstractElementClassAttribute extends AbstractElementMetaB
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the objectConverter.
|
* Returns the objectConverter.
|
||||||
|
*
|
||||||
* @return The objectConverter.
|
* @return The objectConverter.
|
||||||
*/
|
*/
|
||||||
public ObjectConverter getObjectConverter() {
|
public ObjectConverter getObjectConverter() {
|
||||||
|
|
@ -62,6 +63,7 @@ public abstract class AbstractElementClassAttribute extends AbstractElementMetaB
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the objectConverter.
|
* Sets the objectConverter.
|
||||||
|
*
|
||||||
* @param objectConverter The objectConverter to set.
|
* @param objectConverter The objectConverter to set.
|
||||||
*/
|
*/
|
||||||
public void setObjectConverter(ObjectConverter objectConverter) {
|
public void setObjectConverter(ObjectConverter objectConverter) {
|
||||||
|
|
@ -70,15 +72,17 @@ public abstract class AbstractElementClassAttribute extends AbstractElementMetaB
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the default value.
|
* Sets the default value.
|
||||||
* @param defaultValue The defaultValue to set.
|
*
|
||||||
|
* @param defaultValue The defaultValue to set.
|
||||||
* @see org.x4o.xml.element.ElementClassAttribute#setDefaultValue(java.lang.Object)
|
* @see org.x4o.xml.element.ElementClassAttribute#setDefaultValue(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void setDefaultValue(Object defaultValue) {
|
public void setDefaultValue(Object defaultValue) {
|
||||||
this.defaultValue=defaultValue;
|
this.defaultValue = defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the default value.
|
* Returns the default value.
|
||||||
|
*
|
||||||
* @return The default value.
|
* @return The default value.
|
||||||
* @see org.x4o.xml.element.ElementClassAttribute#getDefaultValue()
|
* @see org.x4o.xml.element.ElementClassAttribute#getDefaultValue()
|
||||||
*/
|
*/
|
||||||
|
|
@ -88,7 +92,8 @@ public abstract class AbstractElementClassAttribute extends AbstractElementMetaB
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an alias of this attribute.
|
* Adds an alias of this attribute.
|
||||||
* @param alias The alias to add.
|
*
|
||||||
|
* @param alias The alias to add.
|
||||||
* @see org.x4o.xml.element.ElementClassAttribute#addAttributeAlias(java.lang.String)
|
* @see org.x4o.xml.element.ElementClassAttribute#addAttributeAlias(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void addAttributeAlias(String alias) {
|
public void addAttributeAlias(String alias) {
|
||||||
|
|
@ -97,7 +102,8 @@ public abstract class AbstractElementClassAttribute extends AbstractElementMetaB
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes an alias of this attribute.
|
* Removes an alias of this attribute.
|
||||||
* @param alias The alias to remove.
|
*
|
||||||
|
* @param alias The alias to remove.
|
||||||
* @see org.x4o.xml.element.ElementClassAttribute#removeAttributeAlias(java.lang.String)
|
* @see org.x4o.xml.element.ElementClassAttribute#removeAttributeAlias(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void removeAttributeAlias(String alias) {
|
public void removeAttributeAlias(String alias) {
|
||||||
|
|
@ -106,7 +112,8 @@ public abstract class AbstractElementClassAttribute extends AbstractElementMetaB
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all aliases of this attribute.
|
* Returns all aliases of this attribute.
|
||||||
* @return An list of aliases.
|
*
|
||||||
|
* @return An list of aliases.
|
||||||
* @see org.x4o.xml.element.ElementClassAttribute#getAttributeAliases()
|
* @see org.x4o.xml.element.ElementClassAttribute#getAttributeAliases()
|
||||||
*/
|
*/
|
||||||
public List<String> getAttributeAliases() {
|
public List<String> getAttributeAliases() {
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
@ -36,22 +36,23 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractElementClassBase extends AbstractElementMetaBase implements ElementClassBase {
|
public abstract class AbstractElementClassBase extends AbstractElementMetaBase implements ElementClassBase {
|
||||||
|
|
||||||
private Map<String,ElementClassAttribute> elementClassAttributes = null;
|
private Map<String, ElementClassAttribute> elementClassAttributes = null;
|
||||||
private List<ElementConfigurator> elementConfigurators = null;
|
private List<ElementConfigurator> elementConfigurators = null;
|
||||||
private Map<String,List<String>> elementParents = null;
|
private Map<String, List<String>> elementParents = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a AbstractElementClassBase.
|
* Creates a AbstractElementClassBase.
|
||||||
*/
|
*/
|
||||||
public AbstractElementClassBase() {
|
public AbstractElementClassBase() {
|
||||||
elementConfigurators = new ArrayList<ElementConfigurator>(5);
|
elementConfigurators = new ArrayList<ElementConfigurator>(5);
|
||||||
elementClassAttributes = new HashMap<String,ElementClassAttribute>(15);
|
elementClassAttributes = new HashMap<String, ElementClassAttribute>(15);
|
||||||
elementParents = new HashMap<String,List<String>>(5);
|
elementParents = new HashMap<String, List<String>>(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of ElementConfigurators.
|
* Returns a list of ElementConfigurators.
|
||||||
* @return List of ElementConfigurators.
|
*
|
||||||
|
* @return List of ElementConfigurators.
|
||||||
* @see ElementClass#getElementConfigurators()
|
* @see ElementClass#getElementConfigurators()
|
||||||
*/
|
*/
|
||||||
public List<ElementConfigurator> getElementConfigurators() {
|
public List<ElementConfigurator> getElementConfigurators() {
|
||||||
|
|
@ -70,40 +71,42 @@ public abstract class AbstractElementClassBase extends AbstractElementMetaBase i
|
||||||
* @param elementClassAttribute The ElementClassAttribute to add.
|
* @param elementClassAttribute The ElementClassAttribute to add.
|
||||||
*/
|
*/
|
||||||
public void addElementClassAttribute(ElementClassAttribute elementClassAttribute) {
|
public void addElementClassAttribute(ElementClassAttribute elementClassAttribute) {
|
||||||
elementClassAttributes.put(elementClassAttribute.getId(),elementClassAttribute);
|
elementClassAttributes.put(elementClassAttribute.getId(), elementClassAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return All the element attributes.
|
* @return All the element attributes.
|
||||||
*/
|
*/
|
||||||
public Collection<ElementClassAttribute> getElementClassAttributes() {
|
public Collection<ElementClassAttribute> getElementClassAttributes() {
|
||||||
return elementClassAttributes.values();
|
return elementClassAttributes.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the ElementClassAttribute from its name.
|
* Get the ElementClassAttribute from its name.
|
||||||
|
*
|
||||||
* @param attributeName The attribute name.
|
* @param attributeName The attribute name.
|
||||||
* @return The element class attribute for the name.
|
* @return The element class attribute for the name.
|
||||||
*/
|
*/
|
||||||
public ElementClassAttribute getElementClassAttributeByName(String attributeName) {
|
public ElementClassAttribute getElementClassAttributeByName(String attributeName) {
|
||||||
return elementClassAttributes.get(attributeName);
|
return elementClassAttributes.get(attributeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds parent tag.
|
* Adds parent tag.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.element.ElementClassBase#addElementParent(java.lang.String,java.lang.String)
|
* @see org.x4o.xml.element.ElementClassBase#addElementParent(java.lang.String,java.lang.String)
|
||||||
* @param namespaceUri The namespace uri of the parent tag.
|
* @param namespaceUri The namespace uri of the parent tag.
|
||||||
* @param tag The tag of the parent of this tag.
|
* @param tag The tag of the parent of this tag.
|
||||||
*/
|
*/
|
||||||
public void addElementParent(String namespaceUri,String tag) {
|
public void addElementParent(String namespaceUri, String tag) {
|
||||||
if (namespaceUri==null) {
|
if (namespaceUri == null) {
|
||||||
throw new NullPointerException("Can't add parent tag with null namespace uri.");
|
throw new NullPointerException("Can't add parent tag with null namespace uri.");
|
||||||
}
|
}
|
||||||
if (namespaceUri.length()==0) {
|
if (namespaceUri.length() == 0) {
|
||||||
throw new IllegalArgumentException("Can't add parent tag with empty namespace uri.");
|
throw new IllegalArgumentException("Can't add parent tag with empty namespace uri.");
|
||||||
}
|
}
|
||||||
List<String> tags = elementParents.get(namespaceUri);
|
List<String> tags = elementParents.get(namespaceUri);
|
||||||
if (tags==null) {
|
if (tags == null) {
|
||||||
tags = new ArrayList<String>(5);
|
tags = new ArrayList<String>(5);
|
||||||
elementParents.put(namespaceUri, tags);
|
elementParents.put(namespaceUri, tags);
|
||||||
}
|
}
|
||||||
|
|
@ -112,13 +115,14 @@ public abstract class AbstractElementClassBase extends AbstractElementMetaBase i
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes parent tag.
|
* Removes parent tag.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.element.ElementClassBase#removeElementParent(java.lang.String,java.lang.String)
|
* @see org.x4o.xml.element.ElementClassBase#removeElementParent(java.lang.String,java.lang.String)
|
||||||
* @param namespaceUri The namespace uri of the parent tag.
|
* @param namespaceUri The namespace uri of the parent tag.
|
||||||
* @param tag The tag of the parent of this tag.
|
* @param tag The tag of the parent of this tag.
|
||||||
*/
|
*/
|
||||||
public void removeElementParent(String namespaceUri,String tag) {
|
public void removeElementParent(String namespaceUri, String tag) {
|
||||||
List<String> tags = elementParents.get(namespaceUri);
|
List<String> tags = elementParents.get(namespaceUri);
|
||||||
if (tags==null) {
|
if (tags == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tags.remove(tag);
|
tags.remove(tag);
|
||||||
|
|
@ -126,6 +130,7 @@ public abstract class AbstractElementClassBase extends AbstractElementMetaBase i
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the parent per namespace uri.
|
* Returns the parent per namespace uri.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.element.ElementClassBase#getElementParents(java.lang.String)
|
* @see org.x4o.xml.element.ElementClassBase#getElementParents(java.lang.String)
|
||||||
* @param namespaceUri The namespace uri to gets the parents of.
|
* @param namespaceUri The namespace uri to gets the parents of.
|
||||||
* @return List of parent tags of requested parent namespace uri.
|
* @return List of parent tags of requested parent namespace uri.
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An AbstractElementConfigurator.<br>
|
* An AbstractElementConfigurator.<br>
|
||||||
|
|
@ -33,21 +33,23 @@ public abstract class AbstractElementConfigurator extends AbstractElementMetaBas
|
||||||
|
|
||||||
/** Flag indicating that this is an config action and should run in runPhase */
|
/** Flag indicating that this is an config action and should run in runPhase */
|
||||||
private boolean configAction = false;
|
private boolean configAction = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defaults to false.
|
* Defaults to false.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.element.ElementConfigurator#isConfigAction()
|
* @see org.x4o.xml.element.ElementConfigurator#isConfigAction()
|
||||||
* @return True if set to configAction
|
* @return True if set to configAction
|
||||||
*/
|
*/
|
||||||
public boolean isConfigAction() {
|
public boolean isConfigAction() {
|
||||||
return configAction;
|
return configAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the configAction.
|
* Sets the configAction.
|
||||||
* @param configAction The configAction to set.
|
*
|
||||||
|
* @param configAction The configAction to set.
|
||||||
*/
|
*/
|
||||||
public void setConfigAction(boolean configAction) {
|
public void setConfigAction(boolean configAction) {
|
||||||
this.configAction=configAction;
|
this.configAction = configAction;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AbstractElementInterface extends base support with element interface support.
|
* AbstractElementInterface extends base support with element interface support.
|
||||||
|
|
@ -31,13 +31,13 @@ package org.x4o.xml.element;
|
||||||
public abstract class AbstractElementInterface extends AbstractElementClassBase implements ElementInterface {
|
public abstract class AbstractElementInterface extends AbstractElementClassBase implements ElementInterface {
|
||||||
|
|
||||||
private Class<?> interfaceClass = null;
|
private Class<?> interfaceClass = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates AbstractElementInterface.
|
* Creates AbstractElementInterface.
|
||||||
*/
|
*/
|
||||||
public AbstractElementInterface() {
|
public AbstractElementInterface() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementInterface#getInterfaceClass()
|
* @see org.x4o.xml.element.ElementInterface#getInterfaceClass()
|
||||||
* @return The interface class
|
* @return The interface class
|
||||||
|
|
@ -45,12 +45,12 @@ public abstract class AbstractElementInterface extends AbstractElementClassBase
|
||||||
public Class<?> getInterfaceClass() {
|
public Class<?> getInterfaceClass() {
|
||||||
return interfaceClass;
|
return interfaceClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementInterface#setInterfaceClass(java.lang.Class)
|
* @see org.x4o.xml.element.ElementInterface#setInterfaceClass(java.lang.Class)
|
||||||
* @param interfaceClass The interface class to set.
|
* @param interfaceClass The interface class to set.
|
||||||
*/
|
*/
|
||||||
public void setInterfaceClass(Class<?> interfaceClass) {
|
public void setInterfaceClass(Class<?> interfaceClass) {
|
||||||
this.interfaceClass=interfaceClass;
|
this.interfaceClass = interfaceClass;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AbstractElementMetaBase stores the id and description.
|
* AbstractElementMetaBase stores the id and description.
|
||||||
|
|
@ -30,46 +30,50 @@ package org.x4o.xml.element;
|
||||||
* @version 1.0 Jan 18, 2009
|
* @version 1.0 Jan 18, 2009
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractElementMetaBase implements ElementMetaBase {
|
public abstract class AbstractElementMetaBase implements ElementMetaBase {
|
||||||
|
|
||||||
/** The id */
|
/** The id */
|
||||||
private String id = null;
|
private String id = null;
|
||||||
|
|
||||||
/** The description */
|
/** The description */
|
||||||
private String description = null;
|
private String description = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the id.
|
* Gets the id.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.element.ElementMetaBase#getId()
|
* @see org.x4o.xml.element.ElementMetaBase#getId()
|
||||||
* @return The id.
|
* @return The id.
|
||||||
*/
|
*/
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the id.
|
* Sets the id.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.element.ElementMetaBase#setId(java.lang.String)
|
* @see org.x4o.xml.element.ElementMetaBase#setId(java.lang.String)
|
||||||
* @param id The id to set.
|
* @param id The id to set.
|
||||||
*/
|
*/
|
||||||
public void setId(String id) {
|
public void setId(String id) {
|
||||||
this.id=id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the description.
|
* Gets the description.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.element.ElementConfigurator#getDescription()
|
* @see org.x4o.xml.element.ElementConfigurator#getDescription()
|
||||||
* @return The description.
|
* @return The description.
|
||||||
*/
|
*/
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the description.
|
* Sets the description.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.element.ElementConfigurator#setDescription(java.lang.String)
|
* @see org.x4o.xml.element.ElementConfigurator#setDescription(java.lang.String)
|
||||||
* @param description The description to set.
|
* @param description The description to set.
|
||||||
*/
|
*/
|
||||||
public void setDescription(String description) {
|
public void setDescription(String description) {
|
||||||
this.description=description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ public abstract class AbstractElementNamespace extends AbstractElementMetaBase i
|
||||||
|
|
||||||
private ElementNamespaceInstanceProvider elementNamespaceInstanceProvider = null;
|
private ElementNamespaceInstanceProvider elementNamespaceInstanceProvider = null;
|
||||||
private String prefixMapping = null;
|
private String prefixMapping = null;
|
||||||
private Map<String,ElementClass> elementClasses = null;
|
private Map<String, ElementClass> elementClasses = null;
|
||||||
private String uri = null;
|
private String uri = null;
|
||||||
private String name = null;
|
private String name = null;
|
||||||
private String schemaUri = null;
|
private String schemaUri = null;
|
||||||
|
|
@ -45,9 +45,9 @@ public abstract class AbstractElementNamespace extends AbstractElementMetaBase i
|
||||||
private String schemaPrefix = null;
|
private String schemaPrefix = null;
|
||||||
private Boolean languageRoot = null;
|
private Boolean languageRoot = null;
|
||||||
private List<ElementNamespaceAttribute> elementNamespaceAttributes = null;
|
private List<ElementNamespaceAttribute> elementNamespaceAttributes = null;
|
||||||
|
|
||||||
public AbstractElementNamespace() {
|
public AbstractElementNamespace() {
|
||||||
elementClasses = new HashMap<String,ElementClass>(60);
|
elementClasses = new HashMap<String, ElementClass>(60);
|
||||||
elementNamespaceAttributes = new ArrayList<ElementNamespaceAttribute>(5);
|
elementNamespaceAttributes = new ArrayList<ElementNamespaceAttribute>(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -76,14 +76,14 @@ public abstract class AbstractElementNamespace extends AbstractElementMetaBase i
|
||||||
* @see org.x4o.xml.element.ElementNamespace#setPrefixMapping(java.lang.String)
|
* @see org.x4o.xml.element.ElementNamespace#setPrefixMapping(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void setPrefixMapping(String prefixMapping) {
|
public void setPrefixMapping(String prefixMapping) {
|
||||||
this.prefixMapping=prefixMapping;
|
this.prefixMapping = prefixMapping;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementNamespace#addElementClass(org.x4o.xml.element.ElementClass)
|
* @see org.x4o.xml.element.ElementNamespace#addElementClass(org.x4o.xml.element.ElementClass)
|
||||||
*/
|
*/
|
||||||
public void addElementClass(ElementClass elementClass) {
|
public void addElementClass(ElementClass elementClass) {
|
||||||
if (elementClass.getId()==null) {
|
if (elementClass.getId() == null) {
|
||||||
throw new NullPointerException("ElementClass not correctly configured getId is null.");
|
throw new NullPointerException("ElementClass not correctly configured getId is null.");
|
||||||
}
|
}
|
||||||
elementClasses.put(elementClass.getId(), elementClass);
|
elementClasses.put(elementClass.getId(), elementClass);
|
||||||
|
|
@ -186,16 +186,15 @@ public abstract class AbstractElementNamespace extends AbstractElementMetaBase i
|
||||||
public void setSchemaPrefix(String schemaPrefix) {
|
public void setSchemaPrefix(String schemaPrefix) {
|
||||||
this.schemaPrefix = schemaPrefix;
|
this.schemaPrefix = schemaPrefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addElementNamespaceAttribute(ElementNamespaceAttribute elementNamespaceAttribute) {
|
public void addElementNamespaceAttribute(ElementNamespaceAttribute elementNamespaceAttribute) {
|
||||||
if (elementNamespaceAttribute==null) {
|
if (elementNamespaceAttribute == null) {
|
||||||
throw new NullPointerException("Can't add null object");
|
throw new NullPointerException("Can't add null object");
|
||||||
}
|
}
|
||||||
if (elementNamespaceAttribute.getId()==null) {
|
if (elementNamespaceAttribute.getId() == null) {
|
||||||
throw new NullPointerException("Can't add with null id property.");
|
throw new NullPointerException("Can't add with null id property.");
|
||||||
}
|
}
|
||||||
//logger.finer("Adding elementNamespaceAttribute: "+elementNamespaceAttribute.getAttributeName());
|
// logger.finer("Adding elementNamespaceAttribute: "+elementNamespaceAttribute.getAttributeName());
|
||||||
elementNamespaceAttributes.add(elementNamespaceAttribute);
|
elementNamespaceAttributes.add(elementNamespaceAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,15 +32,15 @@ import java.util.List;
|
||||||
* @version 1.0 Aug 10, 2006
|
* @version 1.0 Aug 10, 2006
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractElementNamespaceAttribute extends AbstractElementConfigurator implements ElementNamespaceAttribute {
|
public abstract class AbstractElementNamespaceAttribute extends AbstractElementConfigurator implements ElementNamespaceAttribute {
|
||||||
|
|
||||||
private String attributeName = null;
|
private String attributeName = null;
|
||||||
private List<String> nextAttributes = new ArrayList<String>(2);
|
private List<String> nextAttributes = new ArrayList<String>(2);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementNamespaceAttribute#addNextAttribute(java.lang.String)
|
* @see org.x4o.xml.element.ElementNamespaceAttribute#addNextAttribute(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void addNextAttribute(String attribute) {
|
public void addNextAttribute(String attribute) {
|
||||||
if (attribute==null) {
|
if (attribute == null) {
|
||||||
throw new NullPointerException("Can add null attribute for loading.");
|
throw new NullPointerException("Can add null attribute for loading.");
|
||||||
}
|
}
|
||||||
nextAttributes.add(attribute);
|
nextAttributes.add(attribute);
|
||||||
|
|
@ -48,9 +48,9 @@ public abstract class AbstractElementNamespaceAttribute extends AbstractElementC
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementNamespaceAttribute#removeNextAttribute(java.lang.String)
|
* @see org.x4o.xml.element.ElementNamespaceAttribute#removeNextAttribute(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void removeNextAttribute(String attribute) {
|
public void removeNextAttribute(String attribute) {
|
||||||
if (attribute==null) {
|
if (attribute == null) {
|
||||||
throw new NullPointerException("Can remove null attribute for loading.");
|
throw new NullPointerException("Can remove null attribute for loading.");
|
||||||
}
|
}
|
||||||
nextAttributes.remove(attribute);
|
nextAttributes.remove(attribute);
|
||||||
|
|
@ -74,6 +74,6 @@ public abstract class AbstractElementNamespaceAttribute extends AbstractElementC
|
||||||
* @see org.x4o.xml.element.ElementNamespaceAttribute#setAttributeName(java.lang.String)
|
* @see org.x4o.xml.element.ElementNamespaceAttribute#setAttributeName(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void setAttributeName(String attributeName) {
|
public void setAttributeName(String attributeName) {
|
||||||
this.attributeName=attributeName;
|
this.attributeName = attributeName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default element to handle the xml events.
|
* The default element to handle the xml events.
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
@ -29,7 +29,6 @@ import javax.el.ValueExpression;
|
||||||
|
|
||||||
import org.x4o.xml.conv.ObjectConverterException;
|
import org.x4o.xml.conv.ObjectConverterException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An DefaultElementAttributeValueParser.
|
* An DefaultElementAttributeValueParser.
|
||||||
*
|
*
|
||||||
|
|
@ -38,18 +37,16 @@ import org.x4o.xml.conv.ObjectConverterException;
|
||||||
*/
|
*/
|
||||||
public class DefaultElementAttributeValueParser implements ElementAttributeValueParser {
|
public class DefaultElementAttributeValueParser implements ElementAttributeValueParser {
|
||||||
|
|
||||||
|
|
||||||
private Logger logger = null;
|
private Logger logger = null;
|
||||||
|
|
||||||
public DefaultElementAttributeValueParser() {
|
public DefaultElementAttributeValueParser() {
|
||||||
logger = Logger.getLogger(DefaultElementAttributeValueParser.class.getName());
|
logger = Logger.getLogger(DefaultElementAttributeValueParser.class.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementAttributeValueParser#getParameterValue(java.lang.String, java.lang.String, org.x4o.xml.element.Element)
|
* @see org.x4o.xml.element.ElementAttributeValueParser#getParameterValue(java.lang.String, java.lang.String, org.x4o.xml.element.Element)
|
||||||
*/
|
*/
|
||||||
public Object getParameterValue(String name, String valueString, Element element) throws ElementAttributeValueParserException,ObjectConverterException {
|
public Object getParameterValue(String name, String valueString, Element element) throws ElementAttributeValueParserException, ObjectConverterException {
|
||||||
Object value = valueString;
|
Object value = valueString;
|
||||||
|
|
||||||
if (isELParameter(name, valueString, element)) {
|
if (isELParameter(name, valueString, element)) {
|
||||||
|
|
@ -58,55 +55,53 @@ public class DefaultElementAttributeValueParser implements ElementAttributeValue
|
||||||
return getConvertedParameterValue(name, value, element);
|
return getConvertedParameterValue(name, value, element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws ObjectConverterException
|
* @throws ObjectConverterException
|
||||||
* @see org.x4o.xml.element.ElementAttributeValueParser#getConvertedParameterValue(java.lang.String, java.lang.Object, org.x4o.xml.element.Element)
|
* @see org.x4o.xml.element.ElementAttributeValueParser#getConvertedParameterValue(java.lang.String, java.lang.Object, org.x4o.xml.element.Element)
|
||||||
*/
|
*/
|
||||||
public Object getConvertedParameterValue(String name,Object value, Element element) throws ElementAttributeValueParserException, ObjectConverterException {
|
public Object getConvertedParameterValue(String name, Object value, Element element) throws ElementAttributeValueParserException, ObjectConverterException {
|
||||||
//bit slow here
|
// bit slow here
|
||||||
if (value==null) {
|
if (value == null) {
|
||||||
return null; // TODO: make setting for null
|
return null; // TODO: make setting for null
|
||||||
}
|
}
|
||||||
|
|
||||||
// do converts for ElementClass
|
// do converts for ElementClass
|
||||||
ElementClassAttribute attr = element.getElementClass().getElementClassAttributeByName(name);
|
ElementClassAttribute attr = element.getElementClass().getElementClassAttributeByName(name);
|
||||||
if (attr!=null && attr.getObjectConverter()!=null && value.getClass().isAssignableFrom(attr.getObjectConverter().getObjectClassTo())==false) {
|
if (attr != null && attr.getObjectConverter() != null && value.getClass().isAssignableFrom(attr.getObjectConverter().getObjectClassTo()) == false) {
|
||||||
logger.finer("attr conv: "+attr.getObjectConverter()+" for name: "+name);
|
logger.finer("attr conv: " + attr.getObjectConverter() + " for name: " + name);
|
||||||
Object result = attr.getObjectConverter().convertTo(value.toString(), Locale.getDefault());
|
Object result = attr.getObjectConverter().convertTo(value.toString(), Locale.getDefault());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
// check interfaces
|
// check interfaces
|
||||||
if (element.getElementObject()==null) {
|
if (element.getElementObject() == null) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
for (ElementInterface ei:element.getLanguageSession().getLanguage().findElementInterfaces(element.getElementObject())) {
|
for (ElementInterface ei : element.getLanguageSession().getLanguage().findElementInterfaces(element.getElementObject())) {
|
||||||
logger.finer("Found interface match executing converter.");
|
logger.finer("Found interface match executing converter.");
|
||||||
for (ElementClassAttribute attrClass:ei.getElementClassAttributes()) {
|
for (ElementClassAttribute attrClass : ei.getElementClassAttributes()) {
|
||||||
if (name.equals(attrClass.getId())==false) {
|
if (name.equals(attrClass.getId()) == false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (attrClass.getObjectConverter()==null) {
|
if (attrClass.getObjectConverter() == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (value.getClass().isAssignableFrom(attrClass.getObjectConverter().getObjectClassTo())) {
|
if (value.getClass().isAssignableFrom(attrClass.getObjectConverter().getObjectClassTo())) {
|
||||||
continue; // make flag ?
|
continue; // make flag ?
|
||||||
}
|
}
|
||||||
logger.finest("attr conv interface: "+attrClass.getObjectConverter()+" for name: "+name);
|
logger.finest("attr conv interface: " + attrClass.getObjectConverter() + " for name: " + name);
|
||||||
Object result = attrClass.getObjectConverter().convertTo(value.toString(), Locale.getDefault());
|
Object result = attrClass.getObjectConverter().convertTo(value.toString(), Locale.getDefault());
|
||||||
return result; // ??
|
return result; // ??
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementAttributeValueParser#getELParameterValue(java.lang.String, org.x4o.xml.element.Element)
|
* @see org.x4o.xml.element.ElementAttributeValueParser#getELParameterValue(java.lang.String, org.x4o.xml.element.Element)
|
||||||
*/
|
*/
|
||||||
public Object getELParameterValue(String value, Element element) throws ElementAttributeValueParserException {
|
public Object getELParameterValue(String value, Element element) throws ElementAttributeValueParserException {
|
||||||
ValueExpression e = element.getLanguageSession().getExpressionLanguageFactory().createValueExpression(element.getLanguageSession().getExpressionLanguageContext(), (String)value,Object.class);
|
ValueExpression e = element.getLanguageSession().getExpressionLanguageFactory()
|
||||||
|
.createValueExpression(element.getLanguageSession().getExpressionLanguageContext(), (String) value, Object.class);
|
||||||
return e.getValue(element.getLanguageSession().getExpressionLanguageContext());
|
return e.getValue(element.getLanguageSession().getExpressionLanguageContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -114,27 +109,27 @@ public class DefaultElementAttributeValueParser implements ElementAttributeValue
|
||||||
* @see org.x4o.xml.element.ElementAttributeValueParser#isELParameter(java.lang.String, java.lang.String, org.x4o.xml.element.Element)
|
* @see org.x4o.xml.element.ElementAttributeValueParser#isELParameter(java.lang.String, java.lang.String, org.x4o.xml.element.Element)
|
||||||
*/
|
*/
|
||||||
public boolean isELParameter(String name, String value, Element element) {
|
public boolean isELParameter(String name, String value, Element element) {
|
||||||
if (value==null) {
|
if (value == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (value.startsWith("${")==false) {
|
if (value.startsWith("${") == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (element==null) {
|
if (element == null) {
|
||||||
return true; // null element disables checks
|
return true; // null element disables checks
|
||||||
}
|
}
|
||||||
ElementClassAttribute attr = element.getElementClass().getElementClassAttributeByName(name);
|
ElementClassAttribute attr = element.getElementClass().getElementClassAttributeByName(name);
|
||||||
if (attr!=null && attr.getRunResolveEL()!=null && attr.getRunResolveEL()==false) {
|
if (attr != null && attr.getRunResolveEL() != null && attr.getRunResolveEL() == false) {
|
||||||
logger.finest("Skipping EL parsing for: "+name);
|
logger.finest("Skipping EL parsing for: " + name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ElementInterface ei:element.getLanguageSession().getLanguage().findElementInterfaces(element.getElementObject())) {
|
for (ElementInterface ei : element.getLanguageSession().getLanguage().findElementInterfaces(element.getElementObject())) {
|
||||||
logger.finest("Found interface match checking disables el parameters.");
|
logger.finest("Found interface match checking disables el parameters.");
|
||||||
|
|
||||||
attr = ei.getElementClassAttributeByName(name);
|
attr = ei.getElementClassAttributeByName(name);
|
||||||
if (attr!=null && attr.getRunResolveEL()!=null && attr.getRunResolveEL()==false) {
|
if (attr != null && attr.getRunResolveEL() != null && attr.getRunResolveEL() == false) {
|
||||||
logger.finest("Skipping EL parsing for: "+name+" in interface element.");
|
logger.finest("Skipping EL parsing for: " + name + " in interface element.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
@ -29,7 +29,6 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.x4o.xml.lang.X4OLanguageSession;
|
import org.x4o.xml.lang.X4OLanguageSession;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DefaultElementBodyCharacters the default characters element.
|
* DefaultElementBodyCharacters the default characters element.
|
||||||
*
|
*
|
||||||
|
|
@ -42,9 +41,9 @@ public class DefaultElementBodyCharacters implements Element {
|
||||||
private Element parent = null;
|
private Element parent = null;
|
||||||
/** The config object */
|
/** The config object */
|
||||||
private Object elementObject = null;
|
private Object elementObject = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The ElementType for characters.
|
* @return The ElementType for characters.
|
||||||
* @see org.x4o.xml.element.Element#getElementType()
|
* @see org.x4o.xml.element.Element#getElementType()
|
||||||
*/
|
*/
|
||||||
public ElementType getElementType() {
|
public ElementType getElementType() {
|
||||||
|
|
@ -106,7 +105,7 @@ public class DefaultElementBodyCharacters implements Element {
|
||||||
* @see org.x4o.xml.element.Element#getAttributes()
|
* @see org.x4o.xml.element.Element#getAttributes()
|
||||||
*/
|
*/
|
||||||
public Map<String, String> getAttributes() {
|
public Map<String, String> getAttributes() {
|
||||||
return new HashMap<String,String>(0);
|
return new HashMap<String, String>(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -160,7 +159,7 @@ public class DefaultElementBodyCharacters implements Element {
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.Element#removeChild(org.x4o.xml.element.Element)
|
* @see org.x4o.xml.element.Element#removeChild(org.x4o.xml.element.Element)
|
||||||
*/
|
*/
|
||||||
public void removeChild(Element element) {
|
public void removeChild(Element element) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -185,13 +184,13 @@ public class DefaultElementBodyCharacters implements Element {
|
||||||
* @see org.x4o.xml.element.Element#setElementObject(java.lang.Object)
|
* @see org.x4o.xml.element.Element#setElementObject(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void setElementObject(Object elementObject) {
|
public void setElementObject(Object elementObject) {
|
||||||
this.elementObject=elementObject;
|
this.elementObject = elementObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.Element#setParent(org.x4o.xml.element.Element)
|
* @see org.x4o.xml.element.Element#setParent(org.x4o.xml.element.Element)
|
||||||
*/
|
*/
|
||||||
public void setParent(Element parent) {
|
public void setParent(Element parent) {
|
||||||
this.parent=parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DefaultElementBodyComment the default comment element.
|
* DefaultElementBodyComment the default comment element.
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DefaultElementBodyWhitespace the default white space element.
|
* DefaultElementBodyWhitespace the default white space element.
|
||||||
|
|
@ -32,7 +31,7 @@ package org.x4o.xml.element;
|
||||||
public class DefaultElementBodyWhitespace extends AbstractElement {
|
public class DefaultElementBodyWhitespace extends AbstractElement {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the whitespace element type.
|
* @return Returns the whitespace element type.
|
||||||
* @see org.x4o.xml.element.AbstractElement#getElementType()
|
* @see org.x4o.xml.element.AbstractElement#getElementType()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DefaultElementClass stores the XML Element information.
|
* DefaultElementClass stores the XML Element information.
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default ElementClassAttribute.
|
* The default ElementClassAttribute.
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default ElementInterface to store config based on class interface.
|
* The default ElementInterface to store config based on class interface.
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DefaultElementNamespace is the default element namespace implementation.
|
* DefaultElementNamespace is the default element namespace implementation.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,6 @@ package org.x4o.xml.element;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The DefaultElementNamespaceAttributeComparator.<br>
|
* The DefaultElementNamespaceAttributeComparator.<br>
|
||||||
* This Comparator compares the NextAttribute names with the attributeName of the ElementNamespaceAttribute.<br>
|
* This Comparator compares the NextAttribute names with the attributeName of the ElementNamespaceAttribute.<br>
|
||||||
|
|
@ -36,20 +34,20 @@ import java.util.Comparator;
|
||||||
public class DefaultElementNamespaceAttributeComparator implements Comparator<ElementNamespaceAttribute> {
|
public class DefaultElementNamespaceAttributeComparator implements Comparator<ElementNamespaceAttribute> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param e1 The first ElementNamespaceAttribute to compare.
|
* @param e1 The first ElementNamespaceAttribute to compare.
|
||||||
* @param e2 The second ElementNamespaceAttribute to compare.
|
* @param e2 The second ElementNamespaceAttribute to compare.
|
||||||
* @return 0 is same.
|
* @return 0 is same.
|
||||||
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
|
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public int compare(ElementNamespaceAttribute e1, ElementNamespaceAttribute e2) {
|
public int compare(ElementNamespaceAttribute e1, ElementNamespaceAttribute e2) {
|
||||||
|
|
||||||
for (String param:e1.getNextAttributes()) {
|
for (String param : e1.getNextAttributes()) {
|
||||||
if(param.equals(e2.getAttributeName())) {
|
if (param.equals(e2.getAttributeName())) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (String param:e2.getNextAttributes()) {
|
for (String param : e2.getNextAttributes()) {
|
||||||
if(param.equals(e1.getAttributeName())) {
|
if (param.equals(e1.getAttributeName())) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ public class DefaultElementNamespaceInstanceProvider implements ElementNamespace
|
||||||
|
|
||||||
private Logger logger = null;
|
private Logger logger = null;
|
||||||
private ElementNamespace elementNamespace = null;
|
private ElementNamespace elementNamespace = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new DefaultElementNamespaceInstanceProvider.
|
* Creates new DefaultElementNamespaceInstanceProvider.
|
||||||
*/
|
*/
|
||||||
|
|
@ -47,47 +47,47 @@ public class DefaultElementNamespaceInstanceProvider implements ElementNamespace
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param language The elementLanguage of this provider.
|
* @param language The elementLanguage of this provider.
|
||||||
* @param elementNamespace The elementNamespace for this provider.
|
* @param elementNamespace The elementNamespace for this provider.
|
||||||
* @see org.x4o.xml.element.ElementNamespaceInstanceProvider#start(org.x4o.xml.lang.X4OLanguage, org.x4o.xml.element.ElementNamespace)
|
* @see org.x4o.xml.element.ElementNamespaceInstanceProvider#start(org.x4o.xml.lang.X4OLanguage, org.x4o.xml.element.ElementNamespace)
|
||||||
*/
|
*/
|
||||||
public void start(X4OLanguage language,ElementNamespace elementNamespace) {
|
public void start(X4OLanguage language, ElementNamespace elementNamespace) {
|
||||||
this.elementNamespace=elementNamespace;
|
this.elementNamespace = elementNamespace;
|
||||||
logger.finer("Starting DefaultElementNamespaceInstanceProvider for: "+elementNamespace.getUri());
|
logger.finer("Starting DefaultElementNamespaceInstanceProvider for: " + elementNamespace.getUri());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param languageSession The language context for which we create the Element instance.
|
* @param languageSession The language context for which we create the Element instance.
|
||||||
* @param tag The xml tag to create an Element instance for.
|
* @param tag The xml tag to create an Element instance for.
|
||||||
* @return The Element to handle the given tag.
|
* @return The Element to handle the given tag.
|
||||||
* @throws ElementNamespaceInstanceProviderException
|
* @throws ElementNamespaceInstanceProviderException
|
||||||
* @see org.x4o.xml.element.ElementNamespaceInstanceProvider#createElementInstance(org.x4o.xml.lang.X4OLanguageSession,java.lang.String)
|
* @see org.x4o.xml.element.ElementNamespaceInstanceProvider#createElementInstance(org.x4o.xml.lang.X4OLanguageSession,java.lang.String)
|
||||||
*/
|
*/
|
||||||
public Element createElementInstance(X4OLanguageSession languageSession,String tag) throws ElementNamespaceInstanceProviderException {
|
public Element createElementInstance(X4OLanguageSession languageSession, String tag) throws ElementNamespaceInstanceProviderException {
|
||||||
ElementClass elementClass = elementNamespace.getElementClass(tag);
|
ElementClass elementClass = elementNamespace.getElementClass(tag);
|
||||||
Element element = null;
|
Element element = null;
|
||||||
|
|
||||||
if (elementClass==null) {
|
if (elementClass == null) {
|
||||||
throw new ElementNamespaceInstanceProviderException(this,"Tag: " + tag + " unknown in: " + elementNamespace.getUri());
|
throw new ElementNamespaceInstanceProviderException(this, "Tag: " + tag + " unknown in: " + elementNamespace.getUri());
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (elementClass.getElementClass()!=null) {
|
if (elementClass.getElementClass() != null) {
|
||||||
Object obj = X4OLanguageClassLoader.newInstance(elementClass.getElementClass());
|
Object obj = X4OLanguageClassLoader.newInstance(elementClass.getElementClass());
|
||||||
if (obj instanceof Element) {
|
if (obj instanceof Element) {
|
||||||
element = (Element) obj;
|
element = (Element) obj;
|
||||||
} else {
|
} else {
|
||||||
throw new ElementNamespaceInstanceProviderException(this,"Provided elementClassName is not an Element: "+obj.getClass());
|
throw new ElementNamespaceInstanceProviderException(this, "Provided elementClassName is not an Element: " + obj.getClass());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
element = (Element)X4OLanguageClassLoader.newInstance((languageSession.getLanguage().getLanguageConfiguration().getDefaultElement()));
|
element = (Element) X4OLanguageClassLoader.newInstance((languageSession.getLanguage().getLanguageConfiguration().getDefaultElement()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elementClass.getObjectClass()!=null) {
|
if (elementClass.getObjectClass() != null) {
|
||||||
element.setElementObject(X4OLanguageClassLoader.newInstance(elementClass.getObjectClass()));
|
element.setElementObject(X4OLanguageClassLoader.newInstance(elementClass.getObjectClass()));
|
||||||
}
|
}
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new ElementNamespaceInstanceProviderException(this,"Error while providing Element: "+e.getMessage(),e);
|
throw new ElementNamespaceInstanceProviderException(this, "Error while providing Element: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
element.setElementClass(elementClass);
|
element.setElementClass(elementClass);
|
||||||
element.setLanguageSession(languageSession);
|
element.setLanguageSession(languageSession);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
@ -39,24 +39,24 @@ import org.x4o.xml.conv.ObjectConverterException;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Feb 16, 2007
|
* @version 1.0 Feb 16, 2007
|
||||||
*/
|
*/
|
||||||
public class DefaultElementObjectPropertyValue implements ElementObjectPropertyValue,Serializable {
|
public class DefaultElementObjectPropertyValue implements ElementObjectPropertyValue, Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private Logger logger = Logger.getLogger(DefaultElementObjectPropertyValue.class.getName());
|
private Logger logger = Logger.getLogger(DefaultElementObjectPropertyValue.class.getName());
|
||||||
|
|
||||||
private Method findMethod(Object object,String parameterName,Object parameter) {
|
private Method findMethod(Object object, String parameterName, Object parameter) {
|
||||||
|
|
||||||
// Get class but can be null.
|
// Get class but can be null.
|
||||||
Class<?> parameterClass = null;
|
Class<?> parameterClass = null;
|
||||||
if(parameter!=null) {
|
if (parameter != null) {
|
||||||
parameterClass=parameter.getClass();
|
parameterClass = parameter.getClass();
|
||||||
}
|
}
|
||||||
logger.finer("Trying value: pn="+parameterName+" o="+object+" p="+parameter+"("+parameterClass+")");
|
logger.finer("Trying value: pn=" + parameterName + " o=" + object + " p=" + parameter + "(" + parameterClass + ")");
|
||||||
String parameterNameSet = "set"+parameterName;
|
String parameterNameSet = "set" + parameterName;
|
||||||
Method[] methodes = object.getClass().getMethods();
|
Method[] methodes = object.getClass().getMethods();
|
||||||
Method lastMethodFall = null;
|
Method lastMethodFall = null;
|
||||||
for (int i=0;i<methodes.length;i++) {
|
for (int i = 0; i < methodes.length; i++) {
|
||||||
Method method = methodes[i];
|
Method method = methodes[i];
|
||||||
Class<?>[] types = method.getParameterTypes();
|
Class<?>[] types = method.getParameterTypes();
|
||||||
if (types.length == 0) {
|
if (types.length == 0) {
|
||||||
|
|
@ -67,32 +67,32 @@ public class DefaultElementObjectPropertyValue implements ElementObjectPropertyV
|
||||||
}
|
}
|
||||||
if (method.getName().equalsIgnoreCase(parameterNameSet)) {
|
if (method.getName().equalsIgnoreCase(parameterNameSet)) {
|
||||||
lastMethodFall = method;
|
lastMethodFall = method;
|
||||||
if (parameterClass!=null) {
|
if (parameterClass != null) {
|
||||||
// Check for class based parameters.
|
// Check for class based parameters.
|
||||||
if (types[0].isAssignableFrom(parameterClass)) {
|
if (types[0].isAssignableFrom(parameterClass)) {
|
||||||
logger.finest("Found method type: "+method.getParameterTypes()[0]+" for parameter: "+parameterName);
|
logger.finest("Found method type: " + method.getParameterTypes()[0] + " for parameter: " + parameterName);
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
// Check the native parameter types.
|
// Check the native parameter types.
|
||||||
if (parameterClass.isAssignableFrom(Boolean.class) && types[0].isAssignableFrom(Boolean.TYPE) ) {
|
if (parameterClass.isAssignableFrom(Boolean.class) && types[0].isAssignableFrom(Boolean.TYPE)) {
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
if (parameterClass.isAssignableFrom(Integer.class) && types[0].isAssignableFrom(Integer.TYPE) ) {
|
if (parameterClass.isAssignableFrom(Integer.class) && types[0].isAssignableFrom(Integer.TYPE)) {
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
if (parameterClass.isAssignableFrom(Long.class) && types[0].isAssignableFrom(Long.TYPE) ) {
|
if (parameterClass.isAssignableFrom(Long.class) && types[0].isAssignableFrom(Long.TYPE)) {
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
if (parameterClass.isAssignableFrom(Double.class) && types[0].isAssignableFrom(Double.TYPE) ) {
|
if (parameterClass.isAssignableFrom(Double.class) && types[0].isAssignableFrom(Double.TYPE)) {
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
if (parameterClass.isAssignableFrom(Float.class) && types[0].isAssignableFrom(Float.TYPE) ) {
|
if (parameterClass.isAssignableFrom(Float.class) && types[0].isAssignableFrom(Float.TYPE)) {
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
if (parameterClass.isAssignableFrom(Byte.class) && types[0].isAssignableFrom(Byte.TYPE) ) {
|
if (parameterClass.isAssignableFrom(Byte.class) && types[0].isAssignableFrom(Byte.TYPE)) {
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
if (parameterClass.isAssignableFrom(Character.class) && types[0].isAssignableFrom(Character.TYPE) ) {
|
if (parameterClass.isAssignableFrom(Character.class) && types[0].isAssignableFrom(Character.TYPE)) {
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -100,7 +100,7 @@ public class DefaultElementObjectPropertyValue implements ElementObjectPropertyV
|
||||||
}
|
}
|
||||||
return lastMethodFall;
|
return lastMethodFall;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: this function is not completed !!
|
* TODO: this function is not completed !!
|
||||||
*
|
*
|
||||||
|
|
@ -111,222 +111,212 @@ public class DefaultElementObjectPropertyValue implements ElementObjectPropertyV
|
||||||
* @param parameter
|
* @param parameter
|
||||||
* @throws ElementObjectPropertyValueException
|
* @throws ElementObjectPropertyValueException
|
||||||
*/
|
*/
|
||||||
public void setProperty(Object object,String parameterName,Object parameter) throws ElementObjectPropertyValueException {
|
public void setProperty(Object object, String parameterName, Object parameter) throws ElementObjectPropertyValueException {
|
||||||
|
|
||||||
// find the method for the parameter
|
// find the method for the parameter
|
||||||
Method lastMethod = findMethod(object,parameterName,parameter);
|
Method lastMethod = findMethod(object, parameterName, parameter);
|
||||||
if (lastMethod==null) {
|
if (lastMethod == null) {
|
||||||
logger.finest("No method found, aborting parameter: "+parameterName);
|
logger.finest("No method found, aborting parameter: " + parameterName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special case for null value.
|
// Special case for null value.
|
||||||
if (parameter==null) {
|
if (parameter == null) {
|
||||||
logger.finest("Found parameter is null Setting method: "+lastMethod.getParameterTypes()[0]+" for parameter: "+parameterName);
|
logger.finest("Found parameter is null Setting method: " + lastMethod.getParameterTypes()[0] + " for parameter: " + parameterName);
|
||||||
try {
|
try {
|
||||||
lastMethod.invoke(object,new Object[]{parameter});
|
lastMethod.invoke(object, new Object[] { parameter });
|
||||||
return;
|
return;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ElementObjectPropertyValueException(e.getMessage(),e);
|
throw new ElementObjectPropertyValueException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invoke for class based parameters
|
// Invoke for class based parameters
|
||||||
if (lastMethod.getParameterTypes()[0].isAssignableFrom(parameter.getClass())) {
|
if (lastMethod.getParameterTypes()[0].isAssignableFrom(parameter.getClass())) {
|
||||||
logger.finest("Found parameter type: "+lastMethod.getParameterTypes()[0]+" for parameter: "+parameterName+" setting value: "+parameter);
|
logger.finest("Found parameter type: " + lastMethod.getParameterTypes()[0] + " for parameter: " + parameterName + " setting value: " + parameter);
|
||||||
try {
|
try {
|
||||||
lastMethod.invoke(object,new Object[]{parameter});
|
lastMethod.invoke(object, new Object[] { parameter });
|
||||||
return;
|
return;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ElementObjectPropertyValueException(e.getMessage(),e);
|
throw new ElementObjectPropertyValueException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invoke for native based types
|
// Invoke for native based types
|
||||||
|
|
||||||
|
|
||||||
// not found 2sec try
|
// not found 2sec try
|
||||||
logger.finest("No corresoning class is found, trying convert manualy");
|
logger.finest("No corresoning class is found, trying convert manualy");
|
||||||
|
|
||||||
// special case for object.
|
// special case for object.
|
||||||
if (lastMethod.getParameterTypes()[0].equals(Object.class) ) {
|
if (lastMethod.getParameterTypes()[0].equals(Object.class)) {
|
||||||
logger.finest("Set Special object value: "+parameterName+" parm2: "+parameter+" on2="+lastMethod.getName()+" with="+object);
|
logger.finest("Set Special object value: " + parameterName + " parm2: " + parameter + " on2=" + lastMethod.getName() + " with=" + object);
|
||||||
try {
|
try {
|
||||||
lastMethod.invoke(object,new Object[]{parameter});
|
lastMethod.invoke(object, new Object[] { parameter });
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ElementObjectPropertyValueException(e.getMessage(),e);
|
throw new ElementObjectPropertyValueException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// all below creates from string
|
// all below creates from string
|
||||||
if (parameter.toString().length()==0) {
|
if (parameter.toString().length() == 0) {
|
||||||
return; // can't set value from string with empty size.
|
return; // can't set value from string with empty size.
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// JAVA OBJECT TYPES:
|
// JAVA OBJECT TYPES:
|
||||||
//
|
//
|
||||||
Object parameter2 = null;
|
Object parameter2 = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DefaultObjectConverterProvider convProvider = new DefaultObjectConverterProvider();
|
DefaultObjectConverterProvider convProvider = new DefaultObjectConverterProvider();
|
||||||
convProvider.addDefaults();
|
convProvider.addDefaults();
|
||||||
ObjectConverter conv = convProvider.getObjectConverterForClass(lastMethod.getParameterTypes()[0]);
|
ObjectConverter conv = convProvider.getObjectConverterForClass(lastMethod.getParameterTypes()[0]);
|
||||||
if (conv!=null) {
|
if (conv != null) {
|
||||||
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* JAVA NATIVE TYPES:
|
* JAVA NATIVE TYPES:
|
||||||
*
|
*
|
||||||
* TYPE: Size in bits:
|
* TYPE: Size in bits: boolean 8, unsigned byte 8 char 16, unsigned short 16 int 32 long 64 float 32 double 64 void n/a
|
||||||
* boolean 8, unsigned
|
|
||||||
* byte 8
|
|
||||||
* char 16, unsigned
|
|
||||||
* short 16
|
|
||||||
* int 32
|
|
||||||
* long 64
|
|
||||||
* float 32
|
|
||||||
* double 64
|
|
||||||
* void n/a
|
|
||||||
*/
|
*/
|
||||||
if (lastMethod.getParameterTypes()[0].isAssignableFrom(Boolean.TYPE) ) {
|
if (lastMethod.getParameterTypes()[0].isAssignableFrom(Boolean.TYPE)) {
|
||||||
conv = convProvider.getObjectConverterForClass(Boolean.class);
|
conv = convProvider.getObjectConverterForClass(Boolean.class);
|
||||||
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
||||||
}
|
}
|
||||||
if (lastMethod.getParameterTypes()[0].isAssignableFrom(Integer.TYPE) ) {
|
if (lastMethod.getParameterTypes()[0].isAssignableFrom(Integer.TYPE)) {
|
||||||
conv = convProvider.getObjectConverterForClass(Integer.class);
|
conv = convProvider.getObjectConverterForClass(Integer.class);
|
||||||
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
||||||
}
|
}
|
||||||
if (lastMethod.getParameterTypes()[0].isAssignableFrom(Long.TYPE) ) {
|
if (lastMethod.getParameterTypes()[0].isAssignableFrom(Long.TYPE)) {
|
||||||
conv = convProvider.getObjectConverterForClass(Long.class);
|
conv = convProvider.getObjectConverterForClass(Long.class);
|
||||||
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
||||||
}
|
}
|
||||||
if (lastMethod.getParameterTypes()[0].isAssignableFrom(Double.TYPE) ) {
|
if (lastMethod.getParameterTypes()[0].isAssignableFrom(Double.TYPE)) {
|
||||||
conv = convProvider.getObjectConverterForClass(Double.class);
|
conv = convProvider.getObjectConverterForClass(Double.class);
|
||||||
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
||||||
}
|
}
|
||||||
if (lastMethod.getParameterTypes()[0].isAssignableFrom(Float.TYPE) ) {
|
if (lastMethod.getParameterTypes()[0].isAssignableFrom(Float.TYPE)) {
|
||||||
conv = convProvider.getObjectConverterForClass(Float.class);
|
conv = convProvider.getObjectConverterForClass(Float.class);
|
||||||
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
||||||
}
|
}
|
||||||
if (lastMethod.getParameterTypes()[0].isAssignableFrom(Byte.TYPE) ) {
|
if (lastMethod.getParameterTypes()[0].isAssignableFrom(Byte.TYPE)) {
|
||||||
conv = convProvider.getObjectConverterForClass(Byte.class);
|
conv = convProvider.getObjectConverterForClass(Byte.class);
|
||||||
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
||||||
}
|
}
|
||||||
if (lastMethod.getParameterTypes()[0].isAssignableFrom(Character.TYPE) ) {
|
if (lastMethod.getParameterTypes()[0].isAssignableFrom(Character.TYPE)) {
|
||||||
conv = convProvider.getObjectConverterForClass(Character.class);
|
conv = convProvider.getObjectConverterForClass(Character.class);
|
||||||
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
parameter2 = conv.convertTo(parameter.toString(), Locale.getDefault());
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (ObjectConverterException oce) {
|
} catch (ObjectConverterException oce) {
|
||||||
throw new ElementObjectPropertyValueException(oce.getMessage(),oce);
|
throw new ElementObjectPropertyValueException(oce.getMessage(), oce);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parameter2==null) {
|
if (parameter2 == null) {
|
||||||
throw new ElementObjectPropertyValueException("Could not convert to type for parameter: '"+parameterName+"' value: '"+parameter+"'");
|
throw new ElementObjectPropertyValueException("Could not convert to type for parameter: '" + parameterName + "' value: '" + parameter + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.finest("Set value: "+parameterName+" parm2: "+parameter2+" on2="+lastMethod.getName()+" with="+object);
|
logger.finest("Set value: " + parameterName + " parm2: " + parameter2 + " on2=" + lastMethod.getName() + " with=" + object);
|
||||||
try {
|
try {
|
||||||
lastMethod.invoke(object,new Object[]{parameter2});
|
lastMethod.invoke(object, new Object[] { parameter2 });
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ElementObjectPropertyValueException(e.getMessage(),e);
|
throw new ElementObjectPropertyValueException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the property of an bean.
|
* Gets the property of an bean.
|
||||||
*
|
*
|
||||||
* @param object The object to get from.
|
* @param object The object to get from.
|
||||||
* @param parameterName The parameter name of the property to get.
|
* @param parameterName The parameter name of the property to get.
|
||||||
* @throws ElementObjectPropertyValueException
|
* @throws ElementObjectPropertyValueException
|
||||||
*/
|
*/
|
||||||
public Object getProperty(Object object,String parameterName) throws ElementObjectPropertyValueException {
|
public Object getProperty(Object object, String parameterName) throws ElementObjectPropertyValueException {
|
||||||
|
|
||||||
if (object==null) {
|
if (object == null) {
|
||||||
throw new NullPointerException("Can't get property of null object.");
|
throw new NullPointerException("Can't get property of null object.");
|
||||||
}
|
}
|
||||||
if (parameterName==null) {
|
if (parameterName == null) {
|
||||||
throw new NullPointerException("Can't get property is the name is null.");
|
throw new NullPointerException("Can't get property is the name is null.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger logger = Logger.getLogger(DefaultElementObjectPropertyValue.class.getName());
|
Logger logger = Logger.getLogger(DefaultElementObjectPropertyValue.class.getName());
|
||||||
|
|
||||||
String propRest = null;
|
String propRest = null;
|
||||||
int index = parameterName.indexOf(".");
|
int index = parameterName.indexOf(".");
|
||||||
if(index>0) {
|
if (index > 0) {
|
||||||
propRest = parameterName.substring(index+1);
|
propRest = parameterName.substring(index + 1);
|
||||||
parameterName = parameterName.substring(0,index);
|
parameterName = parameterName.substring(0, index);
|
||||||
logger.finest("slit property into: '"+propRest+"' and '"+parameterName+"'");
|
logger.finest("slit property into: '" + propRest + "' and '" + parameterName + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.finer("Trying value: pn="+parameterName+" o="+object);
|
logger.finer("Trying value: pn=" + parameterName + " o=" + object);
|
||||||
String parameterNameSet = "get"+parameterName;
|
String parameterNameSet = "get" + parameterName;
|
||||||
Method[] methodes = object.getClass().getMethods();
|
Method[] methodes = object.getClass().getMethods();
|
||||||
Method lastMethod = null;
|
Method lastMethod = null;
|
||||||
|
|
||||||
// a bit hackie
|
// a bit hackie
|
||||||
for(int i=0;i<methodes.length;i++) {
|
for (int i = 0; i < methodes.length; i++) {
|
||||||
Method method = methodes[i];
|
Method method = methodes[i];
|
||||||
Class<?>[] types = method.getParameterTypes();
|
Class<?>[] types = method.getParameterTypes();
|
||||||
if (types.length != 0) {
|
if (types.length != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(method.getName().equalsIgnoreCase(parameterNameSet)) {
|
if (method.getName().equalsIgnoreCase(parameterNameSet)) {
|
||||||
logger.finest("Found method: "+method.getName());
|
logger.finest("Found method: " + method.getName());
|
||||||
lastMethod = method;
|
lastMethod = method;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastMethod==null) {
|
if (lastMethod == null) {
|
||||||
for(int i=0;i<methodes.length;i++) {
|
for (int i = 0; i < methodes.length; i++) {
|
||||||
Method method = methodes[i];
|
Method method = methodes[i];
|
||||||
if(method.getName().equalsIgnoreCase("is"+parameterName)) {
|
if (method.getName().equalsIgnoreCase("is" + parameterName)) {
|
||||||
logger.finest("Found is method: "+method.getName());
|
logger.finest("Found is method: " + method.getName());
|
||||||
lastMethod = method;
|
lastMethod = method;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(method.getName().equalsIgnoreCase("has"+parameterName)) {
|
if (method.getName().equalsIgnoreCase("has" + parameterName)) {
|
||||||
logger.finest("Found has method: "+method.getName());
|
logger.finest("Found has method: " + method.getName());
|
||||||
lastMethod = method;
|
lastMethod = method;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastMethod==null) {
|
if (lastMethod == null) {
|
||||||
throw new ElementObjectPropertyValueException("Could not find method for parameter: '"+parameterName+"' object: '"+object+"'");
|
throw new ElementObjectPropertyValueException("Could not find method for parameter: '" + parameterName + "' object: '" + object + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
Object result = null;
|
Object result = null;
|
||||||
try {
|
try {
|
||||||
result = lastMethod.invoke(object,new Object[]{});
|
result = lastMethod.invoke(object, new Object[] {});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ElementObjectPropertyValueException(e.getMessage(),e);
|
throw new ElementObjectPropertyValueException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (propRest!=null) {
|
if (propRest != null) {
|
||||||
if (result==null) {
|
if (result == null) {
|
||||||
return null; // no need to go deeper into a null value.
|
return null; // no need to go deeper into a null value.
|
||||||
}
|
}
|
||||||
// recursif function:
|
// recursif function:
|
||||||
return getProperty(result,propRest);
|
return getProperty(result, propRest);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementObjectPropertyValue#setPropertyMap(java.lang.Object, java.util.Map)
|
* @see org.x4o.xml.element.ElementObjectPropertyValue#setPropertyMap(java.lang.Object, java.util.Map)
|
||||||
*/
|
*/
|
||||||
public void setPropertyMap(Object object, Map<String, Object> attributes) throws ElementObjectPropertyValueException {
|
public void setPropertyMap(Object object, Map<String, Object> attributes) throws ElementObjectPropertyValueException {
|
||||||
Iterator<String> keyIterator = attributes.keySet().iterator();
|
Iterator<String> keyIterator = attributes.keySet().iterator();
|
||||||
while(keyIterator.hasNext()) {
|
while (keyIterator.hasNext()) {
|
||||||
String key = keyIterator.next();
|
String key = keyIterator.next();
|
||||||
setProperty(object,key,attributes.get(key));
|
setProperty(object, key, attributes.get(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -32,43 +32,43 @@ import org.x4o.xml.lang.X4OLanguageSession;
|
||||||
* Defines an XML element with an object.<br>
|
* Defines an XML element with an object.<br>
|
||||||
* <br>
|
* <br>
|
||||||
* The main function is to store the ElementObject.<br>
|
* The main function is to store the ElementObject.<br>
|
||||||
* Also we can configure the ElementObject from differted events hooks.
|
* Also we can configure the ElementObject from differted events hooks. from the attibutes or parent (object)element.
|
||||||
* from the attibutes or parent (object)element.
|
|
||||||
*
|
*
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Feb 01, 2005
|
* @version 1.0 Feb 01, 2005
|
||||||
*/
|
*/
|
||||||
public interface Element {
|
public interface Element {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ElementTypes which are possible.
|
* The ElementTypes which are possible.
|
||||||
*/
|
*/
|
||||||
public enum ElementType {
|
public enum ElementType {
|
||||||
|
|
||||||
/** The normale ElementType, which is mostly bound to an object. */
|
/** The normale ElementType, which is mostly bound to an object. */
|
||||||
element,
|
element,
|
||||||
|
|
||||||
/** Extra meta characters in xml. */
|
/** Extra meta characters in xml. */
|
||||||
characters,
|
characters,
|
||||||
|
|
||||||
/** The xml comments in xml. */
|
/** The xml comments in xml. */
|
||||||
comment,
|
comment,
|
||||||
|
|
||||||
/** ignorableWhitespace in xml. */
|
/** ignorableWhitespace in xml. */
|
||||||
ignorableWhitespace,
|
ignorableWhitespace,
|
||||||
|
|
||||||
/** Receive raw sax event on elementObject. */
|
/** Receive raw sax event on elementObject. */
|
||||||
overrideSax;
|
overrideSax;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the given elments list to elementType.
|
* Filters the given elments list to elementType.
|
||||||
* @param elements The elements to filter.
|
*
|
||||||
* @param elementType The elementType to filter on.
|
* @param elements The elements to filter.
|
||||||
* @return Always returns List of Elements of filter type.
|
* @param elementType The elementType to filter on.
|
||||||
|
* @return Always returns List of Elements of filter type.
|
||||||
*/
|
*/
|
||||||
public static List<Element> filterElements(List<Element> elements,ElementType elementType) {
|
public static List<Element> filterElements(List<Element> elements, ElementType elementType) {
|
||||||
List<Element> result = new ArrayList<Element>(3);
|
List<Element> result = new ArrayList<Element>(3);
|
||||||
for (int i=0;i<elements.size();i++) {
|
for (int i = 0; i < elements.size(); i++) {
|
||||||
Element element = elements.get(i);
|
Element element = elements.get(i);
|
||||||
if (elementType == element.getElementType()) {
|
if (elementType == element.getElementType()) {
|
||||||
result.add(element);
|
result.add(element);
|
||||||
|
|
@ -77,151 +77,170 @@ public interface Element {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is fired when the end xml tag is parsed.
|
* This method is fired when the end xml tag is parsed.
|
||||||
|
*
|
||||||
* @throws ElementException Can be thrown when structure is not correct.
|
* @throws ElementException Can be thrown when structure is not correct.
|
||||||
*/
|
*/
|
||||||
void doElementEnd() throws ElementException;
|
void doElementEnd() throws ElementException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is fired when the start of xml tag is parsed.
|
* This method is fired when the start of xml tag is parsed.
|
||||||
|
*
|
||||||
* @throws ElementException Can be thrown when structure is not correct.
|
* @throws ElementException Can be thrown when structure is not correct.
|
||||||
*/
|
*/
|
||||||
void doElementStart() throws ElementException;
|
void doElementStart() throws ElementException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is fired only once in the run phase.
|
* This method is fired only once in the run phase.
|
||||||
|
*
|
||||||
* @throws ElementException Can be thrown when structure is not correct.
|
* @throws ElementException Can be thrown when structure is not correct.
|
||||||
*/
|
*/
|
||||||
void doElementRun() throws ElementException;
|
void doElementRun() throws ElementException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the parent Element.
|
* Set the parent Element.
|
||||||
* @param element The paraent Element to set.
|
*
|
||||||
|
* @param element The paraent Element to set.
|
||||||
*/
|
*/
|
||||||
void setParent(Element element);
|
void setParent(Element element);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the parent Element.<br>
|
* Returns the parent Element.<br>
|
||||||
* Or null when there is no parent Element.
|
* Or null when there is no parent Element.
|
||||||
*
|
*
|
||||||
* @return Returns the parent Element
|
* @return Returns the parent Element
|
||||||
*/
|
*/
|
||||||
Element getParent();
|
Element getParent();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method get called when this Element object is not needed anymore.<br>
|
* This method get called when this Element object is not needed anymore.<br>
|
||||||
* Can be used to close resources.
|
* Can be used to close resources.
|
||||||
|
*
|
||||||
* @throws ElementException Can be thrown when structure is not correct.
|
* @throws ElementException Can be thrown when structure is not correct.
|
||||||
*/
|
*/
|
||||||
void release() throws ElementException;
|
void release() throws ElementException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gives back the object this Element has made and configed.<br>
|
* Gives back the object this Element has made and configed.<br>
|
||||||
* So other elements can do stuff to that object.<br>
|
* So other elements can do stuff to that object.<br>
|
||||||
*
|
*
|
||||||
* @return An Object.
|
* @return An Object.
|
||||||
*/
|
*/
|
||||||
Object getElementObject();
|
Object getElementObject();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the object which we control.
|
* Sets the object which we control.
|
||||||
* @param object The object to configed by this element.
|
*
|
||||||
|
* @param object The object to configed by this element.
|
||||||
*/
|
*/
|
||||||
void setElementObject(Object object);
|
void setElementObject(Object object);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the X4OLanguageSession.
|
* Sets the X4OLanguageSession.
|
||||||
* @param languageSession The X4OLanguageSession to set.
|
*
|
||||||
|
* @param languageSession The X4OLanguageSession to set.
|
||||||
*/
|
*/
|
||||||
void setLanguageSession(X4OLanguageSession languageSession);
|
void setLanguageSession(X4OLanguageSession languageSession);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the X4OLanguageSession.
|
* Gets the X4OLanguageSession.
|
||||||
* @return Returns the X4OLanguageSession.
|
*
|
||||||
|
* @return Returns the X4OLanguageSession.
|
||||||
*/
|
*/
|
||||||
X4OLanguageSession getLanguageSession();
|
X4OLanguageSession getLanguageSession();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the body texts on an event based system.
|
* Sets the body texts on an event based system.
|
||||||
* @param body The body text.
|
*
|
||||||
|
* @param body The body text.
|
||||||
* @throws ElementException Can be thrown when structure is not correct.
|
* @throws ElementException Can be thrown when structure is not correct.
|
||||||
*/
|
*/
|
||||||
void doCharacters(String body) throws ElementException;
|
void doCharacters(String body) throws ElementException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the comment texts on an event based system.
|
* Sets the comment texts on an event based system.
|
||||||
* @param comment The comment text.
|
*
|
||||||
|
* @param comment The comment text.
|
||||||
* @throws ElementException Can be thrown when structure is not correct.
|
* @throws ElementException Can be thrown when structure is not correct.
|
||||||
*/
|
*/
|
||||||
void doComment(String comment) throws ElementException;
|
void doComment(String comment) throws ElementException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is called when there is whitespace in xml.
|
* Is called when there is whitespace in xml.
|
||||||
* @param space The space.
|
*
|
||||||
|
* @param space The space.
|
||||||
* @throws ElementException Can be thrown when structure is not correct.
|
* @throws ElementException Can be thrown when structure is not correct.
|
||||||
*/
|
*/
|
||||||
void doIgnorableWhitespace(String space) throws ElementException;
|
void doIgnorableWhitespace(String space) throws ElementException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the ElementClass.
|
* Sets the ElementClass.
|
||||||
* @param elementClass The ElementClass to set.
|
*
|
||||||
|
* @param elementClass The ElementClass to set.
|
||||||
*/
|
*/
|
||||||
void setElementClass(ElementClass elementClass);
|
void setElementClass(ElementClass elementClass);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the ElementClass.
|
* Gets the ElementClass.
|
||||||
* @return Returns the ElementClass.
|
*
|
||||||
|
* @return Returns the ElementClass.
|
||||||
*/
|
*/
|
||||||
ElementClass getElementClass();
|
ElementClass getElementClass();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the xml attributes.
|
* Sets the xml attributes.
|
||||||
* @param name The name to set.
|
*
|
||||||
* @param value The value to set.
|
* @param name The name to set.
|
||||||
|
* @param value The value to set.
|
||||||
*/
|
*/
|
||||||
void setAttribute(String name,String value);
|
void setAttribute(String name, String value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the xml attributes.
|
* Gets the xml attributes.
|
||||||
* @return Returns the xml attributes.
|
*
|
||||||
|
* @return Returns the xml attributes.
|
||||||
*/
|
*/
|
||||||
Map<String,String> getAttributes();
|
Map<String, String> getAttributes();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the childeren elements.
|
* Gets the childeren elements.
|
||||||
* @return Returns the childeren.
|
*
|
||||||
|
* @return Returns the childeren.
|
||||||
*/
|
*/
|
||||||
List<Element> getChilderen();
|
List<Element> getChilderen();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the childeren elements including those which are comment and white space. (text)
|
* Gets the childeren elements including those which are comment and white space. (text)
|
||||||
* @return Returns all the childeren.
|
*
|
||||||
|
* @return Returns all the childeren.
|
||||||
*/
|
*/
|
||||||
List<Element> getAllChilderen();
|
List<Element> getAllChilderen();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an Elment as child of this element.
|
* Adds an Elment as child of this element.
|
||||||
* @param element The child to add.
|
*
|
||||||
|
* @param element The child to add.
|
||||||
*/
|
*/
|
||||||
void addChild(Element element);
|
void addChild(Element element);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes an Elment as child of this element.
|
* Removes an Elment as child of this element.
|
||||||
* @param element The child to remove.
|
*
|
||||||
|
* @param element The child to remove.
|
||||||
*/
|
*/
|
||||||
void removeChild(Element element);
|
void removeChild(Element element);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Element type.
|
* Gets the Element type.
|
||||||
* @return Returns the ElementType.
|
*
|
||||||
|
* @return Returns the ElementType.
|
||||||
*/
|
*/
|
||||||
ElementType getElementType();
|
ElementType getElementType();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if this elements transforms the tree.
|
* Returns if this elements transforms the tree. if true the the doElementRun is runned in the transform phase insteat of the run phase.
|
||||||
* if true the the doElementRun is runned in the transform phase insteat of the run phase.
|
|
||||||
*
|
*
|
||||||
* You need to add those new or modified Elements to the DirtyElement for reparsering.
|
* You need to add those new or modified Elements to the DirtyElement for reparsering.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
import org.x4o.xml.conv.ObjectConverterException;
|
import org.x4o.xml.conv.ObjectConverterException;
|
||||||
|
|
||||||
|
|
@ -31,46 +31,49 @@ import org.x4o.xml.conv.ObjectConverterException;
|
||||||
* @version 1.0 Aug 20, 2005
|
* @version 1.0 Aug 20, 2005
|
||||||
*/
|
*/
|
||||||
public interface ElementAttributeValueParser {
|
public interface ElementAttributeValueParser {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the value is an EL parameter.
|
* Checks if the value is an EL parameter.
|
||||||
* @param name The name of the attribute.
|
*
|
||||||
* @param value The value of the attribute.
|
* @param name The name of the attribute.
|
||||||
* @param element The element of the attribute.
|
* @param value The value of the attribute.
|
||||||
* @return Returns true if value is EL parameter.
|
* @param element The element of the attribute.
|
||||||
|
* @return Returns true if value is EL parameter.
|
||||||
*/
|
*/
|
||||||
boolean isELParameter(String name,String value,Element element);
|
boolean isELParameter(String name, String value, Element element);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the object which is stored in the ELContext
|
* Returns the object which is stored in the ELContext
|
||||||
* @param value The attribute value.
|
*
|
||||||
* @param element The element of the attribute.
|
* @param value The attribute value.
|
||||||
* @return Returns the resolved el parameter value.
|
* @param element The element of the attribute.
|
||||||
|
* @return Returns the resolved el parameter value.
|
||||||
* @throws ElementAttributeValueParserException
|
* @throws ElementAttributeValueParserException
|
||||||
* @throws ObjectConverterException
|
* @throws ObjectConverterException
|
||||||
*/
|
*/
|
||||||
Object getELParameterValue(String value,Element element) throws ElementAttributeValueParserException,ObjectConverterException;
|
Object getELParameterValue(String value, Element element) throws ElementAttributeValueParserException, ObjectConverterException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert the value into a new value genereted by parameterConverters.
|
* Convert the value into a new value genereted by parameterConverters.
|
||||||
* @param name The name of the attribute.
|
*
|
||||||
* @param value The value of the attribute.
|
* @param name The name of the attribute.
|
||||||
* @param element The element of the attribute.
|
* @param value The value of the attribute.
|
||||||
* @return Returns the converted attribute value.
|
* @param element The element of the attribute.
|
||||||
|
* @return Returns the converted attribute value.
|
||||||
* @throws ElementAttributeValueParserException
|
* @throws ElementAttributeValueParserException
|
||||||
* @throws ObjectConverterException
|
* @throws ObjectConverterException
|
||||||
*/
|
*/
|
||||||
Object getConvertedParameterValue(String name,Object value,Element element) throws ElementAttributeValueParserException,ObjectConverterException;
|
Object getConvertedParameterValue(String name, Object value, Element element) throws ElementAttributeValueParserException, ObjectConverterException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Does is all, Checks if value is EL parameter and lookups the object.
|
* Does is all, Checks if value is EL parameter and lookups the object. and converts to new object via parameter converter and return value.
|
||||||
* and converts to new object via parameter converter and return value.
|
*
|
||||||
* @param name The name of the attribute.
|
* @param name The name of the attribute.
|
||||||
* @param value The value of the attribute.
|
* @param value The value of the attribute.
|
||||||
* @param element The element of the attribute.
|
* @param element The element of the attribute.
|
||||||
* @return Returns the attribute value.
|
* @return Returns the attribute value.
|
||||||
* @throws ElementAttributeValueParserException
|
* @throws ElementAttributeValueParserException
|
||||||
* @throws ObjectConverterException
|
* @throws ObjectConverterException
|
||||||
*/
|
*/
|
||||||
Object getParameterValue(String name,String value,Element element) throws ElementAttributeValueParserException,ObjectConverterException;
|
Object getParameterValue(String name, String value, Element element) throws ElementAttributeValueParserException, ObjectConverterException;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ElementAttributeValueParserException.<br>
|
* ElementAttributeValueParserException.<br>
|
||||||
|
|
@ -33,14 +32,10 @@ package org.x4o.xml.element;
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class ElementAttributeValueParserException extends ElementException {
|
public class ElementAttributeValueParserException extends ElementException {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
public ElementAttributeValueParserException(ElementAttributeConverter converter,String message) {
|
* public ElementAttributeValueParserException(ElementAttributeConverter converter,String message) { super(message); }
|
||||||
super(message);
|
*
|
||||||
}
|
* public ElementAttributeValueParserException(ElementAttributeConverter converter,String message,Exception exception) { super(message,exception); }
|
||||||
|
*/
|
||||||
public ElementAttributeValueParserException(ElementAttributeConverter converter,String message,Exception exception) {
|
|
||||||
super(message,exception);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,42 +20,42 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bind ElementObjects together.
|
* Bind ElementObjects together.
|
||||||
*
|
*
|
||||||
* This interface is used to bind a parent and child ElementObject together.
|
* This interface is used to bind a parent and child ElementObject together. For example; when both objects are an JComponent then we can add the child to the
|
||||||
* For example; when both objects are an JComponent then we can add the child to the parent
|
* parent with the method: ((JComponent)parent).add((JComponent)child);
|
||||||
* with the method: ((JComponent)parent).add((JComponent)child);
|
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Aug 17, 2005
|
* @version 1.0 Aug 17, 2005
|
||||||
*/
|
*/
|
||||||
public interface ElementBindingHandler extends ElementMetaBase {
|
public interface ElementBindingHandler extends ElementMetaBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the parent classes which this binding handler can do.
|
* @return Returns the parent classes which this binding handler can do.
|
||||||
*/
|
*/
|
||||||
Class<?> getBindParentClass();
|
Class<?> getBindParentClass();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns array of child classes which this binding handler can do.
|
* @return Returns array of child classes which this binding handler can do.
|
||||||
*/
|
*/
|
||||||
Class<?>[] getBindChildClasses();
|
Class<?>[] getBindChildClasses();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do the binding of this child to the parent object.
|
* Do the binding of this child to the parent object.
|
||||||
* @param childElement The child element to bind to the parent.'
|
*
|
||||||
|
* @param childElement The child element to bind to the parent.'
|
||||||
* @throws ElementBindingHandlerException When binding could not happen.
|
* @throws ElementBindingHandlerException When binding could not happen.
|
||||||
*/
|
*/
|
||||||
void bindChild(Element childElement) throws ElementBindingHandlerException;
|
void bindChild(Element childElement) throws ElementBindingHandlerException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the childeren of the parent object.
|
* Creates the childeren of the parent object.
|
||||||
* @param parentElement The parent element to create the childeren from.'
|
*
|
||||||
|
* @param parentElement The parent element to create the childeren from.'
|
||||||
* @throws ElementBindingHandlerException When binding could not happen.
|
* @throws ElementBindingHandlerException When binding could not happen.
|
||||||
*/
|
*/
|
||||||
void createChilderen(Element parentElement) throws ElementBindingHandlerException;
|
void createChilderen(Element parentElement) throws ElementBindingHandlerException;
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ElementBindingException.<br>
|
* ElementBindingException.<br>
|
||||||
|
|
@ -33,21 +32,23 @@ package org.x4o.xml.element;
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class ElementBindingHandlerException extends ElementException {
|
public class ElementBindingHandlerException extends ElementException {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates binding exception.
|
* Creates binding exception.
|
||||||
* @param message The error message.
|
*
|
||||||
|
* @param message The error message.
|
||||||
*/
|
*/
|
||||||
public ElementBindingHandlerException(String message) {
|
public ElementBindingHandlerException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates binding exception.
|
* Creates binding exception.
|
||||||
* @param message The error message.
|
*
|
||||||
* @param exception The error exception.
|
* @param message The error message.
|
||||||
|
* @param exception The error exception.
|
||||||
*/
|
*/
|
||||||
public ElementBindingHandlerException(String message,Exception exception) {
|
public ElementBindingHandlerException(String message, Exception exception) {
|
||||||
super(message,exception);
|
super(message, exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -32,15 +32,17 @@ import java.util.List;
|
||||||
* @version 1.0 Aug 11, 2005
|
* @version 1.0 Aug 11, 2005
|
||||||
*/
|
*/
|
||||||
public interface ElementClass extends ElementClassBase {
|
public interface ElementClass extends ElementClassBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the ElementClass.
|
* Gets the ElementClass.
|
||||||
|
*
|
||||||
* @return the elementClass
|
* @return the elementClass
|
||||||
*/
|
*/
|
||||||
Class<?> getElementClass();
|
Class<?> getElementClass();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the ElementClass.
|
* Sets the ElementClass.
|
||||||
|
*
|
||||||
* @param elementClass the elementClass to set.
|
* @param elementClass the elementClass to set.
|
||||||
*/
|
*/
|
||||||
void setElementClass(Class<?> elementClass);
|
void setElementClass(Class<?> elementClass);
|
||||||
|
|
@ -54,7 +56,7 @@ public interface ElementClass extends ElementClassBase {
|
||||||
* @param objectClass the objectClass to set.
|
* @param objectClass the objectClass to set.
|
||||||
*/
|
*/
|
||||||
void setObjectClass(Class<?> objectClass);
|
void setObjectClass(Class<?> objectClass);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the autoAttributes.
|
* @return the autoAttributes.
|
||||||
*/
|
*/
|
||||||
|
|
@ -64,7 +66,7 @@ public interface ElementClass extends ElementClassBase {
|
||||||
* @param autoAttributes the autoAttributes to set.
|
* @param autoAttributes the autoAttributes to set.
|
||||||
*/
|
*/
|
||||||
void setAutoAttributes(Boolean autoAttributes);
|
void setAutoAttributes(Boolean autoAttributes);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the schemaContentBase
|
* @return the schemaContentBase
|
||||||
*/
|
*/
|
||||||
|
|
@ -74,7 +76,7 @@ public interface ElementClass extends ElementClassBase {
|
||||||
* @param schemaContentBase the schemaContentBase to set
|
* @param schemaContentBase the schemaContentBase to set
|
||||||
*/
|
*/
|
||||||
void setSchemaContentBase(String schemaContentBase);
|
void setSchemaContentBase(String schemaContentBase);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the schemaContentComplex
|
* @return the schemaContentComplex
|
||||||
*/
|
*/
|
||||||
|
|
@ -94,22 +96,25 @@ public interface ElementClass extends ElementClassBase {
|
||||||
* @param schemaContentMixed the schemaContentMixed to set
|
* @param schemaContentMixed the schemaContentMixed to set
|
||||||
*/
|
*/
|
||||||
void setSchemaContentMixed(Boolean schemaContentMixed);
|
void setSchemaContentMixed(Boolean schemaContentMixed);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an skip phase for this element.
|
* Add an skip phase for this element.
|
||||||
* @param phase The phase name.
|
*
|
||||||
|
* @param phase The phase name.
|
||||||
*/
|
*/
|
||||||
void addSkipPhase(String phase);
|
void addSkipPhase(String phase);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes an skip phase for this element.
|
* Removes an skip phase for this element.
|
||||||
* @param phase The phase name.
|
*
|
||||||
|
* @param phase The phase name.
|
||||||
*/
|
*/
|
||||||
void removeSkipPhase(String phase);
|
void removeSkipPhase(String phase);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all the skip phases for this element.
|
* Get all the skip phases for this element.
|
||||||
* @return The defined phases.
|
*
|
||||||
|
* @return The defined phases.
|
||||||
*/
|
*/
|
||||||
List<String> getSkipPhases();
|
List<String> getSkipPhases();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -34,61 +34,70 @@ import org.x4o.xml.conv.ObjectConverter;
|
||||||
* @version 1.0 Aug 11, 2005
|
* @version 1.0 Aug 11, 2005
|
||||||
*/
|
*/
|
||||||
public interface ElementClassAttribute extends ElementMetaBase {
|
public interface ElementClassAttribute extends ElementMetaBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the ObjectConverter.
|
* Gets the ObjectConverter.
|
||||||
|
*
|
||||||
* @return The ObjectConverter.
|
* @return The ObjectConverter.
|
||||||
*/
|
*/
|
||||||
ObjectConverter getObjectConverter();
|
ObjectConverter getObjectConverter();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the ObjectConverter whichs converts.
|
* Add the ObjectConverter whichs converts.
|
||||||
* @param objectConverter The objectConverter to set for this attribute.
|
*
|
||||||
|
* @param objectConverter The objectConverter to set for this attribute.
|
||||||
*/
|
*/
|
||||||
void setObjectConverter(ObjectConverter objectConverter);
|
void setObjectConverter(ObjectConverter objectConverter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the defaultValue of this attribute.
|
* Sets the defaultValue of this attribute.
|
||||||
* @param defaultValue The defaultValue to set.
|
*
|
||||||
|
* @param defaultValue The defaultValue to set.
|
||||||
*/
|
*/
|
||||||
void setDefaultValue(Object defaultValue);
|
void setDefaultValue(Object defaultValue);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the default value.
|
* Gets the default value.
|
||||||
* @return Returns the default value if any.
|
*
|
||||||
|
* @return Returns the default value if any.
|
||||||
*/
|
*/
|
||||||
Object getDefaultValue();
|
Object getDefaultValue();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an attribute alias for this attribute.
|
* Add an attribute alias for this attribute.
|
||||||
* @param alias The alias.
|
*
|
||||||
|
* @param alias The alias.
|
||||||
*/
|
*/
|
||||||
void addAttributeAlias(String alias);
|
void addAttributeAlias(String alias);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes an attribute alias.
|
* Removes an attribute alias.
|
||||||
* @param alias The alias.
|
*
|
||||||
|
* @param alias The alias.
|
||||||
*/
|
*/
|
||||||
void removeAttributeAlias(String alias);
|
void removeAttributeAlias(String alias);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all the aliases for this attribute.
|
* Get all the aliases for this attribute.
|
||||||
* @return The defined aliases.
|
*
|
||||||
|
* @return The defined aliases.
|
||||||
*/
|
*/
|
||||||
List<String> getAttributeAliases();
|
List<String> getAttributeAliases();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the required state of this attribute.
|
* Gets the required state of this attribute.
|
||||||
|
*
|
||||||
* @return If true then attribute is required.
|
* @return If true then attribute is required.
|
||||||
*/
|
*/
|
||||||
Boolean getRequired();
|
Boolean getRequired();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the required state of this attribute.
|
* Sets the required state of this attribute.
|
||||||
|
*
|
||||||
* @param required the required to set.
|
* @param required the required to set.
|
||||||
*/
|
*/
|
||||||
void setRequired(Boolean required);
|
void setRequired(Boolean required);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the runResolveEL.
|
* @return the runResolveEL.
|
||||||
*/
|
*/
|
||||||
|
|
@ -118,7 +127,7 @@ public interface ElementClassAttribute extends ElementMetaBase {
|
||||||
* @param runBeanValue the runBeanValue to set.
|
* @param runBeanValue the runBeanValue to set.
|
||||||
*/
|
*/
|
||||||
void setRunBeanValue(Boolean runBeanValue);
|
void setRunBeanValue(Boolean runBeanValue);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the writeOrder
|
* @return the writeOrder
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -33,35 +33,38 @@ import java.util.List;
|
||||||
* @version 1.0 Jan 19, 2012
|
* @version 1.0 Jan 19, 2012
|
||||||
*/
|
*/
|
||||||
public interface ElementClassBase extends ElementMetaBase {
|
public interface ElementClassBase extends ElementMetaBase {
|
||||||
|
|
||||||
List<ElementConfigurator> getElementConfigurators();
|
List<ElementConfigurator> getElementConfigurators();
|
||||||
|
|
||||||
void addElementConfigurators(ElementConfigurator elementConfigurator);
|
void addElementConfigurators(ElementConfigurator elementConfigurator);
|
||||||
|
|
||||||
Collection<ElementClassAttribute> getElementClassAttributes();
|
Collection<ElementClassAttribute> getElementClassAttributes();
|
||||||
|
|
||||||
ElementClassAttribute getElementClassAttributeByName(String attributeName);
|
ElementClassAttribute getElementClassAttributeByName(String attributeName);
|
||||||
|
|
||||||
void addElementClassAttribute(ElementClassAttribute elementClassAttribute);
|
void addElementClassAttribute(ElementClassAttribute elementClassAttribute);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an parent element tag.
|
* Add an parent element tag. Used: for xsd/doc only.
|
||||||
* Used: for xsd/doc only.
|
*
|
||||||
* @param namespaceUri The namespace uri of this tag relation.
|
* @param namespaceUri The namespace uri of this tag relation.
|
||||||
* @param tag The parent element tag.
|
* @param tag The parent element tag.
|
||||||
*/
|
*/
|
||||||
void addElementParent(String namespaceUri,String tag);
|
void addElementParent(String namespaceUri, String tag);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove and parent element
|
* Remove and parent element Used: for xsd/doc only.
|
||||||
* Used: for xsd/doc only.
|
*
|
||||||
* @param namespaceUri The namespace uri of this tag relation.
|
* @param namespaceUri The namespace uri of this tag relation.
|
||||||
* @param tag The parent element tag.
|
* @param tag The parent element tag.
|
||||||
*/
|
*/
|
||||||
void removeElementParent(String namespaceUri,String tag);
|
void removeElementParent(String namespaceUri, String tag);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns list of parent element tags.
|
* Returns list of parent element tags. Used: for xsd/doc only.
|
||||||
* Used: for xsd/doc only.
|
*
|
||||||
* @param namespaceUri The namespace uri of this tag relation.
|
* @param namespaceUri The namespace uri of this tag relation.
|
||||||
* @return The list of tags.
|
* @return The list of tags.
|
||||||
*/
|
*/
|
||||||
List<String> getElementParents(String namespaceUri);
|
List<String> getElementParents(String namespaceUri);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides an Interface to configure Element(Object).
|
* Provides an Interface to configure Element(Object).
|
||||||
|
|
@ -31,19 +30,20 @@ package org.x4o.xml.element;
|
||||||
* @version 1.0 Jan 18, 2007
|
* @version 1.0 Jan 18, 2007
|
||||||
*/
|
*/
|
||||||
public interface ElementConfigurator extends ElementMetaBase {
|
public interface ElementConfigurator extends ElementMetaBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets called for configuring the given Element.
|
* Gets called for configuring the given Element.
|
||||||
* @param element The element to config.
|
*
|
||||||
* @throws ElementConfiguratorException Is thrown which error is done.
|
* @param element The element to config.
|
||||||
|
* @throws ElementConfiguratorException Is thrown which error is done.
|
||||||
*/
|
*/
|
||||||
void doConfigElement(Element element) throws ElementConfiguratorException;
|
void doConfigElement(Element element) throws ElementConfiguratorException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return if this ElementConfigurator is an Action.
|
* Return if this ElementConfigurator is an Action. which means is is executed in the runPhase in the end. So all magic is done, and we can access the fully
|
||||||
* which means is is executed in the runPhase in the end.
|
* finnisched object and toss it around.
|
||||||
* So all magic is done, and we can access the fully finnisched object and toss it around.
|
*
|
||||||
* @return Returns true if need to run in config phase.
|
* @return Returns true if need to run in config phase.
|
||||||
*/
|
*/
|
||||||
boolean isConfigAction();
|
boolean isConfigAction();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ElementConfiguratorException.<br>
|
* ElementConfiguratorException.<br>
|
||||||
|
|
@ -31,44 +30,48 @@ package org.x4o.xml.element;
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class ElementConfiguratorException extends ElementException {
|
public class ElementConfiguratorException extends ElementException {
|
||||||
|
|
||||||
private ElementConfigurator elementConfigurator = null;
|
private ElementConfigurator elementConfigurator = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an configurator exception.
|
* Creates an configurator exception.
|
||||||
* @param config The ElementConfigurator.
|
*
|
||||||
* @param message The error message.
|
* @param config The ElementConfigurator.
|
||||||
|
* @param message The error message.
|
||||||
*/
|
*/
|
||||||
public ElementConfiguratorException(ElementConfigurator config,String message) {
|
public ElementConfiguratorException(ElementConfigurator config, String message) {
|
||||||
super(message);
|
super(message);
|
||||||
this.elementConfigurator=config;
|
this.elementConfigurator = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an configurator exception.
|
* Creates an configurator exception.
|
||||||
* @param config The ElementConfigurator.
|
*
|
||||||
* @param message The error message.
|
* @param config The ElementConfigurator.
|
||||||
* @param exception The error exception.
|
* @param message The error message.
|
||||||
|
* @param exception The error exception.
|
||||||
*/
|
*/
|
||||||
public ElementConfiguratorException(ElementConfigurator config,String message,Exception exception) {
|
public ElementConfiguratorException(ElementConfigurator config, String message, Exception exception) {
|
||||||
super(message,exception);
|
super(message, exception);
|
||||||
this.elementConfigurator=config;
|
this.elementConfigurator = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an configurator exception.
|
* Creates an configurator exception.
|
||||||
* @param config The ElementConfigurator.
|
*
|
||||||
* @param message The error message.
|
* @param config The ElementConfigurator.
|
||||||
* @param exception The wrapped element error exception.
|
* @param message The error message.
|
||||||
|
* @param exception The wrapped element error exception.
|
||||||
*/
|
*/
|
||||||
public ElementConfiguratorException(ElementConfigurator config,String message,ElementException exception) {
|
public ElementConfiguratorException(ElementConfigurator config, String message, ElementException exception) {
|
||||||
super(message,exception);
|
super(message, exception);
|
||||||
this.elementConfigurator=config;
|
this.elementConfigurator = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the ElementConfigurator which has thrown this exception.
|
* Gets the ElementConfigurator which has thrown this exception.
|
||||||
* @return The ElementConfigurator.
|
*
|
||||||
|
* @return The ElementConfigurator.
|
||||||
*/
|
*/
|
||||||
public ElementConfigurator getElementConfigurator() {
|
public ElementConfigurator getElementConfigurator() {
|
||||||
return elementConfigurator;
|
return elementConfigurator;
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides an Interface to configure Element(Object) global.
|
* Provides an Interface to configure Element(Object) global.
|
||||||
|
|
@ -30,5 +29,5 @@ package org.x4o.xml.element;
|
||||||
* @version 1.0 Nov 18, 2012
|
* @version 1.0 Nov 18, 2012
|
||||||
*/
|
*/
|
||||||
public interface ElementConfiguratorGlobal extends ElementConfigurator {
|
public interface ElementConfiguratorGlobal extends ElementConfigurator {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is throw when there is en Exception within an Element.
|
* Is throw when there is en Exception within an Element.
|
||||||
|
|
@ -29,7 +29,7 @@ package org.x4o.xml.element;
|
||||||
* @version 1.0 Aug 8, 2005
|
* @version 1.0 Aug 8, 2005
|
||||||
*/
|
*/
|
||||||
public class ElementException extends Exception {
|
public class ElementException extends Exception {
|
||||||
|
|
||||||
/** The serial version uid */
|
/** The serial version uid */
|
||||||
static final long serialVersionUID = 10L;
|
static final long serialVersionUID = 10L;
|
||||||
|
|
||||||
|
|
@ -42,26 +42,29 @@ public class ElementException extends Exception {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an ElementException with a detail message.
|
* Constructs an ElementException with a detail message.
|
||||||
* @param message The message of this Exception
|
*
|
||||||
|
* @param message The message of this Exception
|
||||||
*/
|
*/
|
||||||
public ElementException(String message) {
|
public ElementException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an ElementException from a parent exception.
|
* Creates an ElementException from a parent exception.
|
||||||
* @param e The error exception.
|
*
|
||||||
|
* @param e The error exception.
|
||||||
*/
|
*/
|
||||||
public ElementException(Exception e) {
|
public ElementException(Exception e) {
|
||||||
super(e);
|
super(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an ElementException with a detail message.
|
* Constructs an ElementException with a detail message.
|
||||||
* @param message The message of this Exception
|
*
|
||||||
* @param e The error exception.
|
* @param message The message of this Exception
|
||||||
|
* @param e The error exception.
|
||||||
*/
|
*/
|
||||||
public ElementException(String message,Exception e) {
|
public ElementException(String message, Exception e) {
|
||||||
super(message,e);
|
super(message, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines an ElementInterface.
|
* Defines an ElementInterface.
|
||||||
|
|
@ -29,15 +29,17 @@ package org.x4o.xml.element;
|
||||||
* @version 1.0 Apr 15, 2008
|
* @version 1.0 Apr 15, 2008
|
||||||
*/
|
*/
|
||||||
public interface ElementInterface extends ElementClassBase {
|
public interface ElementInterface extends ElementClassBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets this class of the interface to match this converters/etc/ to.
|
* Gets this class of the interface to match this converters/etc/ to.
|
||||||
|
*
|
||||||
* @return the tag.
|
* @return the tag.
|
||||||
*/
|
*/
|
||||||
Class<?> getInterfaceClass();
|
Class<?> getInterfaceClass();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the interface class.
|
* Sets the interface class.
|
||||||
|
*
|
||||||
* @param interfaceClass the interfaceClass to set.
|
* @param interfaceClass the interfaceClass to set.
|
||||||
*/
|
*/
|
||||||
void setInterfaceClass(Class<?> interfaceClass);
|
void setInterfaceClass(Class<?> interfaceClass);
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ElementMetaBase provides a base interface describe meta information.
|
* ElementMetaBase provides a base interface describe meta information.
|
||||||
|
|
@ -31,28 +30,32 @@ package org.x4o.xml.element;
|
||||||
* @version 1.0 Jan 13, 2009
|
* @version 1.0 Jan 13, 2009
|
||||||
*/
|
*/
|
||||||
public interface ElementMetaBase {
|
public interface ElementMetaBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the id of the ElementMetaBase.
|
* Sets the id of the ElementMetaBase.
|
||||||
* @param id The id to set.
|
*
|
||||||
|
* @param id The id to set.
|
||||||
*/
|
*/
|
||||||
void setId(String id);
|
void setId(String id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the id of the ElementMetaBase.
|
* Returns the id of the ElementMetaBase.
|
||||||
* @return Returns the id.
|
*
|
||||||
|
* @return Returns the id.
|
||||||
*/
|
*/
|
||||||
String getId();
|
String getId();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the description of the ElementMetaBase.
|
* Sets the description of the ElementMetaBase.
|
||||||
* @param description The description to set.
|
*
|
||||||
|
* @param description The description to set.
|
||||||
*/
|
*/
|
||||||
void setDescription(String description);
|
void setDescription(String description);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the description of the ElementMetaBase.
|
* Returns the description of the ElementMetaBase.
|
||||||
* @return Returns the description.
|
*
|
||||||
|
* @return Returns the description.
|
||||||
*/
|
*/
|
||||||
String getDescription();
|
String getDescription();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,50 +31,57 @@ import java.util.List;
|
||||||
* @version 1.0 Oct 28, 2009
|
* @version 1.0 Oct 28, 2009
|
||||||
*/
|
*/
|
||||||
public interface ElementNamespace extends ElementMetaBase {
|
public interface ElementNamespace extends ElementMetaBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the prefix mapping.
|
* Sets the prefix mapping.
|
||||||
* @param prefixMapping The prefix mapping to set.
|
*
|
||||||
|
* @param prefixMapping The prefix mapping to set.
|
||||||
*/
|
*/
|
||||||
void setPrefixMapping(String prefixMapping);
|
void setPrefixMapping(String prefixMapping);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the set prefix mapping of this namespace.
|
* Gets the set prefix mapping of this namespace.
|
||||||
|
*
|
||||||
* @return Returns the prefix mapping.
|
* @return Returns the prefix mapping.
|
||||||
*/
|
*/
|
||||||
String getPrefixMapping();
|
String getPrefixMapping();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the elememen instance provider which creates the elements objects.
|
* Sets the elememen instance provider which creates the elements objects.
|
||||||
* @param elementNamespaceInstanceProvider The ElementNamespaceInstanceProvider to set.
|
*
|
||||||
|
* @param elementNamespaceInstanceProvider The ElementNamespaceInstanceProvider to set.
|
||||||
*/
|
*/
|
||||||
void setElementNamespaceInstanceProvider(ElementNamespaceInstanceProvider elementNamespaceInstanceProvider);
|
void setElementNamespaceInstanceProvider(ElementNamespaceInstanceProvider elementNamespaceInstanceProvider);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the ElementProvider.
|
* Returns the ElementProvider.
|
||||||
* @return Returns the ElementNamespaceInstanceProvider for this namespace.
|
*
|
||||||
|
* @return Returns the ElementNamespaceInstanceProvider for this namespace.
|
||||||
*/
|
*/
|
||||||
ElementNamespaceInstanceProvider getElementNamespaceInstanceProvider();
|
ElementNamespaceInstanceProvider getElementNamespaceInstanceProvider();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an ElementClass.
|
* Adds an ElementClass.
|
||||||
* @param elementClass The elementClass to add to this context.
|
*
|
||||||
|
* @param elementClass The elementClass to add to this context.
|
||||||
*/
|
*/
|
||||||
void addElementClass(ElementClass elementClass);
|
void addElementClass(ElementClass elementClass);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the ElementClass for an namespace and tag.
|
* Gets the ElementClass for an namespace and tag.
|
||||||
* @param tag The tag to get the ElementClass for.
|
*
|
||||||
* @return Returns the ElementClass for a tag in an namespace.
|
* @param tag The tag to get the ElementClass for.
|
||||||
|
* @return Returns the ElementClass for a tag in an namespace.
|
||||||
*/
|
*/
|
||||||
ElementClass getElementClass(String tag);
|
ElementClass getElementClass(String tag);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the loaded ElementClass'es in an namespace in this context.
|
* Returns the loaded ElementClass'es in an namespace in this context.
|
||||||
* @return Returns all ElementClasses handled by this namespace.
|
*
|
||||||
|
* @return Returns all ElementClasses handled by this namespace.
|
||||||
*/
|
*/
|
||||||
List<ElementClass> getElementClasses();
|
List<ElementClass> getElementClasses();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the uri of this namespace.
|
* @return the uri of this namespace.
|
||||||
*/
|
*/
|
||||||
|
|
@ -114,7 +121,7 @@ public interface ElementNamespace extends ElementMetaBase {
|
||||||
* @param schemaResource the schemaResource to set.
|
* @param schemaResource the schemaResource to set.
|
||||||
*/
|
*/
|
||||||
void setSchemaResource(String schemaResource);
|
void setSchemaResource(String schemaResource);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the description.
|
* @return the description.
|
||||||
*/
|
*/
|
||||||
|
|
@ -124,7 +131,7 @@ public interface ElementNamespace extends ElementMetaBase {
|
||||||
* @param description the description to set.
|
* @param description the description to set.
|
||||||
*/
|
*/
|
||||||
void setDescription(String description);
|
void setDescription(String description);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the languageRoot
|
* @return the languageRoot
|
||||||
*/
|
*/
|
||||||
|
|
@ -134,7 +141,7 @@ public interface ElementNamespace extends ElementMetaBase {
|
||||||
* @param languageRoot the languageRoot to set
|
* @param languageRoot the languageRoot to set
|
||||||
*/
|
*/
|
||||||
void setLanguageRoot(Boolean languageRoot);
|
void setLanguageRoot(Boolean languageRoot);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the schemaPrefix
|
* @return the schemaPrefix
|
||||||
*/
|
*/
|
||||||
|
|
@ -144,15 +151,17 @@ public interface ElementNamespace extends ElementMetaBase {
|
||||||
* @param schemaPrefix the schemaPrefix to set
|
* @param schemaPrefix the schemaPrefix to set
|
||||||
*/
|
*/
|
||||||
void setSchemaPrefix(String schemaPrefix);
|
void setSchemaPrefix(String schemaPrefix);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an ElementNamespaceAttribute.
|
* Adds an ElementNamespaceAttribute.
|
||||||
* @param elementNamespaceAttribute Adds an ElementNamespaceAttribute.
|
*
|
||||||
|
* @param elementNamespaceAttribute Adds an ElementNamespaceAttribute.
|
||||||
*/
|
*/
|
||||||
void addElementNamespaceAttribute(ElementNamespaceAttribute elementNamespaceAttribute);
|
void addElementNamespaceAttribute(ElementNamespaceAttribute elementNamespaceAttribute);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Geta All ElementNamespaceAttributes.
|
* Geta All ElementNamespaceAttributes.
|
||||||
|
*
|
||||||
* @return Returns an List of ElementNamespaceAttributes.
|
* @return Returns an List of ElementNamespaceAttributes.
|
||||||
*/
|
*/
|
||||||
List<ElementNamespaceAttribute> getElementNamespaceAttributes();
|
List<ElementNamespaceAttribute> getElementNamespaceAttributes();
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -31,35 +31,39 @@ import java.util.List;
|
||||||
* @version 1.0 Aug 20, 2005
|
* @version 1.0 Aug 20, 2005
|
||||||
*/
|
*/
|
||||||
public interface ElementNamespaceAttribute extends ElementConfigurator {
|
public interface ElementNamespaceAttribute extends ElementConfigurator {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the attribute name this attribute handler handles.
|
* Gets the attribute name this attribute handler handles.
|
||||||
* @return Returns the attributes name of this attribute handler.
|
*
|
||||||
|
* @return Returns the attributes name of this attribute handler.
|
||||||
*/
|
*/
|
||||||
String getAttributeName();
|
String getAttributeName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the attribute name this attribute handler handles.
|
* Sets the attribute name this attribute handler handles.
|
||||||
* @param attributeName The attribute to handle.
|
*
|
||||||
|
* @param attributeName The attribute to handle.
|
||||||
*/
|
*/
|
||||||
void setAttributeName(String attributeName);
|
void setAttributeName(String attributeName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an NextAttribute.
|
* Adds an NextAttribute. There next attributes will defines the order in which the ElementNamespaceAttribute are executed.
|
||||||
* There next attributes will defines the order in which the ElementNamespaceAttribute are executed.
|
*
|
||||||
* @param attribute Add attribute which be will processed after this one.
|
* @param attribute Add attribute which be will processed after this one.
|
||||||
*/
|
*/
|
||||||
void addNextAttribute(String attribute);
|
void addNextAttribute(String attribute);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes an next attribute.
|
* Removes an next attribute.
|
||||||
* @param attribute Removes this next attribute.
|
*
|
||||||
|
* @param attribute Removes this next attribute.
|
||||||
*/
|
*/
|
||||||
void removeNextAttribute(String attribute);
|
void removeNextAttribute(String attribute);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all next attributes.
|
* Get all next attributes.
|
||||||
* @return Returns the list of all next attributes.
|
*
|
||||||
|
* @return Returns the list of all next attributes.
|
||||||
*/
|
*/
|
||||||
List<String> getNextAttributes();
|
List<String> getNextAttributes();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,21 +32,23 @@ import org.x4o.xml.lang.X4OLanguage;
|
||||||
* @version 1.0 Jul 8, 2006
|
* @version 1.0 Jul 8, 2006
|
||||||
*/
|
*/
|
||||||
public interface ElementNamespaceInstanceProvider {
|
public interface ElementNamespaceInstanceProvider {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the ElementProvider.
|
* Starts the ElementProvider.
|
||||||
* @param language The X4OLanguage to start in.
|
*
|
||||||
|
* @param language The X4OLanguage to start in.
|
||||||
* @param elementNamespace The elementNamespace to start for.
|
* @param elementNamespace The elementNamespace to start for.
|
||||||
* @throws ElementNamespaceInstanceProviderException Thrown when error happened in language.
|
* @throws ElementNamespaceInstanceProviderException Thrown when error happened in language.
|
||||||
*/
|
*/
|
||||||
void start(X4OLanguage language,ElementNamespace elementNamespace) throws ElementNamespaceInstanceProviderException;
|
void start(X4OLanguage language, ElementNamespace elementNamespace) throws ElementNamespaceInstanceProviderException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide an Element for an xml tag.
|
* Provide an Element for an xml tag.
|
||||||
|
*
|
||||||
* @param languageSession The languageSession to create element for.
|
* @param languageSession The languageSession to create element for.
|
||||||
* @param tag The xml tag to create instance for.
|
* @param tag The xml tag to create instance for.
|
||||||
* @return An new Element instance.
|
* @return An new Element instance.
|
||||||
* @throws ElementNamespaceInstanceProviderException Thrown when error happened in language.
|
* @throws ElementNamespaceInstanceProviderException Thrown when error happened in language.
|
||||||
*/
|
*/
|
||||||
Element createElementInstance(X4OLanguageSession languageSession,String tag) throws ElementNamespaceInstanceProviderException;
|
Element createElementInstance(X4OLanguageSession languageSession, String tag) throws ElementNamespaceInstanceProviderException;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ElementNamespaceInstanceProviderException holds the ElementNamespaceInstanceProvider which created this Exception.<br>
|
* ElementNamespaceInstanceProviderException holds the ElementNamespaceInstanceProvider which created this Exception.<br>
|
||||||
|
|
@ -31,33 +30,36 @@ package org.x4o.xml.element;
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class ElementNamespaceInstanceProviderException extends ElementException {
|
public class ElementNamespaceInstanceProviderException extends ElementException {
|
||||||
|
|
||||||
private ElementNamespaceInstanceProvider elementNamespaceInstanceProvider = null;
|
private ElementNamespaceInstanceProvider elementNamespaceInstanceProvider = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates provider instance exception.
|
* Creates provider instance exception.
|
||||||
* @param elementNamespaceInstanceProvider The provider which creates this exception.
|
*
|
||||||
* @param message The message of this exception.
|
* @param elementNamespaceInstanceProvider The provider which creates this exception.
|
||||||
|
* @param message The message of this exception.
|
||||||
*/
|
*/
|
||||||
public ElementNamespaceInstanceProviderException(ElementNamespaceInstanceProvider elementNamespaceInstanceProvider,String message) {
|
public ElementNamespaceInstanceProviderException(ElementNamespaceInstanceProvider elementNamespaceInstanceProvider, String message) {
|
||||||
super(message);
|
super(message);
|
||||||
this.elementNamespaceInstanceProvider=elementNamespaceInstanceProvider;
|
this.elementNamespaceInstanceProvider = elementNamespaceInstanceProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates provider instance exception.
|
* Creates provider instance exception.
|
||||||
* @param elementNamespaceInstanceProvider The provider which creates this exception.
|
*
|
||||||
* @param message The message of this exception.
|
* @param elementNamespaceInstanceProvider The provider which creates this exception.
|
||||||
* @param exception The root cause of this exception.
|
* @param message The message of this exception.
|
||||||
|
* @param exception The root cause of this exception.
|
||||||
*/
|
*/
|
||||||
public ElementNamespaceInstanceProviderException(ElementNamespaceInstanceProvider elementNamespaceInstanceProvider,String message,Exception exception) {
|
public ElementNamespaceInstanceProviderException(ElementNamespaceInstanceProvider elementNamespaceInstanceProvider, String message, Exception exception) {
|
||||||
super(message,exception);
|
super(message, exception);
|
||||||
this.elementNamespaceInstanceProvider=elementNamespaceInstanceProvider;
|
this.elementNamespaceInstanceProvider = elementNamespaceInstanceProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the ElementNamespaceInstanceProvider which created this exception.
|
* Gets the ElementNamespaceInstanceProvider which created this exception.
|
||||||
* @return The provider which created the exception.
|
*
|
||||||
|
* @return The provider which created the exception.
|
||||||
*/
|
*/
|
||||||
public ElementNamespaceInstanceProvider getElementNamespaceInstanceProvider() {
|
public ElementNamespaceInstanceProvider getElementNamespaceInstanceProvider() {
|
||||||
return elementNamespaceInstanceProvider;
|
return elementNamespaceInstanceProvider;
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
@ -34,27 +34,30 @@ public interface ElementObjectPropertyValue {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets an bean property of the object.
|
* Sets an bean property of the object.
|
||||||
|
*
|
||||||
* @param object
|
* @param object
|
||||||
* @param propertyName
|
* @param propertyName
|
||||||
* @param value
|
* @param value
|
||||||
* @throws ElementObjectPropertyValueException
|
* @throws ElementObjectPropertyValueException
|
||||||
*/
|
*/
|
||||||
void setProperty(Object object,String propertyName,Object value) throws ElementObjectPropertyValueException;
|
void setProperty(Object object, String propertyName, Object value) throws ElementObjectPropertyValueException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the value of a properterie of a bean,
|
* Get the value of a properterie of a bean,
|
||||||
* @param object The object to get the properties from
|
*
|
||||||
* @param propertyName The name of the property to get.
|
* @param object The object to get the properties from
|
||||||
* @return Returns the value of the property.
|
* @param propertyName The name of the property to get.
|
||||||
|
* @return Returns the value of the property.
|
||||||
* @throws ElementObjectPropertyValueException
|
* @throws ElementObjectPropertyValueException
|
||||||
*/
|
*/
|
||||||
Object getProperty(Object object,String propertyName) throws ElementObjectPropertyValueException;
|
Object getProperty(Object object, String propertyName) throws ElementObjectPropertyValueException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets all bean properties.
|
* Sets all bean properties.
|
||||||
* @param object To object to set all the properties to.
|
*
|
||||||
* @param propertyMap A Map with the keys as properties names and the valua as value to set.
|
* @param object To object to set all the properties to.
|
||||||
|
* @param propertyMap A Map with the keys as properties names and the valua as value to set.
|
||||||
* @throws ElementObjectPropertyValueException
|
* @throws ElementObjectPropertyValueException
|
||||||
*/
|
*/
|
||||||
void setPropertyMap(Object object,Map<String,Object> propertyMap) throws ElementObjectPropertyValueException;
|
void setPropertyMap(Object object, Map<String, Object> propertyMap) throws ElementObjectPropertyValueException;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.element;
|
package org.x4o.xml.element;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ElementObjectPropertyValueException.<br>
|
* ElementObjectPropertyValueException.<br>
|
||||||
|
|
@ -36,18 +35,20 @@ public class ElementObjectPropertyValueException extends ElementException {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates ElementObjectPropertyValueException with message.
|
* Creates ElementObjectPropertyValueException with message.
|
||||||
* @param message The error message.
|
*
|
||||||
|
* @param message The error message.
|
||||||
*/
|
*/
|
||||||
public ElementObjectPropertyValueException(String message) {
|
public ElementObjectPropertyValueException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates ElementObjectPropertyValueException with message and exception.
|
* Creates ElementObjectPropertyValueException with message and exception.
|
||||||
* @param message The error message.
|
*
|
||||||
* @param exception The error exception.
|
* @param message The error message.
|
||||||
|
* @param exception The error exception.
|
||||||
*/
|
*/
|
||||||
public ElementObjectPropertyValueException(String message,Exception exception) {
|
public ElementObjectPropertyValueException(String message, Exception exception) {
|
||||||
super(message,exception);
|
super(message, exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,11 +37,11 @@ import org.x4o.xml.lang.X4OLanguageSession;
|
||||||
* @version 1.0 Apr 6, 2013
|
* @version 1.0 Apr 6, 2013
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractX4OConnection extends AbstractX4OConnectionDebug {
|
public abstract class AbstractX4OConnection extends AbstractX4OConnectionDebug {
|
||||||
|
|
||||||
private final X4OLanguage language;
|
private final X4OLanguage language;
|
||||||
protected String phaseStop = null;
|
protected String phaseStop = null;
|
||||||
protected List<String> phaseSkip = null;
|
protected List<String> phaseSkip = null;
|
||||||
|
|
||||||
public AbstractX4OConnection(X4OLanguage language) {
|
public AbstractX4OConnection(X4OLanguage language) {
|
||||||
if (language == null) {
|
if (language == null) {
|
||||||
throw new NullPointerException("Can't create X4O connection for null language.");
|
throw new NullPointerException("Can't create X4O connection for null language.");
|
||||||
|
|
@ -49,44 +49,45 @@ public abstract class AbstractX4OConnection extends AbstractX4OConnectionDebug {
|
||||||
this.language = language;
|
this.language = language;
|
||||||
this.phaseSkip = new ArrayList<String>(2);
|
this.phaseSkip = new ArrayList<String>(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final X4OLanguage getLanguage() {
|
public final X4OLanguage getLanguage() {
|
||||||
return language;
|
return language;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final X4OLanguageSession createLanguageSession() {
|
public final X4OLanguageSession createLanguageSession() {
|
||||||
return language.createLanguageSession();
|
return language.createLanguageSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract SAX3PropertyConfig getPropertyConfig();
|
abstract SAX3PropertyConfig getPropertyConfig();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets an X4O Language property.
|
* Sets an X4O Language property.
|
||||||
* @param key The key of the property to set.
|
*
|
||||||
* @param value The vlue of the property to set.
|
* @param key The key of the property to set.
|
||||||
|
* @param value The vlue of the property to set.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final void setProperty(String key,Object value) {
|
public final void setProperty(String key, Object value) {
|
||||||
getPropertyConfig().setProperty(key, value);
|
getPropertyConfig().setProperty(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final Object getProperty(String key) {
|
public final Object getProperty(String key) {
|
||||||
return getPropertyConfig().getProperty(key);
|
return getPropertyConfig().getProperty(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final Collection<String> getPropertyKeys() {
|
public final Collection<String> getPropertyKeys() {
|
||||||
return getPropertyConfig().getPropertyKeys();
|
return getPropertyConfig().getPropertyKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void setPhaseStop(String phaseId) {
|
public final void setPhaseStop(String phaseId) {
|
||||||
phaseStop = phaseId;
|
phaseStop = phaseId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void addPhaseSkip(String phaseId) {
|
public final void addPhaseSkip(String phaseId) {
|
||||||
phaseSkip.add(phaseId);
|
phaseSkip.add(phaseId);
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,8 @@ public abstract class AbstractX4OConnectionDebug implements X4OConnection {
|
||||||
protected final static String ABSTRACT_DEBUG_OUTPUT_HANDLER = "debug/output-handler";
|
protected final static String ABSTRACT_DEBUG_OUTPUT_HANDLER = "debug/output-handler";
|
||||||
protected final static String ABSTRACT_DEBUG_OUTPUT_STREAM = "debug/output-stream";
|
protected final static String ABSTRACT_DEBUG_OUTPUT_STREAM = "debug/output-stream";
|
||||||
|
|
||||||
protected void debugStart(X4OLanguageSession languageSession, String debugHandlerKey, String debugStreamKey) throws UnsupportedEncodingException, SAXException {
|
protected void debugStart(X4OLanguageSession languageSession, String debugHandlerKey, String debugStreamKey)
|
||||||
|
throws UnsupportedEncodingException, SAXException {
|
||||||
Object debugOutputHandler = getProperty(debugHandlerKey);
|
Object debugOutputHandler = getProperty(debugHandlerKey);
|
||||||
Object debugOutputStream = getProperty(debugStreamKey);
|
Object debugOutputStream = getProperty(debugStreamKey);
|
||||||
// init debug infra
|
// init debug infra
|
||||||
|
|
|
||||||
|
|
@ -120,8 +120,7 @@ abstract public class AbstractX4OReader<T> extends AbstractX4OReaderSession<T> i
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetched the data direct from remote url to a InputStream to is can me readd
|
* Fetched the data direct from remote url to a InputStream to is can me readd by SAX.
|
||||||
* by SAX.
|
|
||||||
*
|
*
|
||||||
* @param url The url to read.
|
* @param url The url to read.
|
||||||
* @throws X4OConnectionException Is thrown after x4o exception.
|
* @throws X4OConnectionException Is thrown after x4o exception.
|
||||||
|
|
|
||||||
|
|
@ -34,16 +34,16 @@ public class DefaultX4ODriver<T> extends X4ODriver<T> {
|
||||||
|
|
||||||
private final String languageName;
|
private final String languageName;
|
||||||
private final String languageVersion;
|
private final String languageVersion;
|
||||||
|
|
||||||
public DefaultX4ODriver(String languageName) {
|
public DefaultX4ODriver(String languageName) {
|
||||||
this(languageName,X4ODriver.DEFAULT_LANGUAGE_VERSION);
|
this(languageName, X4ODriver.DEFAULT_LANGUAGE_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DefaultX4ODriver(String languageName,String languageVersion) {
|
public DefaultX4ODriver(String languageName, String languageVersion) {
|
||||||
this.languageName=languageName;
|
this.languageName = languageName;
|
||||||
this.languageVersion=languageVersion;
|
this.languageVersion = languageVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getLanguageName() {
|
public String getLanguageName() {
|
||||||
return languageName;
|
return languageName;
|
||||||
|
|
@ -51,6 +51,6 @@ public class DefaultX4ODriver<T> extends X4ODriver<T> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getLanguageVersions() {
|
public String[] getLanguageVersions() {
|
||||||
return new String[]{languageVersion};
|
return new String[] { languageVersion };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,10 +55,11 @@ import org.xml.sax.SAXException;
|
||||||
* @param <T> The root element object type.
|
* @param <T> The root element object type.
|
||||||
*/
|
*/
|
||||||
public class DefaultX4OReader<T> extends AbstractX4OReader<T> {
|
public class DefaultX4OReader<T> extends AbstractX4OReader<T> {
|
||||||
|
|
||||||
private final SAX3PropertyConfig propertyConfig;
|
private final SAX3PropertyConfig propertyConfig;
|
||||||
private final Map<String, Object> elBeans = new HashMap<>();
|
private final Map<String, Object> elBeans = new HashMap<>();
|
||||||
|
|
||||||
|
//@formatter:off
|
||||||
private final static String PROPERTY_CONTEXT_PREFIX = SAX3PropertyConfig.X4O_PROPERTIES_PREFIX+"reader/x4o/";
|
private final static String PROPERTY_CONTEXT_PREFIX = SAX3PropertyConfig.X4O_PROPERTIES_PREFIX+"reader/x4o/";
|
||||||
public final static SAX3PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
public final static SAX3PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
||||||
public final static String SAX_ERROR_HANDLER = PROPERTY_CONTEXT_PREFIX + "sax/error-handler";
|
public final static String SAX_ERROR_HANDLER = PROPERTY_CONTEXT_PREFIX + "sax/error-handler";
|
||||||
|
|
@ -96,12 +97,13 @@ public class DefaultX4OReader<T> extends AbstractX4OReader<T> {
|
||||||
new PropertyConfigItem(DEBUG_OUTPUT_STREAM,OutputStream.class)
|
new PropertyConfigItem(DEBUG_OUTPUT_STREAM,OutputStream.class)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
//@formatter:on
|
||||||
|
|
||||||
public DefaultX4OReader(X4OLanguage language) {
|
public DefaultX4OReader(X4OLanguage language) {
|
||||||
super(language);
|
super(language);
|
||||||
propertyConfig = new SAX3PropertyConfig(DEFAULT_PROPERTY_CONFIG, PROPERTY_CONTEXT_PREFIX);
|
propertyConfig = new SAX3PropertyConfig(DEFAULT_PROPERTY_CONFIG, PROPERTY_CONTEXT_PREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.io.AbstractX4OConnection#getPropertyConfig()
|
* @see org.x4o.xml.io.AbstractX4OConnection#getPropertyConfig()
|
||||||
*/
|
*/
|
||||||
|
|
@ -109,20 +111,22 @@ public class DefaultX4OReader<T> extends AbstractX4OReader<T> {
|
||||||
public SAX3PropertyConfig getPropertyConfig() {
|
public SAX3PropertyConfig getPropertyConfig() {
|
||||||
return propertyConfig;
|
return propertyConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readSession(X4OLanguageSession languageSession, InputStream input, String systemId, URL basePath) throws X4OConnectionException, SAXException, IOException {
|
public void readSession(X4OLanguageSession languageSession, InputStream input, String systemId, URL basePath)
|
||||||
|
throws X4OConnectionException, SAXException, IOException {
|
||||||
setProperty(INPUT_STREAM, input);
|
setProperty(INPUT_STREAM, input);
|
||||||
setProperty(INPUT_SYSTEM_ID, systemId);
|
setProperty(INPUT_SYSTEM_ID, systemId);
|
||||||
setProperty(INPUT_BASE_PATH, basePath);
|
setProperty(INPUT_BASE_PATH, basePath);
|
||||||
for (String name : elBeans.keySet()) {
|
for (String name : elBeans.keySet()) {
|
||||||
Object bean = elBeans.get(name);
|
Object bean = elBeans.get(name);
|
||||||
ValueExpression ve = languageSession.getExpressionLanguageFactory().createValueExpression(languageSession.getExpressionLanguageContext(),"${"+name+"}", bean.getClass());
|
ValueExpression ve = languageSession.getExpressionLanguageFactory().createValueExpression(languageSession.getExpressionLanguageContext(),
|
||||||
|
"${" + name + "}", bean.getClass());
|
||||||
ve.setValue(languageSession.getExpressionLanguageContext(), bean);
|
ve.setValue(languageSession.getExpressionLanguageContext(), bean);
|
||||||
}
|
}
|
||||||
readSession(languageSession);
|
readSession(languageSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addELBeanInstance(String name, Object bean) {
|
public void addELBeanInstance(String name, Object bean) {
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
throw new NullPointerException("Can't add null name.");
|
throw new NullPointerException("Can't add null name.");
|
||||||
|
|
@ -135,19 +139,19 @@ public class DefaultX4OReader<T> extends AbstractX4OReader<T> {
|
||||||
}
|
}
|
||||||
elBeans.put(name, bean);
|
elBeans.put(name, bean);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses the input stream as a X4O document.
|
* Parses the input stream as a X4O document.
|
||||||
*/
|
*/
|
||||||
protected void readSession(X4OLanguageSession languageSession) throws X4OConnectionException, SAXException, IOException {
|
protected void readSession(X4OLanguageSession languageSession) throws X4OConnectionException, SAXException, IOException {
|
||||||
// Extra check if we have a language
|
// Extra check if we have a language
|
||||||
if (languageSession.getLanguage() == null) {
|
if (languageSession.getLanguage() == null) {
|
||||||
throw new X4OConnectionException("languageSession is broken getLanguage() returns null.");
|
throw new X4OConnectionException("languageSession is broken getLanguage() returns null.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert stop/skip phase if we allowed to. TODO: move layer ?
|
// Insert stop/skip phase if we allowed to. TODO: move layer ?
|
||||||
if (languageSession instanceof X4OLanguageSessionLocal) {
|
if (languageSession instanceof X4OLanguageSessionLocal) {
|
||||||
X4OLanguageSessionLocal ll = (X4OLanguageSessionLocal)languageSession;
|
X4OLanguageSessionLocal ll = (X4OLanguageSessionLocal) languageSession;
|
||||||
if (phaseStop != null) {
|
if (phaseStop != null) {
|
||||||
ll.setPhaseStop(phaseStop);
|
ll.setPhaseStop(phaseStop);
|
||||||
}
|
}
|
||||||
|
|
@ -155,39 +159,39 @@ public class DefaultX4OReader<T> extends AbstractX4OReader<T> {
|
||||||
ll.addPhaseSkip(phaseId);
|
ll.addPhaseSkip(phaseId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// init debug
|
// init debug
|
||||||
debugStart(languageSession, DEBUG_OUTPUT_HANDLER, DEBUG_OUTPUT_STREAM);
|
debugStart(languageSession, DEBUG_OUTPUT_HANDLER, DEBUG_OUTPUT_STREAM);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Run init (auto once)
|
// Run init (auto once)
|
||||||
X4OLanguageLocal.class.cast(languageSession.getLanguage()).init(languageSession);
|
X4OLanguageLocal.class.cast(languageSession.getLanguage()).init(languageSession);
|
||||||
|
|
||||||
// Run document parsing
|
// Run document parsing
|
||||||
X4OContentParser parser = new X4OContentParser(propertyConfig);
|
X4OContentParser parser = new X4OContentParser(propertyConfig);
|
||||||
parser.parse(languageSession);
|
parser.parse(languageSession);
|
||||||
|
|
||||||
// Run phases to build object tree
|
// Run phases to build object tree
|
||||||
getLanguage().getPhaseManager().runPhases(languageSession, X4OPhaseType.XML_READ);
|
getLanguage().getPhaseManager().runPhases(languageSession, X4OPhaseType.XML_READ);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// also debug exceptions
|
// also debug exceptions
|
||||||
debugException(languageSession, e);
|
debugException(languageSession, e);
|
||||||
|
|
||||||
// unwrap exception
|
// unwrap exception
|
||||||
// TODO: cleanup exceptions a bit more see X4OConnectionException
|
// TODO: cleanup exceptions a bit more see X4OConnectionException
|
||||||
if (e.getCause() instanceof ParserConfigurationException) {
|
if (e.getCause() instanceof ParserConfigurationException) {
|
||||||
throw new X4OConnectionException((ParserConfigurationException)e.getCause());
|
throw new X4OConnectionException((ParserConfigurationException) e.getCause());
|
||||||
}
|
}
|
||||||
if (e.getCause() instanceof SAXException) {
|
if (e.getCause() instanceof SAXException) {
|
||||||
throw (SAXException)e.getCause();
|
throw (SAXException) e.getCause();
|
||||||
}
|
}
|
||||||
if (e.getCause() instanceof IOException) {
|
if (e.getCause() instanceof IOException) {
|
||||||
throw (IOException)e.getCause();
|
throw (IOException) e.getCause();
|
||||||
}
|
}
|
||||||
if (e.getCause()==null) {
|
if (e.getCause() == null) {
|
||||||
throw new SAXException(e);
|
throw new SAXException(e);
|
||||||
} else {
|
} else {
|
||||||
throw new SAXException((Exception)e.getCause());
|
throw new SAXException((Exception) e.getCause());
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
debugStop(languageSession);
|
debugStop(languageSession);
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,7 @@ public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
|
||||||
private boolean schemaUriPrint;
|
private boolean schemaUriPrint;
|
||||||
private String schemaUriRoot;
|
private String schemaUriRoot;
|
||||||
|
|
||||||
|
//@formatter:off
|
||||||
private final static AttributeEntryComparator ATTR_ENTRY_COMPARATOR = new AttributeEntryComparator();
|
private final static AttributeEntryComparator ATTR_ENTRY_COMPARATOR = new AttributeEntryComparator();
|
||||||
private final static String PROPERTY_CONTEXT_PREFIX = SAX3PropertyConfig.X4O_PROPERTIES_PREFIX+"writer/x4o/";
|
private final static String PROPERTY_CONTEXT_PREFIX = SAX3PropertyConfig.X4O_PROPERTIES_PREFIX+"writer/x4o/";
|
||||||
public final static SAX3PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
public final static SAX3PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
||||||
|
|
@ -88,6 +89,7 @@ public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
|
||||||
new PropertyConfigItem(DEBUG_OUTPUT_STREAM,OutputStream.class)
|
new PropertyConfigItem(DEBUG_OUTPUT_STREAM,OutputStream.class)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
//@formatter:on
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor.
|
* Default constructor.
|
||||||
|
|
|
||||||
|
|
@ -34,23 +34,24 @@ import org.x4o.xml.lang.X4OLanguageSession;
|
||||||
* @version 1.0 Apr 6, 2013
|
* @version 1.0 Apr 6, 2013
|
||||||
*/
|
*/
|
||||||
public interface X4OConnection {
|
public interface X4OConnection {
|
||||||
|
|
||||||
X4OLanguage getLanguage();
|
X4OLanguage getLanguage();
|
||||||
|
|
||||||
X4OLanguageSession createLanguageSession();
|
X4OLanguageSession createLanguageSession();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets an X4O Language property.
|
* Sets an X4O Language property.
|
||||||
* @param key The key of the property to set.
|
*
|
||||||
* @param value The value of the property to set.
|
* @param key The key of the property to set.
|
||||||
|
* @param value The value of the property to set.
|
||||||
*/
|
*/
|
||||||
void setProperty(String key, Object value);
|
void setProperty(String key, Object value);
|
||||||
|
|
||||||
Object getProperty(String key);
|
Object getProperty(String key);
|
||||||
|
|
||||||
Collection<String> getPropertyKeys();
|
Collection<String> getPropertyKeys();
|
||||||
|
|
||||||
void setPhaseStop(String phaseId);
|
void setPhaseStop(String phaseId);
|
||||||
|
|
||||||
void addPhaseSkip(String phaseId);
|
void addPhaseSkip(String phaseId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.io;
|
package org.x4o.xml.io;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* X4OConnectionException is top level exception for io connections.
|
* X4OConnectionException is top level exception for io connections.
|
||||||
|
|
@ -29,7 +29,7 @@ package org.x4o.xml.io;
|
||||||
* @version 1.0 28 Apr, 2013
|
* @version 1.0 28 Apr, 2013
|
||||||
*/
|
*/
|
||||||
public class X4OConnectionException extends Exception {
|
public class X4OConnectionException extends Exception {
|
||||||
|
|
||||||
/** The serial version uid */
|
/** The serial version uid */
|
||||||
static final long serialVersionUID = 10L;
|
static final long serialVersionUID = 10L;
|
||||||
|
|
||||||
|
|
@ -42,26 +42,29 @@ public class X4OConnectionException extends Exception {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an X4OConnectionException with a detail message.
|
* Constructs an X4OConnectionException with a detail message.
|
||||||
* @param message The message of this Exception
|
*
|
||||||
|
* @param message The message of this Exception
|
||||||
*/
|
*/
|
||||||
public X4OConnectionException(String message) {
|
public X4OConnectionException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an X4OConnectionException from a parent exception.
|
* Creates an X4OConnectionException from a parent exception.
|
||||||
* @param e The error exception.
|
*
|
||||||
|
* @param e The error exception.
|
||||||
*/
|
*/
|
||||||
public X4OConnectionException(Exception e) {
|
public X4OConnectionException(Exception e) {
|
||||||
super(e);
|
super(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an X4OConnectionException with a detail message.
|
* Constructs an X4OConnectionException with a detail message.
|
||||||
* @param message The message of this Exception
|
*
|
||||||
* @param e The error exception.
|
* @param message The message of this Exception
|
||||||
|
* @param e The error exception.
|
||||||
*/
|
*/
|
||||||
public X4OConnectionException(String message,Exception e) {
|
public X4OConnectionException(String message, Exception e) {
|
||||||
super(message,e);
|
super(message, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,33 +48,32 @@ import java.util.logging.Logger;
|
||||||
* @version 1.0 Aug 20, 2005
|
* @version 1.0 Aug 20, 2005
|
||||||
*/
|
*/
|
||||||
public class X4OContentHandler extends DefaultHandler2 {
|
public class X4OContentHandler extends DefaultHandler2 {
|
||||||
|
|
||||||
/** The logger to log to */
|
/** The logger to log to */
|
||||||
private Logger logger = null;
|
private Logger logger = null;
|
||||||
private boolean loggerFinest = false;
|
private boolean loggerFinest = false;
|
||||||
|
|
||||||
/** The Locator for parse errors */
|
/** The Locator for parse errors */
|
||||||
private Locator locator = null;
|
private Locator locator = null;
|
||||||
|
|
||||||
/** The element Stack */
|
/** The element Stack */
|
||||||
private Stack<Element> elementStack = null;
|
private Stack<Element> elementStack = null;
|
||||||
|
|
||||||
/** The elememtContext */
|
/** The elememtContext */
|
||||||
private X4OLanguageSession elementLanguage = null;
|
private X4OLanguageSession elementLanguage = null;
|
||||||
|
|
||||||
/** Store the override element */
|
/** Store the override element */
|
||||||
private Element overrideSaxElement = null;
|
private Element overrideSaxElement = null;
|
||||||
|
|
||||||
/** Store the override element handler */
|
/** Store the override element handler */
|
||||||
private DefaultHandler2 overrideSaxHandler = null;
|
private DefaultHandler2 overrideSaxHandler = null;
|
||||||
|
|
||||||
private final SAX3PropertyConfig propertyConfig;
|
private final SAX3PropertyConfig propertyConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an X4OTagHandler
|
* Creates an X4OTagHandler which can receice sax xml events and converts them into the Element* interfaces events.
|
||||||
* which can receice sax xml events and converts them into the Element* interfaces events.
|
|
||||||
*/
|
*/
|
||||||
public X4OContentHandler(X4OLanguageSession elementLanguage,SAX3PropertyConfig propertyConfig) {
|
public X4OContentHandler(X4OLanguageSession elementLanguage, SAX3PropertyConfig propertyConfig) {
|
||||||
logger = Logger.getLogger(X4OContentHandler.class.getName());
|
logger = Logger.getLogger(X4OContentHandler.class.getName());
|
||||||
loggerFinest = logger.isLoggable(Level.FINEST);
|
loggerFinest = logger.isLoggable(Level.FINEST);
|
||||||
elementStack = new Stack<Element>();
|
elementStack = new Stack<Element>();
|
||||||
|
|
@ -87,15 +86,15 @@ public class X4OContentHandler extends DefaultHandler2 {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setDocumentLocator(Locator locator) {
|
public void setDocumentLocator(Locator locator) {
|
||||||
this.locator=locator;
|
this.locator = locator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.xml.sax.helpers.DefaultHandler#startPrefixMapping(java.lang.String, java.lang.String)
|
* @see org.xml.sax.helpers.DefaultHandler#startPrefixMapping(java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void startPrefixMapping(String prefix, String namespaceUri) throws SAXException {
|
public void startPrefixMapping(String prefix, String namespaceUri) throws SAXException {
|
||||||
if (overrideSaxHandler!=null) {
|
if (overrideSaxHandler != null) {
|
||||||
overrideSaxHandler.startPrefixMapping(prefix, namespaceUri);
|
overrideSaxHandler.startPrefixMapping(prefix, namespaceUri);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -106,8 +105,8 @@ public class X4OContentHandler extends DefaultHandler2 {
|
||||||
return; // skip xinclude ns.
|
return; // skip xinclude ns.
|
||||||
}
|
}
|
||||||
ElementNamespace enc = elementLanguage.getLanguage().findElementNamespace(namespaceUri);
|
ElementNamespace enc = elementLanguage.getLanguage().findElementNamespace(namespaceUri);
|
||||||
if (enc==null) {
|
if (enc == null) {
|
||||||
throw new SAXException("Can't find namespace uri: "+namespaceUri+" in language: "+elementLanguage.getLanguage().getLanguageName());
|
throw new SAXException("Can't find namespace uri: " + namespaceUri + " in language: " + elementLanguage.getLanguage().getLanguageName());
|
||||||
}
|
}
|
||||||
enc.setPrefixMapping(prefix);
|
enc.setPrefixMapping(prefix);
|
||||||
}
|
}
|
||||||
|
|
@ -116,41 +115,41 @@ public class X4OContentHandler extends DefaultHandler2 {
|
||||||
* @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
|
* @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void startElement(String namespaceUri, String tag, String qName,Attributes attributes) throws SAXException {
|
public void startElement(String namespaceUri, String tag, String qName, Attributes attributes) throws SAXException {
|
||||||
if (loggerFinest) {
|
if (loggerFinest) {
|
||||||
logger.finest("XMLTAG-START: "+namespaceUri+":"+tag);
|
logger.finest("XMLTAG-START: " + namespaceUri + ":" + tag);
|
||||||
}
|
}
|
||||||
if (overrideSaxHandler!=null) {
|
if (overrideSaxHandler != null) {
|
||||||
overrideSaxHandler.startElement(namespaceUri, tag, qName, attributes);
|
overrideSaxHandler.startElement(namespaceUri, tag, qName, attributes);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ElementNamespace enc = elementLanguage.getLanguage().findElementNamespace(namespaceUri);
|
ElementNamespace enc = elementLanguage.getLanguage().findElementNamespace(namespaceUri);
|
||||||
if (enc==null) {
|
if (enc == null) {
|
||||||
if ("".equals(namespaceUri)) {
|
if ("".equals(namespaceUri)) {
|
||||||
String configEmptryUri = propertyConfig.getPropertyString(DefaultX4OReader.DOC_EMPTY_NAMESPACE_URI);
|
String configEmptryUri = propertyConfig.getPropertyString(DefaultX4OReader.DOC_EMPTY_NAMESPACE_URI);
|
||||||
if (configEmptryUri!=null) {
|
if (configEmptryUri != null) {
|
||||||
namespaceUri = configEmptryUri;
|
namespaceUri = configEmptryUri;
|
||||||
enc = elementLanguage.getLanguage().findElementNamespace(namespaceUri);
|
enc = elementLanguage.getLanguage().findElementNamespace(namespaceUri);
|
||||||
}
|
}
|
||||||
if (enc==null) {
|
if (enc == null) {
|
||||||
throw new SAXParseException("No ElementNamespace found for empty namespace.",locator);
|
throw new SAXParseException("No ElementNamespace found for empty namespace.", locator);
|
||||||
}
|
}
|
||||||
enc.setPrefixMapping("");
|
enc.setPrefixMapping("");
|
||||||
}
|
}
|
||||||
if (enc==null) {
|
if (enc == null) {
|
||||||
throw new SAXParseException("No ElementProvider found for namespace: "+namespaceUri,locator);
|
throw new SAXParseException("No ElementProvider found for namespace: " + namespaceUri, locator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ElementNamespaceInstanceProvider eip = enc.getElementNamespaceInstanceProvider();
|
ElementNamespaceInstanceProvider eip = enc.getElementNamespaceInstanceProvider();
|
||||||
Element element = null;
|
Element element = null;
|
||||||
try {
|
try {
|
||||||
element = eip.createElementInstance(elementLanguage,tag);
|
element = eip.createElementInstance(elementLanguage, tag);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new SAXParseException("Error while creating element: "+e.getMessage(),locator,e);
|
throw new SAXParseException("Error while creating element: " + e.getMessage(), locator, e);
|
||||||
}
|
}
|
||||||
enc.addElementClass(element.getElementClass());
|
enc.addElementClass(element.getElementClass());
|
||||||
|
|
||||||
// next bind them togeter.
|
// next bind them togeter.
|
||||||
if (elementStack.empty()) {
|
if (elementStack.empty()) {
|
||||||
elementLanguage.setRootElement(element); // root element !!
|
elementLanguage.setRootElement(element); // root element !!
|
||||||
|
|
@ -159,32 +158,32 @@ public class X4OContentHandler extends DefaultHandler2 {
|
||||||
element.setParent(parent); // set parent element
|
element.setParent(parent); // set parent element
|
||||||
parent.addChild(element);
|
parent.addChild(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
// create attribute map
|
// create attribute map
|
||||||
Map<String,String> map = new AttributeMap<String,String>(attributes);
|
Map<String, String> map = new AttributeMap<String, String>(attributes);
|
||||||
element.getAttributes().putAll(map);
|
element.getAttributes().putAll(map);
|
||||||
|
|
||||||
elementStack.push(element);
|
elementStack.push(element);
|
||||||
try {
|
try {
|
||||||
element.doElementStart();
|
element.doElementStart();
|
||||||
} catch (ElementException ee) {
|
} catch (ElementException ee) {
|
||||||
throw new SAXParseException("Error while configing element: "+ee.getMessage(),locator,ee);
|
throw new SAXParseException("Error while configing element: " + ee.getMessage(), locator, ee);
|
||||||
}
|
}
|
||||||
if (ElementType.overrideSax.equals(element.getElementType())) {
|
if (ElementType.overrideSax.equals(element.getElementType())) {
|
||||||
overrideSaxElement = element;
|
overrideSaxElement = element;
|
||||||
overrideSaxHandler = (DefaultHandler2)element.getElementObject();
|
overrideSaxHandler = (DefaultHandler2) element.getElementObject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
|
* @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void endElement(String namespaceUri, String tag,String qName) throws SAXException {
|
public void endElement(String namespaceUri, String tag, String qName) throws SAXException {
|
||||||
if (loggerFinest) {
|
if (loggerFinest) {
|
||||||
logger.finest("XMLTAG-END: "+namespaceUri+":"+tag);
|
logger.finest("XMLTAG-END: " + namespaceUri + ":" + tag);
|
||||||
}
|
}
|
||||||
if (overrideSaxHandler!=null) {
|
if (overrideSaxHandler != null) {
|
||||||
if (overrideSaxElement.getElementClass().getId().equals(tag)) {
|
if (overrideSaxElement.getElementClass().getId().equals(tag)) {
|
||||||
overrideSaxHandler.endDocument();
|
overrideSaxHandler.endDocument();
|
||||||
overrideSaxHandler = null;
|
overrideSaxHandler = null;
|
||||||
|
|
@ -201,38 +200,37 @@ public class X4OContentHandler extends DefaultHandler2 {
|
||||||
try {
|
try {
|
||||||
element.doElementEnd();
|
element.doElementEnd();
|
||||||
} catch (ElementException ee) {
|
} catch (ElementException ee) {
|
||||||
throw new SAXParseException("Error while configing element: '"+tag+"' "+ee.getMessage(),locator,ee);
|
throw new SAXParseException("Error while configing element: '" + tag + "' " + ee.getMessage(), locator, ee);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets called to pass the text between XML-tags and converts it to a String.
|
* Gets called to pass the text between XML-tags and converts it to a String. When this string is 0 length then nothing is done. If there are no element on
|
||||||
* When this string is 0 length then nothing is done.
|
* the stact noting is done.
|
||||||
* If there are no element on the stact noting is done.
|
|
||||||
*
|
*
|
||||||
* @see org.xml.sax.helpers.DefaultHandler#characters(char[],int,int)
|
* @see org.xml.sax.helpers.DefaultHandler#characters(char[],int,int)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void characters(char[] ch, int start, int length) throws SAXException {
|
public void characters(char[] ch, int start, int length) throws SAXException {
|
||||||
if (overrideSaxHandler!=null) {
|
if (overrideSaxHandler != null) {
|
||||||
overrideSaxHandler.characters(ch, start, length);
|
overrideSaxHandler.characters(ch, start, length);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (length==0) {
|
if (length == 0) {
|
||||||
return; // no text
|
return; // no text
|
||||||
}
|
}
|
||||||
String text = new String(ch,start,length);
|
String text = new String(ch, start, length);
|
||||||
if (text.length()==0) {
|
if (text.length() == 0) {
|
||||||
return; // no text
|
return; // no text
|
||||||
}
|
}
|
||||||
if (elementStack.isEmpty()) {
|
if (elementStack.isEmpty()) {
|
||||||
return; // no element
|
return; // no element
|
||||||
}
|
}
|
||||||
Element e = elementStack.peek();
|
Element e = elementStack.peek();
|
||||||
try {
|
try {
|
||||||
e.doCharacters(text);
|
e.doCharacters(text);
|
||||||
} catch (ElementException ee) {
|
} catch (ElementException ee) {
|
||||||
throw new SAXParseException("Error while doCharacters element: '"+e.getElementClass().getId()+"' "+ee.getMessage(),locator,ee);
|
throw new SAXParseException("Error while doCharacters element: '" + e.getElementClass().getId() + "' " + ee.getMessage(), locator, ee);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -241,23 +239,23 @@ public class X4OContentHandler extends DefaultHandler2 {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
|
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
|
||||||
if (overrideSaxHandler!=null) {
|
if (overrideSaxHandler != null) {
|
||||||
overrideSaxHandler.ignorableWhitespace(ch, start, length);
|
overrideSaxHandler.ignorableWhitespace(ch, start, length);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String text = new String(ch);
|
String text = new String(ch);
|
||||||
text = text.substring(start, start + length);
|
text = text.substring(start, start + length);
|
||||||
if (text.length()==0) {
|
if (text.length() == 0) {
|
||||||
return; // no text
|
return; // no text
|
||||||
}
|
}
|
||||||
if (elementStack.empty()) {
|
if (elementStack.empty()) {
|
||||||
return; // no element
|
return; // no element
|
||||||
}
|
}
|
||||||
Element e = elementStack.peek();
|
Element e = elementStack.peek();
|
||||||
try {
|
try {
|
||||||
e.doIgnorableWhitespace(text);
|
e.doIgnorableWhitespace(text);
|
||||||
} catch (ElementException ee) {
|
} catch (ElementException ee) {
|
||||||
throw new SAXParseException("Error while doIgnorableWhitespace element: '"+e.getElementClass().getId()+"' "+ee.getMessage(),locator,ee);
|
throw new SAXParseException("Error while doIgnorableWhitespace element: '" + e.getElementClass().getId() + "' " + ee.getMessage(), locator, ee);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -266,31 +264,31 @@ public class X4OContentHandler extends DefaultHandler2 {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void comment(char[] ch, int start, int length) throws SAXException {
|
public void comment(char[] ch, int start, int length) throws SAXException {
|
||||||
if (overrideSaxHandler!=null) {
|
if (overrideSaxHandler != null) {
|
||||||
overrideSaxHandler.comment(ch, start, length);
|
overrideSaxHandler.comment(ch, start, length);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String text = new String(ch);
|
String text = new String(ch);
|
||||||
text = text.substring(start, start + length);
|
text = text.substring(start, start + length);
|
||||||
if (text.length()==0) {
|
if (text.length() == 0) {
|
||||||
return; // no text
|
return; // no text
|
||||||
}
|
}
|
||||||
if (elementStack.empty()) {
|
if (elementStack.empty()) {
|
||||||
return; // no element
|
return; // no element
|
||||||
}
|
}
|
||||||
Element e = elementStack.peek();
|
Element e = elementStack.peek();
|
||||||
try {
|
try {
|
||||||
e.doComment(text);
|
e.doComment(text);
|
||||||
} catch (ElementException ee) {
|
} catch (ElementException ee) {
|
||||||
throw new SAXParseException("Error while doComment element: '"+e.getElementClass().getId()+"' "+ee.getMessage(),locator,ee);
|
throw new SAXParseException("Error while doComment element: '" + e.getElementClass().getId() + "' " + ee.getMessage(), locator, ee);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.xml.sax.helpers.DefaultHandler#processingInstruction(java.lang.String, java.lang.String)
|
* @see org.xml.sax.helpers.DefaultHandler#processingInstruction(java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void processingInstruction(String target, String data) throws SAXException {
|
public void processingInstruction(String target, String data) throws SAXException {
|
||||||
logger.fine("Skipping process instuctions: "+target+" data: "+data);
|
logger.fine("Skipping process instuctions: " + target + " data: " + data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue