Fixed encoding bug,Added writeString support,Started on config bean.
This commit is contained in:
parent
8d71b63a6f
commit
6f2815491b
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -65,3 +65,7 @@ nbproject
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
Desktop.ini
|
Desktop.ini
|
||||||
|
|
||||||
|
# Ignore kde dolphin files
|
||||||
|
.directory
|
||||||
|
|
||||||
|
|
||||||
|
|
2
todo.txt
2
todo.txt
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
- Add doc version upgrade handler;
|
- Add doc version upgrade handler;
|
||||||
- per version step xslt doc upgrade (check dyna sax piplining hooking)
|
- per version step xslt doc upgrade (check dyna sax piplining hooking)
|
||||||
- per version eld + support code + backing objects
|
- per version eld + support code + backing objects (DONE)
|
||||||
- per version eld for dyna tree convert to new backing objects.
|
- per version eld for dyna tree convert to new backing objects.
|
||||||
- Add *Local layer for X4OLanguage* classes.
|
- Add *Local layer for X4OLanguage* classes.
|
||||||
- Add default define (EL) layer
|
- Add default define (EL) layer
|
||||||
|
|
|
@ -30,7 +30,9 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
|
import org.x4o.xml.lang.X4OLanguageClassLoader;
|
||||||
import org.x4o.xml.lang.X4OLanguageContext;
|
import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageProperty;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -102,9 +104,7 @@ abstract public class AbstractX4OReaderContext<T> extends AbstractX4OConnection
|
||||||
if (resourceName==null) {
|
if (resourceName==null) {
|
||||||
throw new NullPointerException("Can't read null resourceName from classpath.");
|
throw new NullPointerException("Can't read null resourceName from classpath.");
|
||||||
}
|
}
|
||||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
URL url = X4OLanguageClassLoader.getResource(resourceName);
|
||||||
if (cl == null) cl = getClass().getClassLoader(); // fallback
|
|
||||||
URL url = cl.getResource(resourceName);
|
|
||||||
if (url==null) {
|
if (url==null) {
|
||||||
throw new NullPointerException("Could not find resource on classpath: "+resourceName);
|
throw new NullPointerException("Could not find resource on classpath: "+resourceName);
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ abstract public class AbstractX4OReaderContext<T> extends AbstractX4OConnection
|
||||||
baseUrl = baseUrl.substring(0,lastSlash+1);
|
baseUrl = baseUrl.substring(0,lastSlash+1);
|
||||||
}
|
}
|
||||||
URL basePath = new URL(baseUrl);
|
URL basePath = new URL(baseUrl);
|
||||||
InputStream inputStream = cl.getResourceAsStream(resourceName);
|
InputStream inputStream = X4OLanguageClassLoader.getResourceAsStream(resourceName);
|
||||||
try {
|
try {
|
||||||
return readContext(inputStream,url.toExternalForm(),basePath);
|
return readContext(inputStream,url.toExternalForm(),basePath);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -123,8 +123,8 @@ abstract public class AbstractX4OReaderContext<T> extends AbstractX4OConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a String to a InputStream to is can me readd by SAX.
|
* Converts a String to a InputStream to is can me read by SAX.
|
||||||
* @param xmlString The xml as String to read.
|
* @param xmlString The xml as (UTF-8) String to read.
|
||||||
* @throws X4OConnectionException Is thrown after x4o exception.
|
* @throws X4OConnectionException Is thrown after x4o exception.
|
||||||
* @throws SAXException Is thrown after sax xml exception.
|
* @throws SAXException Is thrown after sax xml exception.
|
||||||
* @throws IOException Is thrown after io exception.
|
* @throws IOException Is thrown after io exception.
|
||||||
|
@ -135,7 +135,8 @@ abstract public class AbstractX4OReaderContext<T> extends AbstractX4OConnection
|
||||||
throw new NullPointerException("Can't read null xml string.");
|
throw new NullPointerException("Can't read null xml string.");
|
||||||
}
|
}
|
||||||
URL basePath = new File(System.getProperty("user.dir")).toURI().toURL();
|
URL basePath = new File(System.getProperty("user.dir")).toURI().toURL();
|
||||||
return readContext(new ByteArrayInputStream(xmlString.getBytes()),"inline-xml",basePath);
|
String encoding = getLanguageContext().getLanguagePropertyString(X4OLanguageProperty.READER_INPUT_ENCODING);
|
||||||
|
return readContext(new ByteArrayInputStream(xmlString.getBytes(encoding)),"inline-xml",basePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -77,4 +77,8 @@ public abstract class AbstractX4OWriter<T> extends AbstractX4OWriterContext<T> i
|
||||||
public void writeFile(T object,File file) throws X4OConnectionException,SAXException,IOException,FileNotFoundException {
|
public void writeFile(T object,File file) throws X4OConnectionException,SAXException,IOException,FileNotFoundException {
|
||||||
writeFileContext(toObjectContext(object), file);
|
writeFileContext(toObjectContext(object), file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String writeString(T object) throws X4OConnectionException,SAXException,IOException,FileNotFoundException {
|
||||||
|
return writeStringContext(toObjectContext(object));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,12 +22,14 @@
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.io;
|
package org.x4o.xml.io;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
import org.x4o.xml.lang.X4OLanguageContext;
|
import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageProperty;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,4 +62,11 @@ public abstract class AbstractX4OWriterContext<T> extends AbstractX4OConnection
|
||||||
outputStream.close();
|
outputStream.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String writeStringContext(X4OLanguageContext context) throws X4OConnectionException,SAXException,IOException {
|
||||||
|
ByteArrayOutputStream out = new ByteArrayOutputStream(4096);
|
||||||
|
writeContext(context, out);
|
||||||
|
String encoding = context.getLanguagePropertyString(X4OLanguageProperty.WRITER_OUTPUT_ENCODING);
|
||||||
|
return out.toString(encoding);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,4 +41,6 @@ public interface X4OWriter<T> extends X4OConnection {
|
||||||
void writeFile(T object,String fileName) throws X4OConnectionException,SAXException,IOException;
|
void writeFile(T object,String fileName) throws X4OConnectionException,SAXException,IOException;
|
||||||
|
|
||||||
void writeFile(T object,File file) throws X4OConnectionException,SAXException,IOException;
|
void writeFile(T object,File file) throws X4OConnectionException,SAXException,IOException;
|
||||||
|
|
||||||
|
String writeString(T object) throws X4OConnectionException,SAXException,IOException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,4 +42,6 @@ public interface X4OWriterContext<T> extends X4OWriter<T> {
|
||||||
void writeFileContext(X4OLanguageContext context,String fileName) throws X4OConnectionException,SAXException,IOException;
|
void writeFileContext(X4OLanguageContext context,String fileName) throws X4OConnectionException,SAXException,IOException;
|
||||||
|
|
||||||
void writeFileContext(X4OLanguageContext context,File file) throws X4OConnectionException,SAXException,IOException;
|
void writeFileContext(X4OLanguageContext context,File file) throws X4OConnectionException,SAXException,IOException;
|
||||||
|
|
||||||
|
String writeStringContext(X4OLanguageContext context) throws X4OConnectionException,SAXException,IOException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,6 +83,14 @@ public class AbstractContentWriterHandler implements ContentHandler {
|
||||||
prefixMapping = new HashMap<String,String>(15);
|
prefixMapping = new HashMap<String,String>(15);
|
||||||
printedMappings = new ArrayList<String>(15);
|
printedMappings = new ArrayList<String>(15);
|
||||||
elements = new Stack<String>();
|
elements = new Stack<String>();
|
||||||
|
/*
|
||||||
|
ContentConfig conf = new ContentConfig(
|
||||||
|
new ContentConfigItem("writer/output/encoding",String.class,XMLConstants.XML_DEFAULT_ENCODING),
|
||||||
|
new ContentConfigItem("content/writer/output/charTab",String.class)
|
||||||
|
);
|
||||||
|
conf.getPropertyString("");
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: check location of this. (add to api?)
|
// TODO: check location of this. (add to api?)
|
||||||
|
@ -227,12 +235,8 @@ public class AbstractContentWriterHandler implements ContentHandler {
|
||||||
attributeValue = "null"; // TODO: Add null value key to config.
|
attributeValue = "null"; // TODO: Add null value key to config.
|
||||||
}
|
}
|
||||||
String attributeValueSafe = XMLConstants.escapeAttributeValue(attributeValue);
|
String attributeValueSafe = XMLConstants.escapeAttributeValue(attributeValue);
|
||||||
boolean printNewLine = attributeValueSafe.length()>80; // TODO add config
|
|
||||||
if (i==0) {
|
startElement.append(' ');
|
||||||
startElement.append(' ');
|
|
||||||
} else if (!printNewLine) {
|
|
||||||
startElement.append(' ');
|
|
||||||
}
|
|
||||||
if (XMLConstants.NULL_NS_URI.equals(attributeUri) | attributeUri ==null) {
|
if (XMLConstants.NULL_NS_URI.equals(attributeUri) | attributeUri ==null) {
|
||||||
startElement.append(attributeName);
|
startElement.append(attributeName);
|
||||||
} else {
|
} else {
|
||||||
|
@ -243,6 +247,7 @@ public class AbstractContentWriterHandler implements ContentHandler {
|
||||||
startElement.append("=\"");
|
startElement.append("=\"");
|
||||||
startElement.append(attributeValueSafe);
|
startElement.append(attributeValueSafe);
|
||||||
startElement.append('"');
|
startElement.append('"');
|
||||||
|
boolean printNewLine = attributeValueSafe.length()>80; // TODO add config
|
||||||
if (printNewLine) {
|
if (printNewLine) {
|
||||||
startElement.append(XMLConstants.CHAR_NEWLINE);
|
startElement.append(XMLConstants.CHAR_NEWLINE);
|
||||||
for (int ii = 0; ii < indent+1; ii++) {
|
for (int ii = 0; ii < indent+1; ii++) {
|
||||||
|
@ -385,6 +390,10 @@ public class AbstractContentWriterHandler implements ContentHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Prints xml ignorable whitespace.
|
||||||
|
*
|
||||||
|
* @param text The text to print.
|
||||||
|
* @throws SAXException When IOException has happend while printing.
|
||||||
* @see org.x4o.xml.io.sax.ext.ContentWriter#ignorableWhitespace(java.lang.String)
|
* @see org.x4o.xml.io.sax.ext.ContentWriter#ignorableWhitespace(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void ignorableWhitespace(String text) throws SAXException {
|
public void ignorableWhitespace(String text) throws SAXException {
|
||||||
|
@ -395,6 +404,12 @@ public class AbstractContentWriterHandler implements ContentHandler {
|
||||||
write(text); // TODO: check chars
|
write(text); // TODO: check chars
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints xml ignorable whitespace character.
|
||||||
|
*
|
||||||
|
* @param c The character to print.
|
||||||
|
* @throws SAXException When IOException has happend while printing.
|
||||||
|
*/
|
||||||
public void ignorableWhitespace(char c) throws SAXException {
|
public void ignorableWhitespace(char c) throws SAXException {
|
||||||
ignorableWhitespace(new char[]{c},0,1);
|
ignorableWhitespace(new char[]{c},0,1);
|
||||||
}
|
}
|
||||||
|
@ -462,6 +477,8 @@ public class AbstractContentWriterHandler implements ContentHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Prints xml comment.
|
||||||
|
*
|
||||||
* @see org.x4o.xml.io.sax.ext.ContentWriter#comment(java.lang.String)
|
* @see org.x4o.xml.io.sax.ext.ContentWriter#comment(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void comment(String text) throws SAXException {
|
public void comment(String text) throws SAXException {
|
||||||
|
@ -480,6 +497,11 @@ public class AbstractContentWriterHandler implements ContentHandler {
|
||||||
printReturn = true;
|
printReturn = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the value contains any new lines and sets the printReturn field.
|
||||||
|
*
|
||||||
|
* @param value The value to check.
|
||||||
|
*/
|
||||||
private void checkPrintedReturn(String value) {
|
private void checkPrintedReturn(String value) {
|
||||||
if (value.indexOf(XMLConstants.CHAR_NEWLINE)>0) {
|
if (value.indexOf(XMLConstants.CHAR_NEWLINE)>0) {
|
||||||
printReturn = true;
|
printReturn = true;
|
||||||
|
|
|
@ -0,0 +1,158 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013, Willem Cazander
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
* that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||||
|
* following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
package org.x4o.xml.io.sax.ext;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ContentConfig Defines checked config options.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 May 1, 2013
|
||||||
|
*/
|
||||||
|
public final class ContentConfig {
|
||||||
|
|
||||||
|
private final ContentConfigItem[] items;
|
||||||
|
private final Map<String,Integer> itemKeys;
|
||||||
|
|
||||||
|
public ContentConfig(ContentConfigItem...items) {
|
||||||
|
this.items=items;
|
||||||
|
itemKeys = new HashMap<String,Integer>(items.length);
|
||||||
|
for (int i=0;i<items.length;i++) {
|
||||||
|
ContentConfigItem item = items[i];
|
||||||
|
itemKeys.put(item.getKey(),i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class ContentConfigItem {
|
||||||
|
private String key = null;
|
||||||
|
private Class<?> valueType = null;
|
||||||
|
private Object defaultValue = null;
|
||||||
|
private Object value = null;
|
||||||
|
|
||||||
|
public ContentConfigItem(String key,Class<?> valueType) {
|
||||||
|
this(key,valueType,null);
|
||||||
|
}
|
||||||
|
public ContentConfigItem(String key,Class<?> valueType,Object defaultValue) {
|
||||||
|
setKey(key);
|
||||||
|
setValueType(valueType);
|
||||||
|
setDefaultValue(defaultValue);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @return the key
|
||||||
|
*/
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param key the key to set
|
||||||
|
*/
|
||||||
|
public void setKey(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @return the valueType
|
||||||
|
*/
|
||||||
|
public Class<?> getValueType() {
|
||||||
|
return valueType;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param valueType the valueType to set
|
||||||
|
*/
|
||||||
|
public void setValueType(Class<?> valueType) {
|
||||||
|
this.valueType = valueType;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @return the defaultValue
|
||||||
|
*/
|
||||||
|
public Object getDefaultValue() {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param defaultValue the defaultValue to set
|
||||||
|
*/
|
||||||
|
public void setDefaultValue(Object defaultValue) {
|
||||||
|
this.defaultValue = defaultValue;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @return the value
|
||||||
|
*/
|
||||||
|
public Object getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param value the value to set
|
||||||
|
*/
|
||||||
|
public void setValue(Object value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final ContentConfigItem getContentConfigItem(String key) {
|
||||||
|
Integer keyIdx = itemKeys.get(key);
|
||||||
|
if (keyIdx==null) {
|
||||||
|
throw new IllegalArgumentException("Could not find config item for: "+key);
|
||||||
|
}
|
||||||
|
ContentConfigItem item = items[keyIdx];
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void setProperty(String key,Object value) {
|
||||||
|
ContentConfigItem item = getContentConfigItem(key);
|
||||||
|
item.setValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final Object getProperty(String key) {
|
||||||
|
ContentConfigItem item = getContentConfigItem(key);
|
||||||
|
return item.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final boolean getPropertyBoolean(String key) {
|
||||||
|
ContentConfigItem item = getContentConfigItem(key);
|
||||||
|
Object value = item.getValue();
|
||||||
|
if (value instanceof Boolean) {
|
||||||
|
return (Boolean)value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (Boolean)item.getDefaultValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int getPropertyInteger(String key) {
|
||||||
|
ContentConfigItem item = getContentConfigItem(key);
|
||||||
|
Object value = item.getValue();
|
||||||
|
if (value instanceof Integer) {
|
||||||
|
return (Integer)value;
|
||||||
|
}
|
||||||
|
return (Integer)item.getDefaultValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final String getPropertyString(String key) {
|
||||||
|
ContentConfigItem item = getContentConfigItem(key);
|
||||||
|
Object value = item.getValue();
|
||||||
|
if (value instanceof String) {
|
||||||
|
return (String)value;
|
||||||
|
}
|
||||||
|
return (String)item.getDefaultValue();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,38 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2004-2013, Willem Cazander
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
|
||||||
* that the following conditions are met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
|
||||||
* following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
|
||||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
|
||||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
|
||||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package org.x4o.xml.io.sax.ext;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ContentWriterConfig Defines config options for ContentWriter.
|
|
||||||
*
|
|
||||||
* @author Willem Cazander
|
|
||||||
* @version 1.0 May 1, 2013
|
|
||||||
*/
|
|
||||||
public interface ContentWriterConfig {
|
|
||||||
|
|
||||||
String getCharNewLine();
|
|
||||||
String getCharTab();
|
|
||||||
|
|
||||||
String getReplaceCdataStart();
|
|
||||||
String getReplaceCdataEnd();
|
|
||||||
}
|
|
|
@ -22,6 +22,9 @@
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.lang;
|
package org.x4o.xml.lang;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* X4OLanguageClassLoader is short hand for safe class loading.
|
* X4OLanguageClassLoader is short hand for safe class loading.
|
||||||
*
|
*
|
||||||
|
@ -82,4 +85,24 @@ public final class X4OLanguageClassLoader {
|
||||||
public static Object newInstance(String className) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
|
public static Object newInstance(String className) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
|
||||||
return newInstance(loadClass(className));
|
return newInstance(loadClass(className));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a resource from the classloader to an url.
|
||||||
|
* @param resourceName The resource to get from the classloader.
|
||||||
|
* @return The url to the resource or null if not found.
|
||||||
|
* @see java.lang.ClassLoader#getResource(String)
|
||||||
|
*/
|
||||||
|
public static URL getResource(String resourceName) {
|
||||||
|
return getClassLoader().getResource(resourceName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a resource from the classloader to an inputstream.
|
||||||
|
* @param resourceName The resource to get from the classloader.
|
||||||
|
* @return The inputstream to the resource or null if not found.
|
||||||
|
* @see java.lang.ClassLoader#getResourceAsStream(String)
|
||||||
|
*/
|
||||||
|
public static InputStream getResourceAsStream(String resourceName) {
|
||||||
|
return getClassLoader().getResourceAsStream(resourceName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ import java.util.Map;
|
||||||
import javax.el.ELContext;
|
import javax.el.ELContext;
|
||||||
import javax.el.ExpressionFactory;
|
import javax.el.ExpressionFactory;
|
||||||
|
|
||||||
|
import org.x4o.xml.io.XMLConstants;
|
||||||
import org.xml.sax.EntityResolver;
|
import org.xml.sax.EntityResolver;
|
||||||
import org.xml.sax.ErrorHandler;
|
import org.xml.sax.ErrorHandler;
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.InputSource;
|
||||||
|
@ -60,7 +61,7 @@ public enum X4OLanguageProperty {
|
||||||
READER_INPUT_STREAM(IO.READER,"reader/input/stream",InputStream.class),
|
READER_INPUT_STREAM(IO.READER,"reader/input/stream",InputStream.class),
|
||||||
|
|
||||||
/** When set it overrides automatic encoding detection of sax parser. */
|
/** When set it overrides automatic encoding detection of sax parser. */
|
||||||
READER_INPUT_ENCODING(IO.READER,"reader/input/encoding",String.class),
|
READER_INPUT_ENCODING(IO.READER,"reader/input/encoding",String.class,XMLConstants.XML_DEFAULT_ENCODING),
|
||||||
|
|
||||||
/** When set use this InputSource instance for parsing. */
|
/** When set use this InputSource instance for parsing. */
|
||||||
READER_INPUT_SOURCE(IO.READER,"reader/input/source",InputSource.class),
|
READER_INPUT_SOURCE(IO.READER,"reader/input/source",InputSource.class),
|
||||||
|
@ -107,7 +108,7 @@ public enum X4OLanguageProperty {
|
||||||
WRITER_OUTPUT_STREAM(IO.WRITER,"writer/output/stream",OutputStream.class),
|
WRITER_OUTPUT_STREAM(IO.WRITER,"writer/output/stream",OutputStream.class),
|
||||||
|
|
||||||
/** The writer output encoding. */
|
/** The writer output encoding. */
|
||||||
WRITER_OUTPUT_ENCODING(IO.WRITER,"writer/output/encoding",String.class),
|
WRITER_OUTPUT_ENCODING(IO.WRITER,"writer/output/encoding",String.class,XMLConstants.XML_DEFAULT_ENCODING),
|
||||||
|
|
||||||
/** The writer output newline. */
|
/** The writer output newline. */
|
||||||
WRITER_OUTPUT_CHAR_NEWLINE(IO.WRITER,"writer/output/char/newline",String.class),
|
WRITER_OUTPUT_CHAR_NEWLINE(IO.WRITER,"writer/output/char/newline",String.class),
|
||||||
|
@ -129,7 +130,7 @@ public enum X4OLanguageProperty {
|
||||||
SCHEMA_WRITER_OUTPUT_PATH(IO.SCHEMA_WRITER,"schema-writer/output/path",File.class),
|
SCHEMA_WRITER_OUTPUT_PATH(IO.SCHEMA_WRITER,"schema-writer/output/path",File.class),
|
||||||
|
|
||||||
/** The schema writer output encoding. */
|
/** The schema writer output encoding. */
|
||||||
SCHEMA_WRITER_OUTPUT_ENCODING(IO.SCHEMA_WRITER,"schema-writer/output/encoding",String.class),
|
SCHEMA_WRITER_OUTPUT_ENCODING(IO.SCHEMA_WRITER,"schema-writer/output/encoding",String.class,XMLConstants.XML_DEFAULT_ENCODING),
|
||||||
|
|
||||||
/** The schema writer output newline. */
|
/** The schema writer output newline. */
|
||||||
SCHEMA_WRITER_OUTPUT_CHAR_NEWLINE(IO.SCHEMA_WRITER,"schema-writer/output/char/newline",String.class),
|
SCHEMA_WRITER_OUTPUT_CHAR_NEWLINE(IO.SCHEMA_WRITER,"schema-writer/output/char/newline",String.class),
|
||||||
|
|
|
@ -630,8 +630,8 @@ public class X4OPhaseLanguageRead {
|
||||||
return; // has already runned.
|
return; // has already runned.
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
//if (parser.hasX4ODebugWriter()) {
|
//if (element.getLanguageContext().hasX4ODebugWriter()) {
|
||||||
// parser.getX4ODebugWriter().debugElement(element);
|
// element.getLanguageContext().getX4ODebugWriter().debugElement(element);
|
||||||
//}
|
//}
|
||||||
element.doElementRun();
|
element.doElementRun();
|
||||||
} catch (ElementException e) {
|
} catch (ElementException e) {
|
||||||
|
|
|
@ -22,6 +22,15 @@
|
||||||
*/
|
*/
|
||||||
package org.x4o.xml.eld;
|
package org.x4o.xml.eld;
|
||||||
|
|
||||||
|
import org.x4o.xml.X4ODriver;
|
||||||
|
import org.x4o.xml.X4ODriverManager;
|
||||||
|
import org.x4o.xml.io.X4OReader;
|
||||||
|
import org.x4o.xml.io.X4OWriter;
|
||||||
|
import org.x4o.xml.lang.DefaultX4OLanguageModule;
|
||||||
|
import org.x4o.xml.lang.X4OLanguage;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageLocal;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageModule;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,10 +104,27 @@ public class EldParserTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testRunEldParser() throws Exception {
|
public void testRunEldParser() throws Exception {
|
||||||
//EldDriver parser = new EldDriver(false);
|
X4ODriver<X4OLanguageModule> driver = (X4ODriver<X4OLanguageModule>)X4ODriverManager.getX4ODriver(EldDriver.LANGUAGE_NAME);
|
||||||
//parser.parseResource("META-INF/test/test-lang.eld");
|
X4OReader<X4OLanguageModule> reader = driver.createReader();
|
||||||
//X4ODriver<X4OLanguageModule> driver = (X4ODriver<X4OLanguageModule>)X4ODriverManager.getX4ODriver(EldDriver.LANGUAGE_NAME);
|
X4OWriter<X4OLanguageModule> writer = driver.createWriter();
|
||||||
//X4OReader<X4OLanguageModule> reader = driver.createReader();
|
|
||||||
//reader.readResource("META-INF/test/test-lang.eld");
|
X4OLanguage language = driver.createLanguage(driver.getLanguageVersionDefault());
|
||||||
|
X4OLanguageModule mod = new DefaultX4OLanguageModule();
|
||||||
|
|
||||||
|
reader.addELBeanInstance(EldModuleLoader.EL_PARENT_LANGUAGE_CONFIGURATION, language.getLanguageConfiguration());
|
||||||
|
reader.addELBeanInstance(EldModuleLoader.EL_PARENT_LANGUAGE, language);
|
||||||
|
reader.addELBeanInstance(EldModuleLoader.EL_PARENT_ELEMENT_LANGUAGE_MODULE, mod);
|
||||||
|
|
||||||
|
X4OLanguageModule modNew = reader.readResource("META-INF/test/test-lang.eld");
|
||||||
|
|
||||||
|
//int binds = mod.getElementBindingHandlers().size();
|
||||||
|
//System.out.println(binds);
|
||||||
|
|
||||||
|
String output = writer.writeString(mod);
|
||||||
|
assertNotNull(output);
|
||||||
|
|
||||||
|
// TODO; fix element config+event to new interface + reserse for writing.
|
||||||
|
|
||||||
|
//System.out.println(output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,7 @@
|
||||||
</eld:classBindingHandler>
|
</eld:classBindingHandler>
|
||||||
</eld:elementInterface>
|
</eld:elementInterface>
|
||||||
|
|
||||||
|
<!-- TODO: fix writer, run EldParserTest
|
||||||
<eld:configuratorGlobal bean.class="org.x4o.xml.test.element.TestElementConfigurator" id="testConfigGlobal">
|
<eld:configuratorGlobal bean.class="org.x4o.xml.test.element.TestElementConfigurator" id="testConfigGlobal">
|
||||||
<eld:description>Test the global element configurator.</eld:description>
|
<eld:description>Test the global element configurator.</eld:description>
|
||||||
</eld:configuratorGlobal>
|
</eld:configuratorGlobal>
|
||||||
|
@ -83,6 +84,7 @@
|
||||||
<eld:description>Test the global element attribute2 handler.</eld:description>
|
<eld:description>Test the global element attribute2 handler.</eld:description>
|
||||||
<eld:attributeHandlerNextAttribute attributeName="tt.attr1"/>
|
<eld:attributeHandlerNextAttribute attributeName="tt.attr1"/>
|
||||||
</eld:attributeHandler>
|
</eld:attributeHandler>
|
||||||
|
-->
|
||||||
|
|
||||||
<eld:namespace
|
<eld:namespace
|
||||||
uri="http://test.x4o.org/xml/ns/test-root"
|
uri="http://test.x4o.org/xml/ns/test-root"
|
||||||
|
@ -116,10 +118,12 @@
|
||||||
</eld:element>
|
</eld:element>
|
||||||
|
|
||||||
<eld:element tag="configBean" objectClass="org.x4o.xml.test.models.TestBean">
|
<eld:element tag="configBean" objectClass="org.x4o.xml.test.models.TestBean">
|
||||||
|
<!-- TODO: fix writer
|
||||||
<eld:configurator bean.class="org.x4o.xml.test.element.TestElementConfigurator" id="testConfig1">
|
<eld:configurator bean.class="org.x4o.xml.test.element.TestElementConfigurator" id="testConfig1">
|
||||||
<eld:description>The test element config.</eld:description>
|
<eld:description>The test element config.</eld:description>
|
||||||
</eld:configurator>
|
</eld:configurator>
|
||||||
<eld:configurator bean.class="org.x4o.xml.test.element.TestElementConfigurator" id="testConfig2"/>
|
<eld:configurator bean.class="org.x4o.xml.test.element.TestElementConfigurator" id="testConfig2"/>
|
||||||
|
-->
|
||||||
<eld:elementSkipPhase name="runAttributesPhase"/>
|
<eld:elementSkipPhase name="runAttributesPhase"/>
|
||||||
<eld:elementSkipPhase name="transformPhase"/>
|
<eld:elementSkipPhase name="transformPhase"/>
|
||||||
</eld:element>
|
</eld:element>
|
||||||
|
|
|
@ -101,6 +101,7 @@ public class ApiDocContentWriter extends ContentWriterHtml {
|
||||||
List<String> navList = new ArrayList<String>(10);
|
List<String> navList = new ArrayList<String>(10);
|
||||||
Map<String,String> navLinks = new HashMap<String,String>(10);
|
Map<String,String> navLinks = new HashMap<String,String>(10);
|
||||||
Map<String,String> navNames = new HashMap<String,String>(10);
|
Map<String,String> navNames = new HashMap<String,String>(10);
|
||||||
|
Map<String,String> navTitles = new HashMap<String,String>(10);
|
||||||
String pathPrefix;
|
String pathPrefix;
|
||||||
String prev;
|
String prev;
|
||||||
String next;
|
String next;
|
||||||
|
@ -169,15 +170,19 @@ public class ApiDocContentWriter extends ContentWriterHtml {
|
||||||
for (String navKey:conf.navList) {
|
for (String navKey:conf.navList) {
|
||||||
String navName = conf.navNames.get(navKey);
|
String navName = conf.navNames.get(navKey);
|
||||||
String navLink = conf.navLinks.get(navKey);
|
String navLink = conf.navLinks.get(navKey);
|
||||||
|
String navTitle = conf.navTitles.get(navKey);
|
||||||
String selectedCss = null;
|
String selectedCss = null;
|
||||||
if (navKey.equals(conf.navSelected)) {
|
if (navKey.equals(conf.navSelected)) {
|
||||||
selectedCss = "navBarCell1Rev";
|
selectedCss = "navBarCell1Rev";
|
||||||
navLink = null; // disables link
|
navLink = null; // disables link
|
||||||
}
|
}
|
||||||
|
if (navTitle==null) {
|
||||||
|
navTitle = navName;
|
||||||
|
}
|
||||||
if (navLink==null) {
|
if (navLink==null) {
|
||||||
printTagCharacters(Tag.li, navName, selectedCss);
|
printTagCharacters(Tag.li, navName, selectedCss);
|
||||||
} else {
|
} else {
|
||||||
docNavBarListItemHref(pathPrefix+navLink,navName,selectedCss);
|
docNavBarListItemHref(pathPrefix+navLink,navName,navTitle,selectedCss,null,null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
endElement("", "ul", "");
|
endElement("", "ul", "");
|
||||||
|
@ -203,12 +208,12 @@ public class ApiDocContentWriter extends ContentWriterHtml {
|
||||||
if (conf.prev==null) {
|
if (conf.prev==null) {
|
||||||
printTagCharacters(Tag.li, "Prev");
|
printTagCharacters(Tag.li, "Prev");
|
||||||
} else {
|
} else {
|
||||||
docNavBarListItemHref(pathPrefix+conf.prev,"Prev",null,"strong",null);
|
docNavBarListItemHref(pathPrefix+conf.prev,"Prev","Previous Item",null,"strong",null);
|
||||||
}
|
}
|
||||||
if (conf.next==null) {
|
if (conf.next==null) {
|
||||||
printTagCharacters(Tag.li, "Next");
|
printTagCharacters(Tag.li, "Next");
|
||||||
} else {
|
} else {
|
||||||
docNavBarListItemHref(pathPrefix+conf.next,"Next",null,"strong",null);
|
docNavBarListItemHref(pathPrefix+conf.next,"Next","Next Item",null,"strong",null);
|
||||||
}
|
}
|
||||||
printTagEnd(Tag.ul);
|
printTagEnd(Tag.ul);
|
||||||
if (conf.frame!=null) {
|
if (conf.frame!=null) {
|
||||||
|
@ -223,7 +228,7 @@ public class ApiDocContentWriter extends ContentWriterHtml {
|
||||||
}
|
}
|
||||||
if (conf.noFrameAllName!=null && conf.noFrameAllLink!=null) {
|
if (conf.noFrameAllName!=null && conf.noFrameAllLink!=null) {
|
||||||
printTagStart(Tag.ul,ApiDocContentCss.navList,"allclasses_"+barId);
|
printTagStart(Tag.ul,ApiDocContentCss.navList,"allclasses_"+barId);
|
||||||
docNavBarListItemHref(pathPrefix+conf.noFrameAllLink,conf.noFrameAllName,null,null,null);
|
docNavBarListItemHref(pathPrefix+conf.noFrameAllLink,conf.noFrameAllName,null,null,null,null);
|
||||||
printTagEnd(Tag.ul);
|
printTagEnd(Tag.ul);
|
||||||
printTagStart(Tag.div);
|
printTagStart(Tag.div);
|
||||||
if (isTop) {
|
if (isTop) {
|
||||||
|
@ -233,6 +238,7 @@ public class ApiDocContentWriter extends ContentWriterHtml {
|
||||||
}
|
}
|
||||||
printTagEnd(Tag.div);
|
printTagEnd(Tag.div);
|
||||||
}
|
}
|
||||||
|
|
||||||
String tabSpace = " | ";
|
String tabSpace = " | ";
|
||||||
boolean printLink = conf.linkConstructors || conf.linkFields || conf.linkMethods;
|
boolean printLink = conf.linkConstructors || conf.linkFields || conf.linkMethods;
|
||||||
if (printLink) {
|
if (printLink) {
|
||||||
|
@ -241,13 +247,13 @@ public class ApiDocContentWriter extends ContentWriterHtml {
|
||||||
printTagStart(Tag.li);charactersRaw("Summary: ");printTagEnd(Tag.li);
|
printTagStart(Tag.li);charactersRaw("Summary: ");printTagEnd(Tag.li);
|
||||||
//printTagText(Tag.li,"Nested | "); // TODO: Nested
|
//printTagText(Tag.li,"Nested | "); // TODO: Nested
|
||||||
if (conf.linkFields) {
|
if (conf.linkFields) {
|
||||||
docNavBarListItemHref("#field_summary",conf.linkFieldName,null,null,tabSpace);
|
docNavBarListItemHrefLinkSpace("#field_summary",conf.linkFieldName);
|
||||||
} else {
|
} else {
|
||||||
printTagCharacters(Tag.li,conf.linkFieldName);charactersRaw(tabSpace);
|
printTagCharacters(Tag.li,conf.linkFieldName);charactersRaw(tabSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conf.linkConstructors) {
|
if (conf.linkConstructors) {
|
||||||
docNavBarListItemHref("#constructor_summary",conf.linkConstructorName,null,null,tabSpace);
|
docNavBarListItemHrefLinkSpace("#constructor_summary",conf.linkConstructorName);
|
||||||
} else {
|
} else {
|
||||||
printTagCharacters(Tag.li,conf.linkConstructorName);charactersRaw(tabSpace);
|
printTagCharacters(Tag.li,conf.linkConstructorName);charactersRaw(tabSpace);
|
||||||
}
|
}
|
||||||
|
@ -262,12 +268,12 @@ public class ApiDocContentWriter extends ContentWriterHtml {
|
||||||
printTagStart(Tag.li);charactersRaw("Detail: ");printTagEnd(Tag.li);
|
printTagStart(Tag.li);charactersRaw("Detail: ");printTagEnd(Tag.li);
|
||||||
//printTagText(Tag.li,"Nested | ");
|
//printTagText(Tag.li,"Nested | ");
|
||||||
if (conf.linkFields) {
|
if (conf.linkFields) {
|
||||||
docNavBarListItemHref("#field_detail",conf.linkFieldName,null,null,tabSpace);
|
docNavBarListItemHrefLinkSpace("#field_detail",conf.linkFieldName);
|
||||||
} else {
|
} else {
|
||||||
printTagCharacters(Tag.li,conf.linkFieldName);charactersRaw(tabSpace);
|
printTagCharacters(Tag.li,conf.linkFieldName);charactersRaw(tabSpace);
|
||||||
}
|
}
|
||||||
if (conf.linkConstructors) {
|
if (conf.linkConstructors) {
|
||||||
docNavBarListItemHref("#constructor_detail",conf.linkConstructorName,null,null,tabSpace);
|
docNavBarListItemHrefLinkSpace("#constructor_detail",conf.linkConstructorName);
|
||||||
} else {
|
} else {
|
||||||
printTagCharacters(Tag.li,conf.linkConstructorName);charactersRaw(tabSpace);
|
printTagCharacters(Tag.li,conf.linkConstructorName);charactersRaw(tabSpace);
|
||||||
}
|
}
|
||||||
|
@ -286,12 +292,17 @@ public class ApiDocContentWriter extends ContentWriterHtml {
|
||||||
comment("========= END OF "+barComment+" NAVBAR =======");
|
comment("========= END OF "+barComment+" NAVBAR =======");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void docNavBarListItemHref(String href,String title,String cssClass) throws SAXException {
|
private void docNavBarListItemHrefLinkSpace(String href,String title) throws SAXException {
|
||||||
docNavBarListItemHref(href, title, cssClass, null, null);
|
String tabSpace = " | ";
|
||||||
|
docNavBarListItemHref(href, title, title, null, null, tabSpace);
|
||||||
}
|
}
|
||||||
private void docNavBarListItemHref(String href,String title,String cssClass,String spanCss,String linkSpace) throws SAXException {
|
|
||||||
|
private void docNavBarListItemHref(String href,String title, String cssClass) throws SAXException {
|
||||||
|
docNavBarListItemHref(href, title, title, cssClass, null, null);
|
||||||
|
}
|
||||||
|
private void docNavBarListItemHref(String href,String title,String text,String cssClass,String spanCss,String linkSpace) throws SAXException {
|
||||||
printTagStart(Tag.li,cssClass);
|
printTagStart(Tag.li,cssClass);
|
||||||
printHref(href,title,title,spanCss);
|
printHref(href,title,text,spanCss);
|
||||||
charactersRaw(linkSpace);
|
charactersRaw(linkSpace);
|
||||||
printTagEnd(Tag.li);
|
printTagEnd(Tag.li);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ package org.x4o.xml.eld.doc.api;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.x4o.xml.eld.doc.api.dom.ApiDoc;
|
import org.x4o.xml.eld.doc.api.dom.ApiDoc;
|
||||||
|
@ -56,11 +55,11 @@ public class ApiDocNodeWriterBean implements ApiDocNodeWriter {
|
||||||
|
|
||||||
public ApiDocNodeWriterBean(ApiDocNodeBody nodeBody,Object bean,String method,Class<?>...classes) {
|
public ApiDocNodeWriterBean(ApiDocNodeBody nodeBody,Object bean,String method,Class<?>...classes) {
|
||||||
this();
|
this();
|
||||||
this.nodeBody=nodeBody;
|
setNodeBody(nodeBody);
|
||||||
this.bean=bean;
|
setBean(bean);
|
||||||
this.method=method;
|
setMethod(method);
|
||||||
if (classes!=null && classes.length>0) {
|
for (Class<?> cl:classes) {
|
||||||
targetClasses.addAll(Arrays.asList(classes));
|
addtargetClass(cl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,10 +90,10 @@ public class ApiDocNodeWriterBean implements ApiDocNodeWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeNodeContent(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
public void writeNodeContent(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
||||||
Class<?> beanClass = bean.getClass();
|
Class<?> beanClass = getBean().getClass();
|
||||||
try {
|
try {
|
||||||
Method methodBean = beanClass.getMethod(method, new Class[]{ApiDocWriteEvent.class});
|
Method methodBean = beanClass.getMethod(getMethod(), new Class[]{ApiDocWriteEvent.class});
|
||||||
methodBean.invoke(bean, new Object[]{event});
|
methodBean.invoke(getBean(), new Object[]{event});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new SAXException(e);
|
throw new SAXException(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -244,6 +244,7 @@ public class ApiDocWriter {
|
||||||
if (concept.getParent()!=null && !concept.getParent().getId().equals(doc.getRootNode().getId())) {
|
if (concept.getParent()!=null && !concept.getParent().getId().equals(doc.getRootNode().getId())) {
|
||||||
ApiDocConcept conceptParent = concept.getParent();
|
ApiDocConcept conceptParent = concept.getParent();
|
||||||
conf.navLinks.put(conceptParent.getId(), ApiDocContentWriter.toSafeUri(pathClean)+prefix+"/index.html");
|
conf.navLinks.put(conceptParent.getId(), ApiDocContentWriter.toSafeUri(pathClean)+prefix+"/index.html");
|
||||||
|
conf.navTitles.put(conceptParent.getId(), conceptParent.getDescriptionName());
|
||||||
configActiveNavConceptLinks(conf,node,concept.getParent(),prefix+"/..");
|
configActiveNavConceptLinks(conf,node,concept.getParent(),prefix+"/..");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,11 +60,6 @@ public class ApiDoc {
|
||||||
treeNodeClassExcludes = new ArrayList<Class<?>>(5);
|
treeNodeClassExcludes = new ArrayList<Class<?>>(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApiDoc(ApiDocNode rootNode) {
|
|
||||||
this();
|
|
||||||
setRootNode(rootNode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkModel() throws NullPointerException,IllegalArgumentException {
|
public void checkModel() throws NullPointerException,IllegalArgumentException {
|
||||||
checkNull(name,"name");
|
checkNull(name,"name");
|
||||||
checkNull(description,"description");
|
checkNull(description,"description");
|
||||||
|
@ -79,16 +74,16 @@ public class ApiDoc {
|
||||||
throw new IllegalStateException("Can't work with empty nodeBodyWriters");
|
throw new IllegalStateException("Can't work with empty nodeBodyWriters");
|
||||||
}
|
}
|
||||||
if (frameNavOverviewPrintParent==null) {
|
if (frameNavOverviewPrintParent==null) {
|
||||||
frameNavOverviewPrintParent=false;
|
setFrameNavOverviewPrintParent(false);
|
||||||
}
|
}
|
||||||
if (frameNavPrintParent==null) {
|
if (frameNavPrintParent==null) {
|
||||||
frameNavPrintParent=false;
|
setFrameNavPrintParent(false);
|
||||||
}
|
}
|
||||||
if (frameNavPrintParentParent==null) {
|
if (frameNavPrintParentParent==null) {
|
||||||
frameNavPrintParentParent=false;
|
setFrameNavPrintParentParent(false);
|
||||||
}
|
}
|
||||||
if (frameNavPrintParentId==null) {
|
if (frameNavPrintParentId==null) {
|
||||||
frameNavPrintParentId=false;
|
setFrameNavPrintParentId(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue