Moved property config slugs to local class and fixed tests
This commit is contained in:
parent
a8294b17d4
commit
7e153499ea
|
@ -46,7 +46,7 @@ import org.xml.sax.SAXException;
|
||||||
*/
|
*/
|
||||||
public class EldXsdWriter {
|
public class EldXsdWriter {
|
||||||
|
|
||||||
private final static String PROPERTY_CONTEXT_PREFIX = PropertyConfig.X4O_PROPERTIES_PREFIX+PropertyConfig.X4O_PROPERTIES_ELD_XSD;
|
private final static String PROPERTY_CONTEXT_PREFIX = PropertyConfig.X4O_PROPERTIES_PREFIX+"eld-xsd/";
|
||||||
public final static PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
public final static PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
||||||
|
|
||||||
public final static String OUTPUT_PATH = PROPERTY_CONTEXT_PREFIX+"output/path";
|
public final static String OUTPUT_PATH = PROPERTY_CONTEXT_PREFIX+"output/path";
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class DefaultX4OReader<T> extends AbstractX4OReader<T> {
|
||||||
|
|
||||||
private final PropertyConfig propertyConfig;
|
private final PropertyConfig propertyConfig;
|
||||||
|
|
||||||
private final static String PROPERTY_CONTEXT_PREFIX = PropertyConfig.X4O_PROPERTIES_PREFIX+PropertyConfig.X4O_PROPERTIES_READER;
|
private final static String PROPERTY_CONTEXT_PREFIX = PropertyConfig.X4O_PROPERTIES_PREFIX+"reader/x4o/";
|
||||||
|
|
||||||
public final static PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
public final static PropertyConfig 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";
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
|
||||||
|
|
||||||
private final PropertyConfig propertyConfig;
|
private final PropertyConfig propertyConfig;
|
||||||
|
|
||||||
private final static String PROPERTY_CONTEXT_PREFIX = PropertyConfig.X4O_PROPERTIES_PREFIX+PropertyConfig.X4O_PROPERTIES_WRITER;
|
private final static String PROPERTY_CONTEXT_PREFIX = PropertyConfig.X4O_PROPERTIES_PREFIX+"writer/x4o/";
|
||||||
|
|
||||||
public final static PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
public final static PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ import org.xml.sax.SAXException;
|
||||||
*/
|
*/
|
||||||
public class X4OStaticWriter {
|
public class X4OStaticWriter {
|
||||||
|
|
||||||
private final static String PROPERTY_CONTEXT_PREFIX = PropertyConfig.X4O_PROPERTIES_PREFIX+PropertyConfig.X4O_PROPERTIES_X4O_STATIC;
|
private final static String PROPERTY_CONTEXT_PREFIX = PropertyConfig.X4O_PROPERTIES_PREFIX+"x4o-static/";
|
||||||
public final static PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
public final static PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
||||||
|
|
||||||
public final static String OUTPUT_PATH = PROPERTY_CONTEXT_PREFIX+"output/path";
|
public final static String OUTPUT_PATH = PROPERTY_CONTEXT_PREFIX+"output/path";
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class X4OEntityResolverTest {
|
||||||
public void testResolveProperty() throws Exception {
|
public void testResolveProperty() throws Exception {
|
||||||
X4ODriver<TestObjectRoot> driver = new TestDriver();
|
X4ODriver<TestObjectRoot> driver = new TestDriver();
|
||||||
X4OLanguageSession language = driver.createLanguage().createLanguageSession();
|
X4OLanguageSession language = driver.createLanguage().createLanguageSession();
|
||||||
PropertyConfig conf = new PropertyConfig(DefaultX4OReader.DEFAULT_PROPERTY_CONFIG,PropertyConfig.X4O_PROPERTIES_PREFIX+PropertyConfig.X4O_PROPERTIES_READER);
|
PropertyConfig conf = new PropertyConfig(DefaultX4OReader.DEFAULT_PROPERTY_CONFIG,PropertyConfig.X4O_PROPERTIES_PREFIX+"reader/x4o/");
|
||||||
conf.setProperty(DefaultX4OReader.SAX_ENTITY_RESOLVER, new TestEntityResolver());
|
conf.setProperty(DefaultX4OReader.SAX_ENTITY_RESOLVER, new TestEntityResolver());
|
||||||
X4OEntityResolver resolver = new X4OEntityResolver(language,conf);
|
X4OEntityResolver resolver = new X4OEntityResolver(language,conf);
|
||||||
Exception e = null;
|
Exception e = null;
|
||||||
|
@ -104,7 +104,7 @@ public class X4OEntityResolverTest {
|
||||||
public void testResolvePropertyNull() throws Exception {
|
public void testResolvePropertyNull() throws Exception {
|
||||||
X4ODriver<TestObjectRoot> driver = new TestDriver();
|
X4ODriver<TestObjectRoot> driver = new TestDriver();
|
||||||
X4OLanguageSession language = driver.createLanguage().createLanguageSession();
|
X4OLanguageSession language = driver.createLanguage().createLanguageSession();
|
||||||
PropertyConfig conf = new PropertyConfig(DefaultX4OReader.DEFAULT_PROPERTY_CONFIG,PropertyConfig.X4O_PROPERTIES_PREFIX+PropertyConfig.X4O_PROPERTIES_READER);
|
PropertyConfig conf = new PropertyConfig(DefaultX4OReader.DEFAULT_PROPERTY_CONFIG,PropertyConfig.X4O_PROPERTIES_PREFIX+"reader/x4o/");
|
||||||
conf.setProperty(DefaultX4OReader.SAX_ENTITY_RESOLVER, new TestEntityResolver());
|
conf.setProperty(DefaultX4OReader.SAX_ENTITY_RESOLVER, new TestEntityResolver());
|
||||||
X4OEntityResolver resolver = new X4OEntityResolver(language,conf);
|
X4OEntityResolver resolver = new X4OEntityResolver(language,conf);
|
||||||
Exception e = null;
|
Exception e = null;
|
||||||
|
|
|
@ -79,7 +79,7 @@ public class EldDocWriter {
|
||||||
private static final String[] CC_CONFIGURATOR_G = {"configurator-global","ConfiguratorGlobal","The global configurator.","The global configurator."};
|
private static final String[] CC_CONFIGURATOR_G = {"configurator-global","ConfiguratorGlobal","The global configurator.","The global configurator."};
|
||||||
private static final String[] CC_BINDING = {"binding","Binding","The element binding.","The element binding."};
|
private static final String[] CC_BINDING = {"binding","Binding","The element binding.","The element binding."};
|
||||||
|
|
||||||
private final static String PROPERTY_CONTEXT_PREFIX = PropertyConfig.X4O_PROPERTIES_PREFIX+PropertyConfig.X4O_PROPERTIES_ELD_DOC;
|
private final static String PROPERTY_CONTEXT_PREFIX = PropertyConfig.X4O_PROPERTIES_PREFIX+"eld-doc/";
|
||||||
public final static PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
public final static PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
||||||
|
|
||||||
public final static String OUTPUT_PATH = PROPERTY_CONTEXT_PREFIX+"output/path";
|
public final static String OUTPUT_PATH = PROPERTY_CONTEXT_PREFIX+"output/path";
|
||||||
|
|
|
@ -62,7 +62,9 @@ import org.xml.sax.SAXException;
|
||||||
*/
|
*/
|
||||||
public class ApiDocWriter {
|
public class ApiDocWriter {
|
||||||
|
|
||||||
private final static String PROPERTY_CONTEXT_PREFIX = PropertyConfig.X4O_PROPERTIES_PREFIX+PropertyConfig.X4O_PROPERTIES_ELD_DOC;
|
// NOTE: this class is unused, and is waiting for ApiDocProject code and replaces most code in EldDocWriter to here.
|
||||||
|
|
||||||
|
private final static String PROPERTY_CONTEXT_PREFIX = PropertyConfig.X4O_PROPERTIES_PREFIX+"api-doc/";
|
||||||
public final static PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
public final static PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
||||||
|
|
||||||
public final static String OUTPUT_PATH = PROPERTY_CONTEXT_PREFIX+"output/path";
|
public final static String OUTPUT_PATH = PROPERTY_CONTEXT_PREFIX+"output/path";
|
||||||
|
|
|
@ -38,23 +38,11 @@ import java.util.function.Supplier;
|
||||||
*/
|
*/
|
||||||
public final class PropertyConfig implements Cloneable {
|
public final class PropertyConfig implements Cloneable {
|
||||||
|
|
||||||
|
public final static String X4O_PROPERTIES_PREFIX = "http://x4o.org/properties/";
|
||||||
private final Map<String,PropertyConfigItem> items;
|
private final Map<String,PropertyConfigItem> items;
|
||||||
private final boolean readOnly;
|
private final boolean readOnly;
|
||||||
private final String keyPrefix;
|
private final String keyPrefix;
|
||||||
|
|
||||||
// TODO: move to ?
|
|
||||||
// public final static String X4O_PROPERTIES_PREFIX = "http://language.x4o.org/xml/properties/";
|
|
||||||
public final static String X4O_PROPERTIES_PREFIX = "http://x4o.org/properties/";
|
|
||||||
public final static String X4O_PROPERTIES_READER = "reader/x4o/";
|
|
||||||
//public final static String X4O_PROPERTIES_READER_DTD = "reader/dtd/";
|
|
||||||
public final static String X4O_PROPERTIES_WRITER = "writer/x4o/";
|
|
||||||
public final static String X4O_PROPERTIES_WRITER_XML = "content/";
|
|
||||||
public final static String X4O_PROPERTIES_ELD_XSD = "eld-xsd/";
|
|
||||||
public final static String X4O_PROPERTIES_ELD_DOC = "eld-doc/";
|
|
||||||
public final static String X4O_PROPERTIES_X4O_STATIC = "x4o-static/";
|
|
||||||
//public final static String X4O_PROPERTIES_WRITER_DTD = "writer/dtd/";
|
|
||||||
//public final static String X4O_PROPERTIES_WRITER_HTML = "writer/html/";
|
|
||||||
|
|
||||||
public PropertyConfig(String keyPrefix,PropertyConfigItem...items) {
|
public PropertyConfig(String keyPrefix,PropertyConfigItem...items) {
|
||||||
this(false,null,keyPrefix,items);
|
this(false,null,keyPrefix,items);
|
||||||
}
|
}
|
||||||
|
@ -421,19 +409,19 @@ public final class PropertyConfig implements Cloneable {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Boolean.class.equals(valueType)) {
|
if (Boolean.class.equals(valueType)) {
|
||||||
setProperty(key, new Boolean(value));
|
setProperty(key, Boolean.parseBoolean(value));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Integer.class.equals(valueType)) {
|
if (Integer.class.equals(valueType)) {
|
||||||
setProperty(key, new Integer(value));
|
setProperty(key, Integer.parseInt(value));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Double.class.equals(valueType)) {
|
if (Double.class.equals(valueType)) {
|
||||||
setProperty(key, new Double(value));
|
setProperty(key, Double.parseDouble(value));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Float.class.equals(valueType)) {
|
if (Float.class.equals(valueType)) {
|
||||||
setProperty(key, new Float(value));
|
setProperty(key, Float.parseFloat(value));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (File.class.equals(valueType)) {
|
if (File.class.equals(valueType)) {
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class AbstractContentWriterHandler implements ContentHandler {
|
||||||
private String lastElement = null;
|
private String lastElement = null;
|
||||||
private Stack<String> elements = null;
|
private Stack<String> elements = null;
|
||||||
|
|
||||||
private final static String PROPERTY_CONTEXT_PREFIX = PropertyConfig.X4O_PROPERTIES_PREFIX+PropertyConfig.X4O_PROPERTIES_WRITER_XML;
|
private final static String PROPERTY_CONTEXT_PREFIX = PropertyConfig.X4O_PROPERTIES_PREFIX+"content/"; // TODO: change to "writer/xml"
|
||||||
public final static PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
public final static PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
||||||
public final static String OUTPUT_ENCODING = PROPERTY_CONTEXT_PREFIX+"output/encoding";
|
public final static String OUTPUT_ENCODING = PROPERTY_CONTEXT_PREFIX+"output/encoding";
|
||||||
public final static String OUTPUT_CHAR_TAB = PROPERTY_CONTEXT_PREFIX+"output/char-tab";
|
public final static String OUTPUT_CHAR_TAB = PROPERTY_CONTEXT_PREFIX+"output/char-tab";
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class AbstractXDBXWriterHandler implements ContentHandler {
|
||||||
private Stack<String> elements = null;
|
private Stack<String> elements = null;
|
||||||
private Map<String,Integer> stringIdx = null;
|
private Map<String,Integer> stringIdx = null;
|
||||||
|
|
||||||
private final static String PROPERTY_CONTEXT_PREFIX = PropertyConfig.X4O_PROPERTIES_PREFIX+PropertyConfig.X4O_PROPERTIES_WRITER_XML;
|
private final static String PROPERTY_CONTEXT_PREFIX = PropertyConfig.X4O_PROPERTIES_PREFIX+"writer/xdbx/";
|
||||||
public final static PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
public final static PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
||||||
public final static String OUTPUT_DECLARATION = PROPERTY_CONTEXT_PREFIX+"output/declaration";
|
public final static String OUTPUT_DECLARATION = PROPERTY_CONTEXT_PREFIX+"output/declaration";
|
||||||
public final static String OUTPUT_CHAR_NULL = PROPERTY_CONTEXT_PREFIX+"output/char-null";
|
public final static String OUTPUT_CHAR_NULL = PROPERTY_CONTEXT_PREFIX+"output/char-null";
|
||||||
|
|
|
@ -29,8 +29,6 @@ import java.io.StringWriter;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.x4o.xml.o2o.io.sax3.ContentWriterXml;
|
import org.x4o.xml.o2o.io.sax3.ContentWriterXml;
|
||||||
import org.x4o.xml.o2o.io.sax3.xdbx.XDBXReaderXml;
|
|
||||||
import org.x4o.xml.o2o.io.sax3.xdbx.XDBXWriterXml;
|
|
||||||
import org.xml.sax.helpers.AttributesImpl;
|
import org.xml.sax.helpers.AttributesImpl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -155,9 +153,9 @@ public class XDBXWriterXmlTest {
|
||||||
writer.startElement("", "name", "", atts);
|
writer.startElement("", "name", "", atts);
|
||||||
writer.characters("Bill");
|
writer.characters("Bill");
|
||||||
writer.endElement("", "name", "");
|
writer.endElement("", "name", "");
|
||||||
writer.startElement("bar", "age", "foo:age", new AttributesImpl());
|
writer.startElement("bar", "age", "age", new AttributesImpl());
|
||||||
writer.characters("35");
|
writer.characters("35");
|
||||||
writer.endElement("", "age", "");
|
writer.endElement("bar", "age", "age");
|
||||||
writer.endElement("", "Person", "");
|
writer.endElement("", "Person", "");
|
||||||
|
|
||||||
writer.startElement("", "Person", "", new AttributesImpl());
|
writer.startElement("", "Person", "", new AttributesImpl());
|
||||||
|
@ -166,9 +164,9 @@ public class XDBXWriterXmlTest {
|
||||||
writer.startElement("", "name", "", atts);
|
writer.startElement("", "name", "", atts);
|
||||||
writer.characters("Joe");
|
writer.characters("Joe");
|
||||||
writer.endElement("", "name", "");
|
writer.endElement("", "name", "");
|
||||||
writer.startElement("bar", "age", "foo:age", new AttributesImpl());
|
writer.startElement("bar", "age", "age", new AttributesImpl());
|
||||||
writer.characters("45");
|
writer.characters("45");
|
||||||
writer.endElement("", "age", "");
|
writer.endElement("bar", "age", "age");
|
||||||
writer.endElement("", "Person", "");
|
writer.endElement("", "Person", "");
|
||||||
|
|
||||||
writer.endElement("", "root", "");
|
writer.endElement("", "root", "");
|
||||||
|
|
Loading…
Reference in a new issue