Made config keys shorter and renamed some more context to session.
This commit is contained in:
parent
e434c1dfe7
commit
931886030e
|
@ -27,14 +27,13 @@ import java.util.List;
|
|||
import org.x4o.xml.io.DefaultX4OReader;
|
||||
import org.x4o.xml.io.DefaultX4OWriter;
|
||||
import org.x4o.xml.io.X4OReader;
|
||||
import org.x4o.xml.io.X4OReaderContext;
|
||||
import org.x4o.xml.io.X4OReaderSession;
|
||||
import org.x4o.xml.io.X4OWriter;
|
||||
import org.x4o.xml.io.X4OWriterContext;
|
||||
import org.x4o.xml.io.X4OWriterSession;
|
||||
import org.x4o.xml.lang.X4OLanguageConfiguration;
|
||||
import org.x4o.xml.lang.X4OLanguage;
|
||||
import org.x4o.xml.lang.phase.X4OPhaseManager;
|
||||
import org.x4o.xml.lang.task.X4OLanguageTask;
|
||||
import org.x4o.xml.lang.task.X4OLanguageTaskExecutor;
|
||||
|
||||
/**
|
||||
* X4ODriver Is the x4o language driver to interact with xml.
|
||||
|
@ -84,18 +83,18 @@ public abstract class X4ODriver<T> {
|
|||
// =============== Reader
|
||||
|
||||
public X4OReader<T> createReader() {
|
||||
return createReaderContext();
|
||||
return createReaderSession();
|
||||
}
|
||||
|
||||
public X4OReader<T> createReader(String version) {
|
||||
return createReaderContext(version);
|
||||
return createReaderSession(version);
|
||||
}
|
||||
|
||||
public X4OReaderContext<T> createReaderContext() {
|
||||
return createReaderContext(getLanguageVersionDefault());
|
||||
public X4OReaderSession<T> createReaderSession() {
|
||||
return createReaderSession(getLanguageVersionDefault());
|
||||
}
|
||||
|
||||
public X4OReaderContext<T> createReaderContext(String version) {
|
||||
public X4OReaderSession<T> createReaderSession(String version) {
|
||||
return new DefaultX4OReader<T>(createLanguage(version));
|
||||
}
|
||||
|
||||
|
@ -104,18 +103,18 @@ public abstract class X4ODriver<T> {
|
|||
// =============== Writer
|
||||
|
||||
public X4OWriter<T> createWriter() {
|
||||
return createWriterContext();
|
||||
return createWriterSession();
|
||||
}
|
||||
|
||||
public X4OWriter<T> createWriter(String version) {
|
||||
return createWriterContext(version);
|
||||
return createWriterSession(version);
|
||||
}
|
||||
|
||||
public X4OWriterContext<T> createWriterContext() {
|
||||
return createWriterContext(getLanguageVersionDefault());
|
||||
public X4OWriterSession<T> createWriterSession() {
|
||||
return createWriterSession(getLanguageVersionDefault());
|
||||
}
|
||||
|
||||
public X4OWriterContext<T> createWriterContext(String version) {
|
||||
public X4OWriterSession<T> createWriterSession(String version) {
|
||||
return new DefaultX4OWriter<T>(createLanguage(version));
|
||||
}
|
||||
|
||||
|
@ -175,11 +174,4 @@ public abstract class X4ODriver<T> {
|
|||
final public List<X4OLanguageTask> getLanguageTasks() {
|
||||
return X4ODriverManager.getX4OLanguageTasks();
|
||||
}
|
||||
|
||||
public void t() {
|
||||
X4OLanguageTask t = null;
|
||||
//PropertyConfig conf = t.createTaskConfig();
|
||||
//X4OLanguageTaskExecutor exe = t.createTaskExecutor(conf);
|
||||
//exe.execute(language);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,14 +38,14 @@ import org.xml.sax.SAXException;
|
|||
* @version 1.0 Aug 11, 2005
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
abstract public class AbstractX4OReader<T> extends AbstractX4OReaderContext<T> implements X4OReader<T> {
|
||||
abstract public class AbstractX4OReader<T> extends AbstractX4OReaderSession<T> implements X4OReader<T> {
|
||||
|
||||
public AbstractX4OReader(X4OLanguage language) {
|
||||
super(language);
|
||||
}
|
||||
|
||||
public T read(InputStream input, String systemId, URL basePath) throws X4OConnectionException,SAXException,IOException {
|
||||
return (T)readContext(input, systemId, basePath).getRootElement().getElementObject();
|
||||
return (T)readSession(input, systemId, basePath).getRootElement().getElementObject();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -55,10 +55,10 @@ abstract public class AbstractX4OReader<T> extends AbstractX4OReaderContext<T> i
|
|||
* @throws X4OConnectionException Is thrown after x4o exception.
|
||||
* @throws SAXException Is thrown after sax xml exception.
|
||||
* @throws IOException Is thrown after io exception.
|
||||
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
* @see org.x4o.xml.io.X4OReaderSession#readSession(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
*/
|
||||
public T readFile(String fileName) throws X4OConnectionException,SAXException,IOException,FileNotFoundException {
|
||||
return (T)readFileContext(fileName).getRootElement().getElementObject();
|
||||
return (T)readFileSession(fileName).getRootElement().getElementObject();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,10 +68,10 @@ abstract public class AbstractX4OReader<T> extends AbstractX4OReaderContext<T> i
|
|||
* @throws X4OConnectionException Is thrown after x4o exception.
|
||||
* @throws SAXException Is thrown after sax xml exception.
|
||||
* @throws IOException Is thrown after io exception.
|
||||
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
* @see org.x4o.xml.io.X4OReaderSession#readSession(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
*/
|
||||
public T readFile(File file) throws X4OConnectionException,SAXException,IOException,FileNotFoundException {
|
||||
return (T)readFileContext(file).getRootElement().getElementObject();
|
||||
return (T)readFileSession(file).getRootElement().getElementObject();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -80,10 +80,10 @@ abstract public class AbstractX4OReader<T> extends AbstractX4OReaderContext<T> i
|
|||
* @throws X4OConnectionException Is thrown after x4o exception.
|
||||
* @throws SAXException Is thrown after sax xml exception.
|
||||
* @throws IOException Is thrown after io exception.
|
||||
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
* @see org.x4o.xml.io.X4OReaderSession#readSession(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
*/
|
||||
public T readResource(String resourceName) throws X4OConnectionException,SAXException,IOException {
|
||||
return (T)readResourceContext(resourceName).getRootElement().getElementObject();
|
||||
return (T)readResourceSession(resourceName).getRootElement().getElementObject();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -92,10 +92,10 @@ abstract public class AbstractX4OReader<T> extends AbstractX4OReaderContext<T> i
|
|||
* @throws X4OConnectionException Is thrown after x4o exception.
|
||||
* @throws SAXException Is thrown after sax xml exception.
|
||||
* @throws IOException Is thrown after io exception.
|
||||
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
* @see org.x4o.xml.io.X4OReaderSession#readSession(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
*/
|
||||
public T readString(String xmlString) throws X4OConnectionException,SAXException,IOException {
|
||||
return (T)readStringContext(xmlString).getRootElement().getElementObject();
|
||||
return (T)readStringSession(xmlString).getRootElement().getElementObject();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -104,9 +104,9 @@ abstract public class AbstractX4OReader<T> extends AbstractX4OReaderContext<T> i
|
|||
* @throws X4OConnectionException Is thrown after x4o exception.
|
||||
* @throws SAXException Is thrown after sax xml exception.
|
||||
* @throws IOException Is thrown after io exception.
|
||||
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
* @see org.x4o.xml.io.X4OReaderSession#readSession(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
*/
|
||||
public T readUrl(URL url) throws X4OConnectionException,SAXException,IOException {
|
||||
return (T)readUrlContext(url).getRootElement().getElementObject();
|
||||
return (T)readUrlSession(url).getRootElement().getElementObject();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,15 +36,14 @@ import org.x4o.xml.lang.X4OLanguageSession;
|
|||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* AbstractX4OContextReader
|
||||
|
||||
* AbstractX4OReaderSession
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Apr 6, 2013
|
||||
*/
|
||||
abstract public class AbstractX4OReaderContext<T> extends AbstractX4OConnection implements X4OReaderContext<T> {
|
||||
abstract public class AbstractX4OReaderSession<T> extends AbstractX4OConnection implements X4OReaderSession<T> {
|
||||
|
||||
public AbstractX4OReaderContext(X4OLanguage language) {
|
||||
public AbstractX4OReaderSession(X4OLanguage language) {
|
||||
super(language);
|
||||
}
|
||||
|
||||
|
@ -55,13 +54,13 @@ abstract public class AbstractX4OReaderContext<T> extends AbstractX4OConnection
|
|||
* @throws X4OConnectionException Is thrown after x4o exception.
|
||||
* @throws SAXException Is thrown after sax xml exception.
|
||||
* @throws IOException Is thrown after io exception.
|
||||
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
* @see org.x4o.xml.io.X4OReaderSession#readSession(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
*/
|
||||
public X4OLanguageSession readFileContext(String fileName) throws X4OConnectionException,SAXException,IOException,FileNotFoundException {
|
||||
public X4OLanguageSession readFileSession(String fileName) throws X4OConnectionException,SAXException,IOException,FileNotFoundException {
|
||||
if (fileName==null) {
|
||||
throw new NullPointerException("Can't convert null fileName to file object.");
|
||||
}
|
||||
return readFileContext(new File(fileName));
|
||||
return readFileSession(new File(fileName));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -71,9 +70,9 @@ abstract public class AbstractX4OReaderContext<T> extends AbstractX4OConnection
|
|||
* @throws X4OConnectionException Is thrown after x4o exception.
|
||||
* @throws SAXException Is thrown after sax xml exception.
|
||||
* @throws IOException Is thrown after io exception.
|
||||
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
* @see org.x4o.xml.io.X4OReaderSession#readSession(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
*/
|
||||
public X4OLanguageSession readFileContext(File file) throws X4OConnectionException,SAXException,IOException,FileNotFoundException {
|
||||
public X4OLanguageSession readFileSession(File file) throws X4OConnectionException,SAXException,IOException,FileNotFoundException {
|
||||
if (file==null) {
|
||||
throw new NullPointerException("Can't read null file.");
|
||||
}
|
||||
|
@ -86,7 +85,7 @@ abstract public class AbstractX4OReaderContext<T> extends AbstractX4OConnection
|
|||
URL basePath = new File(file.getAbsolutePath()).toURI().toURL();
|
||||
InputStream inputStream = new FileInputStream(file);
|
||||
try {
|
||||
return readContext(inputStream,file.getAbsolutePath(),basePath);
|
||||
return readSession(inputStream,file.getAbsolutePath(),basePath);
|
||||
} finally {
|
||||
inputStream.close();
|
||||
}
|
||||
|
@ -98,9 +97,9 @@ abstract public class AbstractX4OReaderContext<T> extends AbstractX4OConnection
|
|||
* @throws X4OConnectionException Is thrown after x4o exception.
|
||||
* @throws SAXException Is thrown after sax xml exception.
|
||||
* @throws IOException Is thrown after io exception.
|
||||
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
* @see org.x4o.xml.io.X4OReaderSession#readSession(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
*/
|
||||
public X4OLanguageSession readResourceContext(String resourceName) throws X4OConnectionException,SAXException,IOException {
|
||||
public X4OLanguageSession readResourceSession(String resourceName) throws X4OConnectionException,SAXException,IOException {
|
||||
if (resourceName==null) {
|
||||
throw new NullPointerException("Can't read null resourceName from classpath.");
|
||||
}
|
||||
|
@ -116,7 +115,7 @@ abstract public class AbstractX4OReaderContext<T> extends AbstractX4OConnection
|
|||
URL basePath = new URL(baseUrl);
|
||||
InputStream inputStream = X4OLanguageClassLoader.getResourceAsStream(resourceName);
|
||||
try {
|
||||
return readContext(inputStream,url.toExternalForm(),basePath);
|
||||
return readSession(inputStream,url.toExternalForm(),basePath);
|
||||
} finally {
|
||||
inputStream.close();
|
||||
}
|
||||
|
@ -128,15 +127,15 @@ abstract public class AbstractX4OReaderContext<T> extends AbstractX4OConnection
|
|||
* @throws X4OConnectionException Is thrown after x4o exception.
|
||||
* @throws SAXException Is thrown after sax xml exception.
|
||||
* @throws IOException Is thrown after io exception.
|
||||
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
* @see org.x4o.xml.io.X4OReaderSession#readSession(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
*/
|
||||
public X4OLanguageSession readStringContext(String xmlString) throws X4OConnectionException,SAXException,IOException {
|
||||
public X4OLanguageSession readStringSession(String xmlString) throws X4OConnectionException,SAXException,IOException {
|
||||
if (xmlString==null) {
|
||||
throw new NullPointerException("Can't read null xml string.");
|
||||
}
|
||||
URL basePath = new File(System.getProperty("user.dir")).toURI().toURL();
|
||||
String encoding = (String)getProperty(DefaultX4OReader.INPUT_ENCODING);
|
||||
return readContext(new ByteArrayInputStream(xmlString.getBytes(encoding)),"inline-xml",basePath);
|
||||
return readSession(new ByteArrayInputStream(xmlString.getBytes(encoding)),"inline-xml",basePath);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -145,13 +144,13 @@ abstract public class AbstractX4OReaderContext<T> extends AbstractX4OConnection
|
|||
* @throws X4OConnectionException Is thrown after x4o exception.
|
||||
* @throws SAXException Is thrown after sax xml exception.
|
||||
* @throws IOException Is thrown after io exception.
|
||||
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
* @see org.x4o.xml.io.X4OReaderSession#readSession(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
*/
|
||||
public X4OLanguageSession readUrlContext(URL url) throws X4OConnectionException,SAXException,IOException {
|
||||
public X4OLanguageSession readUrlSession(URL url) throws X4OConnectionException,SAXException,IOException {
|
||||
if (url==null) {
|
||||
throw new NullPointerException("Can't read null url.");
|
||||
}
|
||||
URL basePath = new URL(url.toExternalForm().substring(0,url.toExternalForm().length()-url.getFile().length()));
|
||||
return readContext(url.openStream(),url.toExternalForm(),basePath);
|
||||
return readSession(url.openStream(),url.toExternalForm(),basePath);
|
||||
}
|
||||
}
|
|
@ -38,7 +38,7 @@ import org.xml.sax.SAXException;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Apr 6, 2013
|
||||
*/
|
||||
public abstract class AbstractX4OWriter<T> extends AbstractX4OWriterContext<T> implements X4OWriter<T> {
|
||||
public abstract class AbstractX4OWriter<T> extends AbstractX4OWriterSession<T> implements X4OWriter<T> {
|
||||
|
||||
public AbstractX4OWriter(X4OLanguage language) {
|
||||
super(language);
|
||||
|
@ -63,18 +63,18 @@ public abstract class AbstractX4OWriter<T> extends AbstractX4OWriterContext<T> i
|
|||
}
|
||||
|
||||
public void write(T object,OutputStream output) throws X4OConnectionException,SAXException,IOException {
|
||||
writeContext(toObjectContext(object), output);
|
||||
writeSession(toObjectContext(object), output);
|
||||
}
|
||||
|
||||
public void writeFile(T object,String fileName) throws X4OConnectionException,SAXException,IOException,FileNotFoundException {
|
||||
writeFileContext(toObjectContext(object), fileName);
|
||||
writeFileSession(toObjectContext(object), fileName);
|
||||
}
|
||||
|
||||
public void writeFile(T object,File file) throws X4OConnectionException,SAXException,IOException,FileNotFoundException {
|
||||
writeFileContext(toObjectContext(object), file);
|
||||
writeFileSession(toObjectContext(object), file);
|
||||
}
|
||||
|
||||
public String writeString(T object) throws X4OConnectionException,SAXException,IOException,FileNotFoundException {
|
||||
return writeStringContext(toObjectContext(object));
|
||||
return writeStringSession(toObjectContext(object));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,39 +34,39 @@ import org.x4o.xml.lang.X4OLanguageSession;
|
|||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* AbstractX4OWriterContext.
|
||||
* AbstractX4OWriterSession.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Apr 6, 2013
|
||||
*/
|
||||
public abstract class AbstractX4OWriterContext<T> extends AbstractX4OConnection implements X4OWriterContext<T> {
|
||||
public abstract class AbstractX4OWriterSession<T> extends AbstractX4OConnection implements X4OWriterSession<T> {
|
||||
|
||||
public AbstractX4OWriterContext(X4OLanguage language) {
|
||||
public AbstractX4OWriterSession(X4OLanguage language) {
|
||||
super(language);
|
||||
}
|
||||
|
||||
public void writeFileContext(X4OLanguageSession context,String fileName) throws X4OConnectionException,SAXException,IOException {
|
||||
public void writeFileSession(X4OLanguageSession languageSession,String fileName) throws X4OConnectionException,SAXException,IOException {
|
||||
if (fileName==null) {
|
||||
throw new NullPointerException("Can't convert null fileName to file object.");
|
||||
}
|
||||
writeFileContext(context,new File(fileName));
|
||||
writeFileSession(languageSession,new File(fileName));
|
||||
}
|
||||
|
||||
public void writeFileContext(X4OLanguageSession context,File file) throws X4OConnectionException,SAXException,IOException {
|
||||
public void writeFileSession(X4OLanguageSession languageSession,File file) throws X4OConnectionException,SAXException,IOException {
|
||||
if (file==null) {
|
||||
throw new NullPointerException("Can't read null file.");
|
||||
}
|
||||
OutputStream outputStream = new FileOutputStream(file);
|
||||
try {
|
||||
writeContext(context,outputStream);
|
||||
writeSession(languageSession,outputStream);
|
||||
} finally {
|
||||
outputStream.close();
|
||||
}
|
||||
}
|
||||
|
||||
public String writeStringContext(X4OLanguageSession context) throws X4OConnectionException,SAXException,IOException {
|
||||
public String writeStringSession(X4OLanguageSession languageSession) throws X4OConnectionException,SAXException,IOException {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream(4096);
|
||||
writeContext(context, out);
|
||||
writeSession(languageSession, out);
|
||||
String encoding = (String)getProperty(ContentWriterXml.OUTPUT_ENCODING);
|
||||
return out.toString(encoding);
|
||||
}
|
|
@ -113,7 +113,7 @@ public class DefaultX4OReader<T> extends AbstractX4OReader<T> {
|
|||
return propertyConfig;
|
||||
}
|
||||
|
||||
public X4OLanguageSession readContext(InputStream input, String systemId, URL basePath) throws X4OConnectionException, SAXException, IOException {
|
||||
public X4OLanguageSession readSession(InputStream input, String systemId, URL basePath) throws X4OConnectionException, SAXException, IOException {
|
||||
setProperty(INPUT_STREAM, input);
|
||||
setProperty(INPUT_SYSTEM_ID, systemId);
|
||||
setProperty(INPUT_BASE_PATH, basePath);
|
||||
|
@ -247,7 +247,7 @@ public class DefaultX4OReader<T> extends AbstractX4OReader<T> {
|
|||
}
|
||||
}
|
||||
|
||||
public void releaseContext(X4OLanguageSession context) throws X4OPhaseException {
|
||||
public void releaseSession(X4OLanguageSession context) throws X4OPhaseException {
|
||||
if (context==null) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -98,9 +98,9 @@ public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.io.X4OWriterContext#writeContext(org.x4o.xml.lang.X4OLanguageSession, java.io.OutputStream)
|
||||
* @see org.x4o.xml.io.X4OWriterSession#writeSession(org.x4o.xml.lang.X4OLanguageSession, java.io.OutputStream)
|
||||
*/
|
||||
public void writeContext(X4OLanguageSession languageSession,OutputStream output) throws X4OConnectionException,SAXException,IOException {
|
||||
public void writeSession(X4OLanguageSession languageSession,OutputStream output) throws X4OConnectionException,SAXException,IOException {
|
||||
setProperty(OUTPUT_STREAM, output);
|
||||
addPhaseSkip(X4OPhase.WRITE_RELEASE);
|
||||
try {
|
||||
|
|
|
@ -61,7 +61,7 @@ public interface X4OReader<T> extends X4OConnection {
|
|||
* @throws X4OConnectionException Is thrown after x4o exception.
|
||||
* @throws SAXException Is thrown after sax xml exception.
|
||||
* @throws IOException Is thrown after io exception.
|
||||
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
* @see org.x4o.xml.io.X4OReaderSession#readSession(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
*/
|
||||
T readFile(String fileName) throws X4OConnectionException,SAXException,IOException,FileNotFoundException;
|
||||
|
||||
|
@ -72,7 +72,7 @@ public interface X4OReader<T> extends X4OConnection {
|
|||
* @throws X4OConnectionException Is thrown after x4o exception.
|
||||
* @throws SAXException Is thrown after sax xml exception.
|
||||
* @throws IOException Is thrown after io exception.
|
||||
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
* @see org.x4o.xml.io.X4OReaderSession#readSession(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
*/
|
||||
T readFile(File file) throws X4OConnectionException,SAXException,IOException,FileNotFoundException;
|
||||
|
||||
|
@ -82,7 +82,7 @@ public interface X4OReader<T> extends X4OConnection {
|
|||
* @throws X4OConnectionException Is thrown after x4o exception.
|
||||
* @throws SAXException Is thrown after sax xml exception.
|
||||
* @throws IOException Is thrown after io exception.
|
||||
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
* @see org.x4o.xml.io.X4OReaderSession#readSession(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
*/
|
||||
T readResource(String resourceName) throws X4OConnectionException,SAXException,IOException;
|
||||
|
||||
|
@ -92,7 +92,7 @@ public interface X4OReader<T> extends X4OConnection {
|
|||
* @throws X4OConnectionException Is thrown after x4o exception.
|
||||
* @throws SAXException Is thrown after sax xml exception.
|
||||
* @throws IOException Is thrown after io exception.
|
||||
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
* @see org.x4o.xml.io.X4OReaderSession#readSession(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
*/
|
||||
T readString(String xmlString) throws X4OConnectionException,SAXException,IOException;
|
||||
|
||||
|
@ -102,7 +102,7 @@ public interface X4OReader<T> extends X4OConnection {
|
|||
* @throws X4OConnectionException Is thrown after x4o exception.
|
||||
* @throws SAXException Is thrown after sax xml exception.
|
||||
* @throws IOException Is thrown after io exception.
|
||||
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
* @see org.x4o.xml.io.X4OReaderSession#readSession(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
*/
|
||||
T readUrl(URL url) throws X4OConnectionException,SAXException,IOException;
|
||||
}
|
||||
|
|
|
@ -33,14 +33,14 @@ import org.x4o.xml.lang.phase.X4OPhaseException;
|
|||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* X4OReaderContext is reader with language context.
|
||||
* X4OReaderSession is reader with language session.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Apr 6, 2013
|
||||
*/
|
||||
public interface X4OReaderContext<T> extends X4OReader<T> {
|
||||
public interface X4OReaderSession<T> extends X4OReader<T> {
|
||||
|
||||
void releaseContext(X4OLanguageSession context) throws X4OPhaseException;
|
||||
void releaseSession(X4OLanguageSession context) throws X4OPhaseException;
|
||||
|
||||
/**
|
||||
* Method to parse the xml data.
|
||||
|
@ -49,7 +49,7 @@ public interface X4OReaderContext<T> extends X4OReader<T> {
|
|||
* @throws SAXException Is thrown after sax xml exception.
|
||||
* @throws IOException Is thrown after io exception.
|
||||
*/
|
||||
X4OLanguageSession readContext(InputStream input,String systemId,URL basePath) throws X4OConnectionException,SAXException,IOException;
|
||||
X4OLanguageSession readSession(InputStream input,String systemId,URL basePath) throws X4OConnectionException,SAXException,IOException;
|
||||
|
||||
/**
|
||||
* Reads the file fileName and parses it as an InputStream.
|
||||
|
@ -58,9 +58,9 @@ public interface X4OReaderContext<T> extends X4OReader<T> {
|
|||
* @throws X4OConnectionException Is thrown after x4o exception.
|
||||
* @throws SAXException Is thrown after sax xml exception.
|
||||
* @throws IOException Is thrown after io exception.
|
||||
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
* @see org.x4o.xml.io.X4OReaderSession#readSession(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
*/
|
||||
X4OLanguageSession readFileContext(String fileName) throws X4OConnectionException,SAXException,IOException,FileNotFoundException;
|
||||
X4OLanguageSession readFileSession(String fileName) throws X4OConnectionException,SAXException,IOException,FileNotFoundException;
|
||||
|
||||
/**
|
||||
* Reads the file and parses it as an InputStream.
|
||||
|
@ -69,9 +69,9 @@ public interface X4OReaderContext<T> extends X4OReader<T> {
|
|||
* @throws X4OConnectionException Is thrown after x4o exception.
|
||||
* @throws SAXException Is thrown after sax xml exception.
|
||||
* @throws IOException Is thrown after io exception.
|
||||
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
* @see org.x4o.xml.io.X4OReaderSession#readSession(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
*/
|
||||
X4OLanguageSession readFileContext(File file) throws X4OConnectionException,SAXException,IOException,FileNotFoundException;
|
||||
X4OLanguageSession readFileSession(File file) throws X4OConnectionException,SAXException,IOException,FileNotFoundException;
|
||||
|
||||
/**
|
||||
* Parses an resource locaction.
|
||||
|
@ -79,27 +79,27 @@ public interface X4OReaderContext<T> extends X4OReader<T> {
|
|||
* @throws X4OConnectionException Is thrown after x4o exception.
|
||||
* @throws SAXException Is thrown after sax xml exception.
|
||||
* @throws IOException Is thrown after io exception.
|
||||
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
* @see org.x4o.xml.io.X4OReaderSession#readSession(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
*/
|
||||
X4OLanguageSession readResourceContext(String resourceName) throws X4OConnectionException,SAXException,IOException;
|
||||
X4OLanguageSession readResourceSession(String resourceName) throws X4OConnectionException,SAXException,IOException;
|
||||
|
||||
/**
|
||||
* Converts a String to a InputStream to is can me parsed by SAX.
|
||||
* Converts a String to a InputStream to is can be parsed by SAX.
|
||||
* @param xmlString The xml as String to parse.
|
||||
* @throws X4OConnectionException Is thrown after x4o exception.
|
||||
* @throws SAXException Is thrown after sax xml exception.
|
||||
* @throws IOException Is thrown after io exception.
|
||||
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
* @see org.x4o.xml.io.X4OReaderSession#readSession(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
*/
|
||||
X4OLanguageSession readStringContext(String xmlString) throws X4OConnectionException,SAXException,IOException;
|
||||
X4OLanguageSession readStringSession(String xmlString) throws X4OConnectionException,SAXException,IOException;
|
||||
|
||||
/**
|
||||
* Fetched the data direct from remote url to a InputStream to is can me parsed by SAX.
|
||||
* Fetched the data direct from remote url to a InputStream to is can be parsed by SAX.
|
||||
* @param url The url to parse.
|
||||
* @throws X4OConnectionException Is thrown after x4o exception.
|
||||
* @throws SAXException Is thrown after sax xml exception.
|
||||
* @throws IOException Is thrown after io exception.
|
||||
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
* @see org.x4o.xml.io.X4OReaderSession#readSession(java.io.InputStream,java.lang.String,java.net.URL)
|
||||
*/
|
||||
X4OLanguageSession readUrlContext(URL url) throws X4OConnectionException,SAXException,IOException;
|
||||
X4OLanguageSession readUrlSession(URL url) throws X4OConnectionException,SAXException,IOException;
|
||||
}
|
|
@ -30,18 +30,18 @@ import org.x4o.xml.lang.X4OLanguageSession;
|
|||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* X4OWriterContext is writer with language context.
|
||||
* X4OWriterSession is writer with language session.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Apr 6, 2013
|
||||
*/
|
||||
public interface X4OWriterContext<T> extends X4OWriter<T> {
|
||||
public interface X4OWriterSession<T> extends X4OWriter<T> {
|
||||
|
||||
void writeContext(X4OLanguageSession context,OutputStream out) throws X4OConnectionException,SAXException,IOException;
|
||||
void writeSession(X4OLanguageSession context,OutputStream out) throws X4OConnectionException,SAXException,IOException;
|
||||
|
||||
void writeFileContext(X4OLanguageSession context,String fileName) throws X4OConnectionException,SAXException,IOException;
|
||||
void writeFileSession(X4OLanguageSession context,String fileName) throws X4OConnectionException,SAXException,IOException;
|
||||
|
||||
void writeFileContext(X4OLanguageSession context,File file) throws X4OConnectionException,SAXException,IOException;
|
||||
void writeFileSession(X4OLanguageSession context,File file) throws X4OConnectionException,SAXException,IOException;
|
||||
|
||||
String writeStringContext(X4OLanguageSession context) throws X4OConnectionException,SAXException,IOException;
|
||||
String writeStringSession(X4OLanguageSession context) throws X4OConnectionException,SAXException,IOException;
|
||||
}
|
|
@ -23,7 +23,7 @@
|
|||
package org.x4o.xml.core;
|
||||
|
||||
import org.x4o.xml.io.DefaultX4OReader;
|
||||
import org.x4o.xml.io.X4OReaderContext;
|
||||
import org.x4o.xml.io.X4OReaderSession;
|
||||
import org.x4o.xml.lang.X4OLanguageSession;
|
||||
import org.x4o.xml.lang.phase.X4OPhase;
|
||||
import org.x4o.xml.test.TestDriver;
|
||||
|
@ -42,40 +42,40 @@ public class NamespaceUriTest extends TestCase {
|
|||
public void testSimpleUri() throws Exception {
|
||||
X4OLanguageSession context = null;
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
|
||||
X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
|
||||
reader.addPhaseSkip(X4OPhase.READ_RELEASE);
|
||||
try {
|
||||
context = reader.readResourceContext("tests/namespace/uri-simple.xml");
|
||||
context = reader.readResourceSession("tests/namespace/uri-simple.xml");
|
||||
assertEquals(true,context.getRootElement().getChilderen().size()==1);
|
||||
} finally {
|
||||
reader.releaseContext(context);
|
||||
reader.releaseSession(context);
|
||||
}
|
||||
}
|
||||
|
||||
public void testEmptyUri() throws Exception {
|
||||
X4OLanguageSession context = null;
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
|
||||
X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
|
||||
reader.addPhaseSkip(X4OPhase.READ_RELEASE);
|
||||
reader.setProperty(DefaultX4OReader.DOC_EMPTY_NAMESPACE_URI, "http://test.x4o.org/xml/ns/test-lang");
|
||||
try {
|
||||
context = reader.readResourceContext("tests/namespace/uri-empty.xml");
|
||||
context = reader.readResourceSession("tests/namespace/uri-empty.xml");
|
||||
assertEquals(true,context.getRootElement().getChilderen().size()==1);
|
||||
} finally {
|
||||
reader.releaseContext(context);
|
||||
reader.releaseSession(context);
|
||||
}
|
||||
}
|
||||
|
||||
public void testSchemaUri() throws Exception {
|
||||
X4OLanguageSession context = null;
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
|
||||
X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
|
||||
reader.addPhaseSkip(X4OPhase.READ_RELEASE);
|
||||
try {
|
||||
context = reader.readResourceContext("tests/namespace/uri-schema.xml");
|
||||
context = reader.readResourceSession("tests/namespace/uri-schema.xml");
|
||||
assertEquals(true,context.getRootElement().getChilderen().size()==1);
|
||||
} finally {
|
||||
reader.releaseContext(context);
|
||||
reader.releaseSession(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,12 +37,12 @@ import org.x4o.xml.test.models.TestObjectRoot;
|
|||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* X4OReaderContextTest.
|
||||
* X4OReaderSessionTest.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Apr 15, 2013
|
||||
*/
|
||||
public class X4OReaderContextTest extends TestCase {
|
||||
public class X4OReaderSessionTest extends TestCase {
|
||||
|
||||
private File copyResourceToTempFile() throws IOException {
|
||||
File tempFile = File.createTempFile("test-resource", ".xml");
|
||||
|
@ -60,9 +60,9 @@ public class X4OReaderContextTest extends TestCase {
|
|||
|
||||
public void testReadFileName() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
|
||||
X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
|
||||
File xmlFile = copyResourceToTempFile();
|
||||
X4OLanguageSession context = reader.readFileContext(xmlFile.getAbsolutePath());
|
||||
X4OLanguageSession context = reader.readFileSession(xmlFile.getAbsolutePath());
|
||||
TestObjectRoot root = (TestObjectRoot)context.getRootElement().getElementObject();
|
||||
assertNotNull(root);
|
||||
assertTrue(root.getTestBeans().size()>0);
|
||||
|
@ -72,11 +72,11 @@ public class X4OReaderContextTest extends TestCase {
|
|||
|
||||
public void testReadFileNameNull() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
|
||||
X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
|
||||
Exception e = null;
|
||||
try {
|
||||
String nullFileName = null;
|
||||
reader.readFileContext(nullFileName);
|
||||
reader.readFileSession(nullFileName);
|
||||
} catch (Exception catchE) {
|
||||
e = catchE;
|
||||
}
|
||||
|
@ -88,9 +88,9 @@ public class X4OReaderContextTest extends TestCase {
|
|||
|
||||
public void testReadFile() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
|
||||
X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
|
||||
File xmlFile = copyResourceToTempFile();
|
||||
X4OLanguageSession context = reader.readFileContext(xmlFile);
|
||||
X4OLanguageSession context = reader.readFileSession(xmlFile);
|
||||
TestObjectRoot root = (TestObjectRoot)context.getRootElement().getElementObject();
|
||||
assertNotNull(root);
|
||||
assertTrue(root.getTestBeans().size()>0);
|
||||
|
@ -100,11 +100,11 @@ public class X4OReaderContextTest extends TestCase {
|
|||
|
||||
public void testReadFileNull() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
|
||||
X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
|
||||
Exception e = null;
|
||||
try {
|
||||
File nullFile = null;
|
||||
reader.readFileContext(nullFile);
|
||||
reader.readFileSession(nullFile);
|
||||
} catch (Exception catchE) {
|
||||
e = catchE;
|
||||
}
|
||||
|
@ -116,12 +116,12 @@ public class X4OReaderContextTest extends TestCase {
|
|||
|
||||
public void testReadFileNotExists() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
|
||||
X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
|
||||
Exception e = null;
|
||||
try {
|
||||
File tempFile = File.createTempFile("test-file", ".xml");
|
||||
tempFile.delete();
|
||||
reader.readFileContext(tempFile);
|
||||
reader.readFileSession(tempFile);
|
||||
} catch (Exception catchE) {
|
||||
e = catchE;
|
||||
}
|
||||
|
@ -136,10 +136,10 @@ public class X4OReaderContextTest extends TestCase {
|
|||
return; // only test on real os.
|
||||
}
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
|
||||
X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
|
||||
Exception e = null;
|
||||
try {
|
||||
reader.readFileContext(new File("/etc/shadow"));
|
||||
reader.readFileSession(new File("/etc/shadow"));
|
||||
} catch (Exception catchE) {
|
||||
e = catchE;
|
||||
}
|
||||
|
@ -152,18 +152,18 @@ public class X4OReaderContextTest extends TestCase {
|
|||
|
||||
public void testReadResource() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
|
||||
X4OLanguageSession context = reader.readResourceContext("tests/attributes/test-bean.xml");
|
||||
X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
|
||||
X4OLanguageSession context = reader.readResourceSession("tests/attributes/test-bean.xml");
|
||||
TestObjectRoot root = (TestObjectRoot)context.getRootElement().getElementObject();
|
||||
assertNotNull(root);
|
||||
}
|
||||
|
||||
public void testReadResourceNull() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
|
||||
X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
|
||||
Exception e = null;
|
||||
try {
|
||||
reader.readResourceContext(null);
|
||||
reader.readResourceSession(null);
|
||||
} catch (Exception catchE) {
|
||||
e = catchE;
|
||||
}
|
||||
|
@ -175,8 +175,8 @@ public class X4OReaderContextTest extends TestCase {
|
|||
|
||||
public void testReadString() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
|
||||
X4OLanguageSession context = reader.readStringContext(
|
||||
X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
|
||||
X4OLanguageSession context = reader.readStringSession(
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+
|
||||
"<root:root xmlns:root=\"http://test.x4o.org/xml/ns/test-root\" xmlns=\"http://test.x4o.org/xml/ns/test-lang\">"+
|
||||
"<testBean privateIntegerTypeField=\"987654321\"/>"+
|
||||
|
@ -192,10 +192,10 @@ public class X4OReaderContextTest extends TestCase {
|
|||
|
||||
public void testReadStringNull() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
|
||||
X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
|
||||
Exception e = null;
|
||||
try {
|
||||
reader.readStringContext(null);
|
||||
reader.readStringSession(null);
|
||||
} catch (Exception catchE) {
|
||||
e = catchE;
|
||||
}
|
||||
|
@ -207,9 +207,9 @@ public class X4OReaderContextTest extends TestCase {
|
|||
|
||||
public void testReadUrl() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
|
||||
X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
|
||||
URL xmlUrl = Thread.currentThread().getContextClassLoader().getResource("tests/attributes/test-bean.xml");
|
||||
X4OLanguageSession context = reader.readUrlContext(xmlUrl);
|
||||
X4OLanguageSession context = reader.readUrlSession(xmlUrl);
|
||||
TestObjectRoot root = (TestObjectRoot)context.getRootElement().getElementObject();
|
||||
assertNotNull(root);
|
||||
assertTrue(root.getTestBeans().size()>0);
|
||||
|
@ -219,10 +219,10 @@ public class X4OReaderContextTest extends TestCase {
|
|||
|
||||
public void testReadUrlNull() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
|
||||
X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
|
||||
Exception e = null;
|
||||
try {
|
||||
reader.readUrlContext(null);
|
||||
reader.readUrlSession(null);
|
||||
} catch (Exception catchE) {
|
||||
e = catchE;
|
||||
}
|
|
@ -60,7 +60,7 @@ public class X4OReaderTest extends TestCase {
|
|||
|
||||
public void testReadInputStream() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
|
||||
X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
|
||||
File xmlFile = copyResourceToTempFile();
|
||||
URL basePath = new File(xmlFile.getAbsolutePath()).toURI().toURL();
|
||||
InputStream inputStream = new FileInputStream(xmlFile);
|
||||
|
|
|
@ -38,12 +38,12 @@ import org.xml.sax.SAXException;
|
|||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* X4OWriterContextTest.
|
||||
* X4OWriterSessionTest.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Apr 28, 2013
|
||||
*/
|
||||
public class X4OWriterContextTest extends TestCase {
|
||||
public class X4OWriterSessionTest extends TestCase {
|
||||
|
||||
private File createOutputFile() throws IOException {
|
||||
File outputFile = File.createTempFile("test-writer-context", ".xml");
|
||||
|
@ -72,9 +72,9 @@ public class X4OWriterContextTest extends TestCase {
|
|||
public void testWriteFile() throws Exception {
|
||||
File outputFile = createOutputFile();
|
||||
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||
X4OWriterContext<TestObjectRoot> writer = driver.createWriterContext();
|
||||
X4OWriterSession<TestObjectRoot> writer = driver.createWriterSession();
|
||||
|
||||
writer.writeFileContext(createContext(), outputFile);
|
||||
writer.writeFileSession(createContext(), outputFile);
|
||||
String text = X4OWriterTest.readFile( outputFile );
|
||||
outputFile.delete();
|
||||
|
||||
|
@ -86,11 +86,11 @@ public class X4OWriterContextTest extends TestCase {
|
|||
|
||||
public void testWriteFileNull() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
X4OWriterContext<TestObjectRoot> writer = driver.createWriterContext();
|
||||
X4OWriterSession<TestObjectRoot> writer = driver.createWriterSession();
|
||||
Exception e = null;
|
||||
File nullFile = null;
|
||||
try {
|
||||
writer.writeFileContext(createContext(), nullFile);
|
||||
writer.writeFileSession(createContext(), nullFile);
|
||||
} catch (Exception catchE) {
|
||||
e = catchE;
|
||||
}
|
||||
|
@ -103,9 +103,9 @@ public class X4OWriterContextTest extends TestCase {
|
|||
public void testWriteFileName() throws Exception {
|
||||
File outputFile = createOutputFile();
|
||||
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||
X4OWriterContext<TestObjectRoot> writer = driver.createWriterContext();
|
||||
X4OWriterSession<TestObjectRoot> writer = driver.createWriterSession();
|
||||
|
||||
writer.writeFileContext(createContext(), outputFile.getAbsolutePath());
|
||||
writer.writeFileSession(createContext(), outputFile.getAbsolutePath());
|
||||
String text = X4OWriterTest.readFile( outputFile );
|
||||
outputFile.delete();
|
||||
|
||||
|
@ -117,11 +117,11 @@ public class X4OWriterContextTest extends TestCase {
|
|||
|
||||
public void testWriteFileNameNull() throws Exception {
|
||||
TestDriver driver = TestDriver.getInstance();
|
||||
X4OWriterContext<TestObjectRoot> writer = driver.createWriterContext();
|
||||
X4OWriterSession<TestObjectRoot> writer = driver.createWriterSession();
|
||||
Exception e = null;
|
||||
String nullFileName = null;
|
||||
try {
|
||||
writer.writeFileContext(createContext(), nullFileName);
|
||||
writer.writeFileSession(createContext(), nullFileName);
|
||||
} catch (Exception catchE) {
|
||||
e = catchE;
|
||||
}
|
||||
|
@ -134,11 +134,11 @@ public class X4OWriterContextTest extends TestCase {
|
|||
public void testWriteStream() throws Exception {
|
||||
File outputFile = createOutputFile();
|
||||
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
|
||||
X4OWriterContext<TestObjectRoot> writer = driver.createWriterContext();
|
||||
X4OWriterSession<TestObjectRoot> writer = driver.createWriterSession();
|
||||
|
||||
OutputStream outputStream = new FileOutputStream(outputFile);
|
||||
try {
|
||||
writer.writeContext(createContext(),outputStream);
|
||||
writer.writeSession(createContext(),outputStream);
|
||||
} finally {
|
||||
outputStream.close();
|
||||
}
|
|
@ -235,7 +235,7 @@ public class ContentWriterXmlTest extends TestCase {
|
|||
String output = outputWriter.toString();
|
||||
assertNotNull(output);
|
||||
assertTrue(output.length()>0);
|
||||
assertTrue(output.equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!-- foobar -->"));
|
||||
assertTrue(output.equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!--foobar-->"));
|
||||
}
|
||||
|
||||
public void testCommentEscape() throws Exception {
|
||||
|
@ -243,7 +243,7 @@ public class ContentWriterXmlTest extends TestCase {
|
|||
ContentWriterXml writer = new ContentWriterXml(outputWriter);
|
||||
|
||||
writer.startDocument();
|
||||
writer.comment("<!--foobar-->");
|
||||
writer.comment("<!-- foobar -->");
|
||||
writer.endDocument();
|
||||
|
||||
String output = outputWriter.toString();
|
||||
|
|
|
@ -24,8 +24,8 @@ package org.x4o.xml.test;
|
|||
|
||||
import org.x4o.xml.X4ODriver;
|
||||
import org.x4o.xml.X4ODriverManager;
|
||||
import org.x4o.xml.io.X4OReaderContext;
|
||||
import org.x4o.xml.io.X4OWriterContext;
|
||||
import org.x4o.xml.io.X4OReaderSession;
|
||||
import org.x4o.xml.io.X4OWriterSession;
|
||||
import org.x4o.xml.test.models.TestObjectRoot;
|
||||
|
||||
public class TestDriver extends X4ODriver<TestObjectRoot> {
|
||||
|
|
|
@ -26,7 +26,7 @@ import javax.swing.JLabel;
|
|||
|
||||
import org.x4o.xml.element.DefaultElement;
|
||||
import org.x4o.xml.element.Element;
|
||||
import org.x4o.xml.io.X4OReaderContext;
|
||||
import org.x4o.xml.io.X4OReaderSession;
|
||||
import org.x4o.xml.lang.X4OLanguageSession;
|
||||
import org.x4o.xml.lang.phase.X4OPhase;
|
||||
|
||||
|
@ -43,16 +43,16 @@ public class ParentObjectTest extends TestCase {
|
|||
public void testParentElement() throws Exception {
|
||||
X4OLanguageSession context = null;
|
||||
MTestDriver driver = new MTestDriver();
|
||||
X4OReaderContext<?> reader = driver.createReaderContext();
|
||||
X4OReaderSession<?> reader = driver.createReaderSession();
|
||||
reader.addPhaseSkip(X4OPhase.READ_RELEASE);
|
||||
try {
|
||||
context = reader.readResourceContext("junit/test-meta-parent-element.xml");
|
||||
context = reader.readResourceSession("junit/test-meta-parent-element.xml");
|
||||
assertEquals(1,context.getRootElement().getChilderen().size());
|
||||
Element childElement = context.getRootElement().getChilderen().get(0);
|
||||
JLabel test = (JLabel)childElement.getElementObject();
|
||||
assertEquals("parentTest",test.getText());
|
||||
} finally {
|
||||
reader.releaseContext(context);
|
||||
reader.releaseSession(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ package org.x4o.xml.lang.meta;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import org.x4o.xml.io.X4OReaderContext;
|
||||
import org.x4o.xml.io.X4OReaderSession;
|
||||
import org.x4o.xml.lang.X4OLanguageSession;
|
||||
import org.x4o.xml.lang.phase.X4OPhase;
|
||||
|
||||
|
@ -41,42 +41,42 @@ public class ReferenceStoreTest extends TestCase {
|
|||
public void testMetaGeneric() throws Exception {
|
||||
X4OLanguageSession context = null;
|
||||
MTestDriver driver = new MTestDriver();
|
||||
X4OReaderContext<?> reader = driver.createReaderContext();
|
||||
X4OReaderSession<?> reader = driver.createReaderSession();
|
||||
reader.addPhaseSkip(X4OPhase.READ_RELEASE);
|
||||
try {
|
||||
context = reader.readResourceContext("junit/test-meta-generic.xml");
|
||||
context = reader.readResourceSession("junit/test-meta-generic.xml");
|
||||
assertEquals(Date.class.getName(),context.getRootElement().getChilderen().get(0).getElementObject().getClass().getName());
|
||||
} finally {
|
||||
reader.releaseContext(context);
|
||||
reader.releaseSession(context);
|
||||
}
|
||||
}
|
||||
|
||||
public void testLoadClass() throws Exception {
|
||||
X4OLanguageSession context = null;
|
||||
MTestDriver driver = new MTestDriver();
|
||||
X4OReaderContext<?> reader = driver.createReaderContext();
|
||||
X4OReaderSession<?> reader = driver.createReaderSession();
|
||||
reader.addPhaseSkip(X4OPhase.READ_RELEASE);
|
||||
try {
|
||||
context = reader.readResourceContext("junit/test-meta-reference.xml");
|
||||
context = reader.readResourceSession("junit/test-meta-reference.xml");
|
||||
assertEquals(Date.class.getName(),context.getRootElement().getChilderen().get(0).getElementObject().getClass().getName());
|
||||
} finally {
|
||||
reader.releaseContext(context);
|
||||
reader.releaseSession(context);
|
||||
}
|
||||
}
|
||||
|
||||
public void testStoreRef() throws Exception {
|
||||
X4OLanguageSession context = null;
|
||||
MTestDriver driver = new MTestDriver();
|
||||
X4OReaderContext<?> reader = driver.createReaderContext();
|
||||
X4OReaderSession<?> reader = driver.createReaderSession();
|
||||
reader.addPhaseSkip(X4OPhase.READ_RELEASE);
|
||||
try {
|
||||
context = reader.readResourceContext("junit/test-meta-reference.xml");
|
||||
context = reader.readResourceSession("junit/test-meta-reference.xml");
|
||||
assertEquals(Date.class.getName(),context.getRootElement().getChilderen().get(0).getElementObject().getClass().getName());
|
||||
assertEquals(Date.class.getName(),context.getRootElement().getChilderen().get(1).getElementObject().getClass().getName());
|
||||
assertEquals(Date.class.getName(),context.getRootElement().getChilderen().get(2).getElementObject().getClass().getName());
|
||||
assertEquals(Date.class.getName(),context.getRootElement().getChilderen().get(3).getElementObject().getClass().getName());
|
||||
} finally {
|
||||
reader.releaseContext(context);
|
||||
reader.releaseSession(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
<mkdir dir="${test.dir}/cel"/>
|
||||
<x4oTask languageName="cel" taskId="eld-doc">
|
||||
<x4oTaskProperty
|
||||
key="http://language.x4o.org/xml/properties/eld-doc/output/path"
|
||||
key="http://x4o.org/properties/eld-doc/output/path"
|
||||
value="${test.dir}/cel"
|
||||
/>
|
||||
</x4oTask>
|
||||
|
@ -47,7 +47,7 @@
|
|||
<mkdir dir="${test.dir}/cel-verbose"/>
|
||||
<x4oTask languageName="cel" taskId="eld-doc" verbose="true">
|
||||
<x4oTaskProperty
|
||||
key="http://language.x4o.org/xml/properties/eld-doc/output/path"
|
||||
key="http://x4o.org/properties/eld-doc/output/path"
|
||||
value="${test.dir}/cel-verbose"
|
||||
/>
|
||||
</x4oTask>
|
||||
|
@ -57,7 +57,7 @@
|
|||
<mkdir dir="${test.dir}/eld"/>
|
||||
<x4oTask languageName="eld" taskId="eld-doc">
|
||||
<x4oTaskProperty
|
||||
key="http://language.x4o.org/xml/properties/eld-doc/output/path"
|
||||
key="http://x4o.org/properties/eld-doc/output/path"
|
||||
value="${test.dir}/eld"
|
||||
/>
|
||||
</x4oTask>
|
||||
|
@ -67,24 +67,24 @@
|
|||
<mkdir dir="${test.dir}/eld-custom"/>
|
||||
<x4oTask languageName="eld" taskId="eld-doc">
|
||||
<x4oTaskProperty
|
||||
key="http://language.x4o.org/xml/properties/eld-doc/output/path"
|
||||
key="http://x4o.org/properties/eld-doc/output/path"
|
||||
value="${test.dir}/eld-custom"
|
||||
/>
|
||||
<x4oTaskProperty
|
||||
key="http://language.x4o.org/xml/properties/content/output/charTab"
|
||||
key="http://x4o.org/properties/content/output/charTab"
|
||||
value=" "
|
||||
/>
|
||||
<x4oTaskProperty
|
||||
key="http://language.x4o.org/xml/properties/eld-doc/meta/stylesheet-thema"
|
||||
key="http://x4o.org/properties/eld-doc/meta/stylesheet-thema"
|
||||
value="jdk6"
|
||||
/>
|
||||
<x4oTaskProperty
|
||||
key="http://language.x4o.org/xml/properties/eld-doc/javadoc/link"
|
||||
key="http://x4o.org/properties/eld-doc/javadoc/link"
|
||||
value="http://docs.oracle.com/javase/7/docs/api/"
|
||||
/>
|
||||
<!-- fixme map type property config
|
||||
<x4oTaskProperty
|
||||
key="http://language.x4o.org/xml/properties/eld-doc/javadoc/link-offline"
|
||||
key="http://x4o.org/properties/eld-doc/javadoc/link-offline"
|
||||
value="http://www.x4o.org/apidocs/,file:///home/willemc/devv/git/x4o/x4o-driver/target/apidocs"
|
||||
/>
|
||||
-->
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
<mkdir dir="${test.dir}/cel-full"/>
|
||||
<x4oTask languageName="cel" taskId="eld-xsd">
|
||||
<x4oTaskProperty
|
||||
key="http://language.x4o.org/xml/properties/eld-xsd/output/path"
|
||||
key="http://x4o.org/properties/eld-xsd/output/path"
|
||||
value="${test.dir}/cel-full"
|
||||
/>
|
||||
</x4oTask>
|
||||
|
@ -47,11 +47,11 @@
|
|||
<mkdir dir="${test.dir}/cel-single"/>
|
||||
<x4oTask languageName="cel" taskId="eld-xsd">
|
||||
<x4oTaskProperty
|
||||
key="http://language.x4o.org/xml/properties/eld-xsd/output/path"
|
||||
key="http://x4o.org/properties/eld-xsd/output/path"
|
||||
value="${test.dir}/cel-single"
|
||||
/>
|
||||
<x4oTaskProperty
|
||||
key="http://language.x4o.org/xml/properties/eld-xsd/filter/namespace"
|
||||
key="http://x4o.org/properties/eld-xsd/filter/namespace"
|
||||
value="http://cel.x4o.org/xml/ns/cel-core"
|
||||
/>
|
||||
</x4oTask>
|
||||
|
@ -61,11 +61,11 @@
|
|||
<mkdir dir="${test.dir}/cel-single-verbose"/>
|
||||
<x4oTask languageName="cel" taskId="eld-xsd" verbose="true">
|
||||
<x4oTaskProperty
|
||||
key="http://language.x4o.org/xml/properties/eld-xsd/output/path"
|
||||
key="http://x4o.org/properties/eld-xsd/output/path"
|
||||
value="${test.dir}/cel-single-verbose"
|
||||
/>
|
||||
<x4oTaskProperty
|
||||
key="http://language.x4o.org/xml/properties/eld-xsd/filter/namespace"
|
||||
key="http://x4o.org/properties/eld-xsd/filter/namespace"
|
||||
value="http://cel.x4o.org/xml/ns/cel-core"
|
||||
/>
|
||||
</x4oTask>
|
||||
|
|
|
@ -46,10 +46,11 @@
|
|||
<plugin>
|
||||
<artifactId>x4o-plugin-maven</artifactId>
|
||||
<configuration>
|
||||
<outputDirectory>target/jtest/test-plugin-conf-all</outputDirectory>
|
||||
<languages>
|
||||
<eld>1.0</eld>
|
||||
</languages>
|
||||
<languageName>cel</languageName>
|
||||
<taskId>eld-xsd</taskId>
|
||||
<taskPropertyValues>
|
||||
<taskPropertyValue>http://x4o.org/properties/eld-xsd/output/path=target/jtest/test-plugin-conf-all/cel</taskPropertyValue>
|
||||
</taskPropertyValues>
|
||||
<verbose>false</verbose>
|
||||
<failOnError>false</failOnError>
|
||||
</configuration>
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
<languageName>cel</languageName>
|
||||
<taskId>eld-xsd</taskId>
|
||||
<taskPropertyValues>
|
||||
<taskPropertyValue>http://language.x4o.org/xml/properties/eld-xsd/output/path=target/jtest/test-plugin-conf-lang/cel</taskPropertyValue>
|
||||
<taskPropertyValue>http://x4o.org/properties/eld-xsd/output/path=target/jtest/test-plugin-conf-lang/cel</taskPropertyValue>
|
||||
</taskPropertyValues>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
|
Loading…
Reference in a new issue