Made config keys shorter and renamed some more context to session.

This commit is contained in:
Willem Cazander 2013-08-31 12:13:18 +02:00
parent e434c1dfe7
commit 931886030e
22 changed files with 173 additions and 181 deletions

View file

@ -27,14 +27,13 @@ import java.util.List;
import org.x4o.xml.io.DefaultX4OReader; import org.x4o.xml.io.DefaultX4OReader;
import org.x4o.xml.io.DefaultX4OWriter; import org.x4o.xml.io.DefaultX4OWriter;
import org.x4o.xml.io.X4OReader; 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.X4OWriter;
import org.x4o.xml.io.X4OWriterContext; import org.x4o.xml.io.X4OWriterSession;
import org.x4o.xml.lang.X4OLanguageConfiguration; import org.x4o.xml.lang.X4OLanguageConfiguration;
import org.x4o.xml.lang.X4OLanguage; import org.x4o.xml.lang.X4OLanguage;
import org.x4o.xml.lang.phase.X4OPhaseManager; import org.x4o.xml.lang.phase.X4OPhaseManager;
import org.x4o.xml.lang.task.X4OLanguageTask; import org.x4o.xml.lang.task.X4OLanguageTask;
import org.x4o.xml.lang.task.X4OLanguageTaskExecutor;
/** /**
* X4ODriver Is the x4o language driver to interact with xml. * X4ODriver Is the x4o language driver to interact with xml.
@ -84,18 +83,18 @@ public abstract class X4ODriver<T> {
// =============== Reader // =============== Reader
public X4OReader<T> createReader() { public X4OReader<T> createReader() {
return createReaderContext(); return createReaderSession();
} }
public X4OReader<T> createReader(String version) { public X4OReader<T> createReader(String version) {
return createReaderContext(version); return createReaderSession(version);
} }
public X4OReaderContext<T> createReaderContext() { public X4OReaderSession<T> createReaderSession() {
return createReaderContext(getLanguageVersionDefault()); return createReaderSession(getLanguageVersionDefault());
} }
public X4OReaderContext<T> createReaderContext(String version) { public X4OReaderSession<T> createReaderSession(String version) {
return new DefaultX4OReader<T>(createLanguage(version)); return new DefaultX4OReader<T>(createLanguage(version));
} }
@ -104,18 +103,18 @@ public abstract class X4ODriver<T> {
// =============== Writer // =============== Writer
public X4OWriter<T> createWriter() { public X4OWriter<T> createWriter() {
return createWriterContext(); return createWriterSession();
} }
public X4OWriter<T> createWriter(String version) { public X4OWriter<T> createWriter(String version) {
return createWriterContext(version); return createWriterSession(version);
} }
public X4OWriterContext<T> createWriterContext() { public X4OWriterSession<T> createWriterSession() {
return createWriterContext(getLanguageVersionDefault()); return createWriterSession(getLanguageVersionDefault());
} }
public X4OWriterContext<T> createWriterContext(String version) { public X4OWriterSession<T> createWriterSession(String version) {
return new DefaultX4OWriter<T>(createLanguage(version)); return new DefaultX4OWriter<T>(createLanguage(version));
} }
@ -175,11 +174,4 @@ public abstract class X4ODriver<T> {
final public List<X4OLanguageTask> getLanguageTasks() { final public List<X4OLanguageTask> getLanguageTasks() {
return X4ODriverManager.getX4OLanguageTasks(); return X4ODriverManager.getX4OLanguageTasks();
} }
public void t() {
X4OLanguageTask t = null;
//PropertyConfig conf = t.createTaskConfig();
//X4OLanguageTaskExecutor exe = t.createTaskExecutor(conf);
//exe.execute(language);
}
} }

View file

@ -38,14 +38,14 @@ import org.xml.sax.SAXException;
* @version 1.0 Aug 11, 2005 * @version 1.0 Aug 11, 2005
*/ */
@SuppressWarnings("unchecked") @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) { public AbstractX4OReader(X4OLanguage language) {
super(language); super(language);
} }
public T read(InputStream input, String systemId, URL basePath) throws X4OConnectionException,SAXException,IOException { 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 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.
* @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 { 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 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.
* @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 { 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 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.
* @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 { 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 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.
* @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 { 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 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.
* @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 { public T readUrl(URL url) throws X4OConnectionException,SAXException,IOException {
return (T)readUrlContext(url).getRootElement().getElementObject(); return (T)readUrlSession(url).getRootElement().getElementObject();
} }
} }

View file

@ -36,15 +36,14 @@ import org.x4o.xml.lang.X4OLanguageSession;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
/** /**
* AbstractX4OContextReader * AbstractX4OReaderSession
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Apr 6, 2013 * @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); super(language);
} }
@ -55,13 +54,13 @@ abstract public class AbstractX4OReaderContext<T> extends AbstractX4OConnection
* @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.
* @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) { if (fileName==null) {
throw new NullPointerException("Can't convert null fileName to file object."); 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 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.
* @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) { if (file==null) {
throw new NullPointerException("Can't read null file."); 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(); URL basePath = new File(file.getAbsolutePath()).toURI().toURL();
InputStream inputStream = new FileInputStream(file); InputStream inputStream = new FileInputStream(file);
try { try {
return readContext(inputStream,file.getAbsolutePath(),basePath); return readSession(inputStream,file.getAbsolutePath(),basePath);
} finally { } finally {
inputStream.close(); inputStream.close();
} }
@ -98,9 +97,9 @@ abstract public class AbstractX4OReaderContext<T> extends AbstractX4OConnection
* @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.
* @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) { if (resourceName==null) {
throw new NullPointerException("Can't read null resourceName from classpath."); 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); URL basePath = new URL(baseUrl);
InputStream inputStream = X4OLanguageClassLoader.getResourceAsStream(resourceName); InputStream inputStream = X4OLanguageClassLoader.getResourceAsStream(resourceName);
try { try {
return readContext(inputStream,url.toExternalForm(),basePath); return readSession(inputStream,url.toExternalForm(),basePath);
} finally { } finally {
inputStream.close(); inputStream.close();
} }
@ -128,15 +127,15 @@ abstract public class AbstractX4OReaderContext<T> extends AbstractX4OConnection
* @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.
* @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) { if (xmlString==null) {
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();
String encoding = (String)getProperty(DefaultX4OReader.INPUT_ENCODING); 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 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.
* @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) { if (url==null) {
throw new NullPointerException("Can't read null url."); throw new NullPointerException("Can't read null url.");
} }
URL basePath = new URL(url.toExternalForm().substring(0,url.toExternalForm().length()-url.getFile().length())); 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);
} }
} }

View file

@ -38,7 +38,7 @@ import org.xml.sax.SAXException;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Apr 6, 2013 * @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) { public AbstractX4OWriter(X4OLanguage language) {
super(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 { 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 { 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 { 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 { public String writeString(T object) throws X4OConnectionException,SAXException,IOException,FileNotFoundException {
return writeStringContext(toObjectContext(object)); return writeStringSession(toObjectContext(object));
} }
} }

View file

@ -34,39 +34,39 @@ import org.x4o.xml.lang.X4OLanguageSession;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
/** /**
* AbstractX4OWriterContext. * AbstractX4OWriterSession.
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Apr 6, 2013 * @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); 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) { if (fileName==null) {
throw new NullPointerException("Can't convert null fileName to file object."); 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) { if (file==null) {
throw new NullPointerException("Can't read null file."); throw new NullPointerException("Can't read null file.");
} }
OutputStream outputStream = new FileOutputStream(file); OutputStream outputStream = new FileOutputStream(file);
try { try {
writeContext(context,outputStream); writeSession(languageSession,outputStream);
} finally { } finally {
outputStream.close(); 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); ByteArrayOutputStream out = new ByteArrayOutputStream(4096);
writeContext(context, out); writeSession(languageSession, out);
String encoding = (String)getProperty(ContentWriterXml.OUTPUT_ENCODING); String encoding = (String)getProperty(ContentWriterXml.OUTPUT_ENCODING);
return out.toString(encoding); return out.toString(encoding);
} }

View file

@ -113,7 +113,7 @@ public class DefaultX4OReader<T> extends AbstractX4OReader<T> {
return propertyConfig; 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_STREAM, input);
setProperty(INPUT_SYSTEM_ID, systemId); setProperty(INPUT_SYSTEM_ID, systemId);
setProperty(INPUT_BASE_PATH, basePath); 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) { if (context==null) {
return; return;
} }

View file

@ -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); setProperty(OUTPUT_STREAM, output);
addPhaseSkip(X4OPhase.WRITE_RELEASE); addPhaseSkip(X4OPhase.WRITE_RELEASE);
try { try {

View file

@ -61,7 +61,7 @@ public interface X4OReader<T> extends X4OConnection {
* @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.
* @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; 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 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.
* @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; 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 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.
* @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; 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 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.
* @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; 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 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.
* @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; T readUrl(URL url) throws X4OConnectionException,SAXException,IOException;
} }

View file

@ -33,14 +33,14 @@ import org.x4o.xml.lang.phase.X4OPhaseException;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
/** /**
* X4OReaderContext is reader with language context. * X4OReaderSession is reader with language session.
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Apr 6, 2013 * @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. * 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 SAXException Is thrown after sax xml exception.
* @throws IOException Is thrown after io 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. * 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 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.
* @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. * 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 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.
* @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. * Parses an resource locaction.
@ -79,27 +79,27 @@ public interface X4OReaderContext<T> extends X4OReader<T> {
* @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.
* @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. * @param xmlString The xml as String to parse.
* @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.
* @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. * @param url The url to parse.
* @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.
* @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;
} }

View file

@ -30,18 +30,18 @@ import org.x4o.xml.lang.X4OLanguageSession;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
/** /**
* X4OWriterContext is writer with language context. * X4OWriterSession is writer with language session.
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Apr 6, 2013 * @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;
} }

View file

@ -23,7 +23,7 @@
package org.x4o.xml.core; package org.x4o.xml.core;
import org.x4o.xml.io.DefaultX4OReader; 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.X4OLanguageSession;
import org.x4o.xml.lang.phase.X4OPhase; import org.x4o.xml.lang.phase.X4OPhase;
import org.x4o.xml.test.TestDriver; import org.x4o.xml.test.TestDriver;
@ -42,40 +42,40 @@ public class NamespaceUriTest extends TestCase {
public void testSimpleUri() throws Exception { public void testSimpleUri() throws Exception {
X4OLanguageSession context = null; X4OLanguageSession context = null;
TestDriver driver = TestDriver.getInstance(); TestDriver driver = TestDriver.getInstance();
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext(); X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
reader.addPhaseSkip(X4OPhase.READ_RELEASE); reader.addPhaseSkip(X4OPhase.READ_RELEASE);
try { try {
context = reader.readResourceContext("tests/namespace/uri-simple.xml"); context = reader.readResourceSession("tests/namespace/uri-simple.xml");
assertEquals(true,context.getRootElement().getChilderen().size()==1); assertEquals(true,context.getRootElement().getChilderen().size()==1);
} finally { } finally {
reader.releaseContext(context); reader.releaseSession(context);
} }
} }
public void testEmptyUri() throws Exception { public void testEmptyUri() throws Exception {
X4OLanguageSession context = null; X4OLanguageSession context = null;
TestDriver driver = TestDriver.getInstance(); TestDriver driver = TestDriver.getInstance();
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext(); X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
reader.addPhaseSkip(X4OPhase.READ_RELEASE); reader.addPhaseSkip(X4OPhase.READ_RELEASE);
reader.setProperty(DefaultX4OReader.DOC_EMPTY_NAMESPACE_URI, "http://test.x4o.org/xml/ns/test-lang"); reader.setProperty(DefaultX4OReader.DOC_EMPTY_NAMESPACE_URI, "http://test.x4o.org/xml/ns/test-lang");
try { try {
context = reader.readResourceContext("tests/namespace/uri-empty.xml"); context = reader.readResourceSession("tests/namespace/uri-empty.xml");
assertEquals(true,context.getRootElement().getChilderen().size()==1); assertEquals(true,context.getRootElement().getChilderen().size()==1);
} finally { } finally {
reader.releaseContext(context); reader.releaseSession(context);
} }
} }
public void testSchemaUri() throws Exception { public void testSchemaUri() throws Exception {
X4OLanguageSession context = null; X4OLanguageSession context = null;
TestDriver driver = TestDriver.getInstance(); TestDriver driver = TestDriver.getInstance();
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext(); X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
reader.addPhaseSkip(X4OPhase.READ_RELEASE); reader.addPhaseSkip(X4OPhase.READ_RELEASE);
try { try {
context = reader.readResourceContext("tests/namespace/uri-schema.xml"); context = reader.readResourceSession("tests/namespace/uri-schema.xml");
assertEquals(true,context.getRootElement().getChilderen().size()==1); assertEquals(true,context.getRootElement().getChilderen().size()==1);
} finally { } finally {
reader.releaseContext(context); reader.releaseSession(context);
} }
} }
} }

View file

@ -37,12 +37,12 @@ import org.x4o.xml.test.models.TestObjectRoot;
import junit.framework.TestCase; import junit.framework.TestCase;
/** /**
* X4OReaderContextTest. * X4OReaderSessionTest.
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Apr 15, 2013 * @version 1.0 Apr 15, 2013
*/ */
public class X4OReaderContextTest extends TestCase { public class X4OReaderSessionTest extends TestCase {
private File copyResourceToTempFile() throws IOException { private File copyResourceToTempFile() throws IOException {
File tempFile = File.createTempFile("test-resource", ".xml"); File tempFile = File.createTempFile("test-resource", ".xml");
@ -60,9 +60,9 @@ public class X4OReaderContextTest extends TestCase {
public void testReadFileName() throws Exception { public void testReadFileName() throws Exception {
TestDriver driver = TestDriver.getInstance(); TestDriver driver = TestDriver.getInstance();
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext(); X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
File xmlFile = copyResourceToTempFile(); File xmlFile = copyResourceToTempFile();
X4OLanguageSession context = reader.readFileContext(xmlFile.getAbsolutePath()); X4OLanguageSession context = reader.readFileSession(xmlFile.getAbsolutePath());
TestObjectRoot root = (TestObjectRoot)context.getRootElement().getElementObject(); TestObjectRoot root = (TestObjectRoot)context.getRootElement().getElementObject();
assertNotNull(root); assertNotNull(root);
assertTrue(root.getTestBeans().size()>0); assertTrue(root.getTestBeans().size()>0);
@ -72,11 +72,11 @@ public class X4OReaderContextTest extends TestCase {
public void testReadFileNameNull() throws Exception { public void testReadFileNameNull() throws Exception {
TestDriver driver = TestDriver.getInstance(); TestDriver driver = TestDriver.getInstance();
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext(); X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
Exception e = null; Exception e = null;
try { try {
String nullFileName = null; String nullFileName = null;
reader.readFileContext(nullFileName); reader.readFileSession(nullFileName);
} catch (Exception catchE) { } catch (Exception catchE) {
e = catchE; e = catchE;
} }
@ -88,9 +88,9 @@ public class X4OReaderContextTest extends TestCase {
public void testReadFile() throws Exception { public void testReadFile() throws Exception {
TestDriver driver = TestDriver.getInstance(); TestDriver driver = TestDriver.getInstance();
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext(); X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
File xmlFile = copyResourceToTempFile(); File xmlFile = copyResourceToTempFile();
X4OLanguageSession context = reader.readFileContext(xmlFile); X4OLanguageSession context = reader.readFileSession(xmlFile);
TestObjectRoot root = (TestObjectRoot)context.getRootElement().getElementObject(); TestObjectRoot root = (TestObjectRoot)context.getRootElement().getElementObject();
assertNotNull(root); assertNotNull(root);
assertTrue(root.getTestBeans().size()>0); assertTrue(root.getTestBeans().size()>0);
@ -100,11 +100,11 @@ public class X4OReaderContextTest extends TestCase {
public void testReadFileNull() throws Exception { public void testReadFileNull() throws Exception {
TestDriver driver = TestDriver.getInstance(); TestDriver driver = TestDriver.getInstance();
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext(); X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
Exception e = null; Exception e = null;
try { try {
File nullFile = null; File nullFile = null;
reader.readFileContext(nullFile); reader.readFileSession(nullFile);
} catch (Exception catchE) { } catch (Exception catchE) {
e = catchE; e = catchE;
} }
@ -116,12 +116,12 @@ public class X4OReaderContextTest extends TestCase {
public void testReadFileNotExists() throws Exception { public void testReadFileNotExists() throws Exception {
TestDriver driver = TestDriver.getInstance(); TestDriver driver = TestDriver.getInstance();
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext(); X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
Exception e = null; Exception e = null;
try { try {
File tempFile = File.createTempFile("test-file", ".xml"); File tempFile = File.createTempFile("test-file", ".xml");
tempFile.delete(); tempFile.delete();
reader.readFileContext(tempFile); reader.readFileSession(tempFile);
} catch (Exception catchE) { } catch (Exception catchE) {
e = catchE; e = catchE;
} }
@ -136,10 +136,10 @@ public class X4OReaderContextTest extends TestCase {
return; // only test on real os. return; // only test on real os.
} }
TestDriver driver = TestDriver.getInstance(); TestDriver driver = TestDriver.getInstance();
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext(); X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
Exception e = null; Exception e = null;
try { try {
reader.readFileContext(new File("/etc/shadow")); reader.readFileSession(new File("/etc/shadow"));
} catch (Exception catchE) { } catch (Exception catchE) {
e = catchE; e = catchE;
} }
@ -152,18 +152,18 @@ public class X4OReaderContextTest extends TestCase {
public void testReadResource() throws Exception { public void testReadResource() throws Exception {
TestDriver driver = TestDriver.getInstance(); TestDriver driver = TestDriver.getInstance();
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext(); X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
X4OLanguageSession context = reader.readResourceContext("tests/attributes/test-bean.xml"); X4OLanguageSession context = reader.readResourceSession("tests/attributes/test-bean.xml");
TestObjectRoot root = (TestObjectRoot)context.getRootElement().getElementObject(); TestObjectRoot root = (TestObjectRoot)context.getRootElement().getElementObject();
assertNotNull(root); assertNotNull(root);
} }
public void testReadResourceNull() throws Exception { public void testReadResourceNull() throws Exception {
TestDriver driver = TestDriver.getInstance(); TestDriver driver = TestDriver.getInstance();
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext(); X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
Exception e = null; Exception e = null;
try { try {
reader.readResourceContext(null); reader.readResourceSession(null);
} catch (Exception catchE) { } catch (Exception catchE) {
e = catchE; e = catchE;
} }
@ -175,8 +175,8 @@ public class X4OReaderContextTest extends TestCase {
public void testReadString() throws Exception { public void testReadString() throws Exception {
TestDriver driver = TestDriver.getInstance(); TestDriver driver = TestDriver.getInstance();
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext(); X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
X4OLanguageSession context = reader.readStringContext( X4OLanguageSession context = reader.readStringSession(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+ "<?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\">"+ "<root:root xmlns:root=\"http://test.x4o.org/xml/ns/test-root\" xmlns=\"http://test.x4o.org/xml/ns/test-lang\">"+
"<testBean privateIntegerTypeField=\"987654321\"/>"+ "<testBean privateIntegerTypeField=\"987654321\"/>"+
@ -192,10 +192,10 @@ public class X4OReaderContextTest extends TestCase {
public void testReadStringNull() throws Exception { public void testReadStringNull() throws Exception {
TestDriver driver = TestDriver.getInstance(); TestDriver driver = TestDriver.getInstance();
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext(); X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
Exception e = null; Exception e = null;
try { try {
reader.readStringContext(null); reader.readStringSession(null);
} catch (Exception catchE) { } catch (Exception catchE) {
e = catchE; e = catchE;
} }
@ -207,9 +207,9 @@ public class X4OReaderContextTest extends TestCase {
public void testReadUrl() throws Exception { public void testReadUrl() throws Exception {
TestDriver driver = TestDriver.getInstance(); 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"); 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(); TestObjectRoot root = (TestObjectRoot)context.getRootElement().getElementObject();
assertNotNull(root); assertNotNull(root);
assertTrue(root.getTestBeans().size()>0); assertTrue(root.getTestBeans().size()>0);
@ -219,10 +219,10 @@ public class X4OReaderContextTest extends TestCase {
public void testReadUrlNull() throws Exception { public void testReadUrlNull() throws Exception {
TestDriver driver = TestDriver.getInstance(); TestDriver driver = TestDriver.getInstance();
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext(); X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
Exception e = null; Exception e = null;
try { try {
reader.readUrlContext(null); reader.readUrlSession(null);
} catch (Exception catchE) { } catch (Exception catchE) {
e = catchE; e = catchE;
} }

View file

@ -60,7 +60,7 @@ public class X4OReaderTest extends TestCase {
public void testReadInputStream() throws Exception { public void testReadInputStream() throws Exception {
TestDriver driver = TestDriver.getInstance(); TestDriver driver = TestDriver.getInstance();
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext(); X4OReaderSession<TestObjectRoot> reader = driver.createReaderSession();
File xmlFile = copyResourceToTempFile(); File xmlFile = copyResourceToTempFile();
URL basePath = new File(xmlFile.getAbsolutePath()).toURI().toURL(); URL basePath = new File(xmlFile.getAbsolutePath()).toURI().toURL();
InputStream inputStream = new FileInputStream(xmlFile); InputStream inputStream = new FileInputStream(xmlFile);

View file

@ -38,12 +38,12 @@ import org.xml.sax.SAXException;
import junit.framework.TestCase; import junit.framework.TestCase;
/** /**
* X4OWriterContextTest. * X4OWriterSessionTest.
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Apr 28, 2013 * @version 1.0 Apr 28, 2013
*/ */
public class X4OWriterContextTest extends TestCase { public class X4OWriterSessionTest extends TestCase {
private File createOutputFile() throws IOException { private File createOutputFile() throws IOException {
File outputFile = File.createTempFile("test-writer-context", ".xml"); File outputFile = File.createTempFile("test-writer-context", ".xml");
@ -72,9 +72,9 @@ public class X4OWriterContextTest extends TestCase {
public void testWriteFile() throws Exception { public void testWriteFile() throws Exception {
File outputFile = createOutputFile(); File outputFile = createOutputFile();
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance(); 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 ); String text = X4OWriterTest.readFile( outputFile );
outputFile.delete(); outputFile.delete();
@ -86,11 +86,11 @@ public class X4OWriterContextTest extends TestCase {
public void testWriteFileNull() throws Exception { public void testWriteFileNull() throws Exception {
TestDriver driver = TestDriver.getInstance(); TestDriver driver = TestDriver.getInstance();
X4OWriterContext<TestObjectRoot> writer = driver.createWriterContext(); X4OWriterSession<TestObjectRoot> writer = driver.createWriterSession();
Exception e = null; Exception e = null;
File nullFile = null; File nullFile = null;
try { try {
writer.writeFileContext(createContext(), nullFile); writer.writeFileSession(createContext(), nullFile);
} catch (Exception catchE) { } catch (Exception catchE) {
e = catchE; e = catchE;
} }
@ -103,9 +103,9 @@ public class X4OWriterContextTest extends TestCase {
public void testWriteFileName() throws Exception { public void testWriteFileName() throws Exception {
File outputFile = createOutputFile(); File outputFile = createOutputFile();
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance(); 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 ); String text = X4OWriterTest.readFile( outputFile );
outputFile.delete(); outputFile.delete();
@ -117,11 +117,11 @@ public class X4OWriterContextTest extends TestCase {
public void testWriteFileNameNull() throws Exception { public void testWriteFileNameNull() throws Exception {
TestDriver driver = TestDriver.getInstance(); TestDriver driver = TestDriver.getInstance();
X4OWriterContext<TestObjectRoot> writer = driver.createWriterContext(); X4OWriterSession<TestObjectRoot> writer = driver.createWriterSession();
Exception e = null; Exception e = null;
String nullFileName = null; String nullFileName = null;
try { try {
writer.writeFileContext(createContext(), nullFileName); writer.writeFileSession(createContext(), nullFileName);
} catch (Exception catchE) { } catch (Exception catchE) {
e = catchE; e = catchE;
} }
@ -134,11 +134,11 @@ public class X4OWriterContextTest extends TestCase {
public void testWriteStream() throws Exception { public void testWriteStream() throws Exception {
File outputFile = createOutputFile(); File outputFile = createOutputFile();
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance(); X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
X4OWriterContext<TestObjectRoot> writer = driver.createWriterContext(); X4OWriterSession<TestObjectRoot> writer = driver.createWriterSession();
OutputStream outputStream = new FileOutputStream(outputFile); OutputStream outputStream = new FileOutputStream(outputFile);
try { try {
writer.writeContext(createContext(),outputStream); writer.writeSession(createContext(),outputStream);
} finally { } finally {
outputStream.close(); outputStream.close();
} }

View file

@ -235,7 +235,7 @@ public class ContentWriterXmlTest extends TestCase {
String output = outputWriter.toString(); String output = outputWriter.toString();
assertNotNull(output); assertNotNull(output);
assertTrue(output.length()>0); 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 { public void testCommentEscape() throws Exception {
@ -243,7 +243,7 @@ public class ContentWriterXmlTest extends TestCase {
ContentWriterXml writer = new ContentWriterXml(outputWriter); ContentWriterXml writer = new ContentWriterXml(outputWriter);
writer.startDocument(); writer.startDocument();
writer.comment("<!--foobar-->"); writer.comment("<!-- foobar -->");
writer.endDocument(); writer.endDocument();
String output = outputWriter.toString(); String output = outputWriter.toString();

View file

@ -24,8 +24,8 @@ package org.x4o.xml.test;
import org.x4o.xml.X4ODriver; import org.x4o.xml.X4ODriver;
import org.x4o.xml.X4ODriverManager; import org.x4o.xml.X4ODriverManager;
import org.x4o.xml.io.X4OReaderContext; import org.x4o.xml.io.X4OReaderSession;
import org.x4o.xml.io.X4OWriterContext; import org.x4o.xml.io.X4OWriterSession;
import org.x4o.xml.test.models.TestObjectRoot; import org.x4o.xml.test.models.TestObjectRoot;
public class TestDriver extends X4ODriver<TestObjectRoot> { public class TestDriver extends X4ODriver<TestObjectRoot> {

View file

@ -26,7 +26,7 @@ import javax.swing.JLabel;
import org.x4o.xml.element.DefaultElement; import org.x4o.xml.element.DefaultElement;
import org.x4o.xml.element.Element; 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.X4OLanguageSession;
import org.x4o.xml.lang.phase.X4OPhase; import org.x4o.xml.lang.phase.X4OPhase;
@ -43,16 +43,16 @@ public class ParentObjectTest extends TestCase {
public void testParentElement() throws Exception { public void testParentElement() throws Exception {
X4OLanguageSession context = null; X4OLanguageSession context = null;
MTestDriver driver = new MTestDriver(); MTestDriver driver = new MTestDriver();
X4OReaderContext<?> reader = driver.createReaderContext(); X4OReaderSession<?> reader = driver.createReaderSession();
reader.addPhaseSkip(X4OPhase.READ_RELEASE); reader.addPhaseSkip(X4OPhase.READ_RELEASE);
try { 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()); assertEquals(1,context.getRootElement().getChilderen().size());
Element childElement = context.getRootElement().getChilderen().get(0); Element childElement = context.getRootElement().getChilderen().get(0);
JLabel test = (JLabel)childElement.getElementObject(); JLabel test = (JLabel)childElement.getElementObject();
assertEquals("parentTest",test.getText()); assertEquals("parentTest",test.getText());
} finally { } finally {
reader.releaseContext(context); reader.releaseSession(context);
} }
} }

View file

@ -24,7 +24,7 @@ package org.x4o.xml.lang.meta;
import java.util.Date; 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.X4OLanguageSession;
import org.x4o.xml.lang.phase.X4OPhase; import org.x4o.xml.lang.phase.X4OPhase;
@ -41,42 +41,42 @@ public class ReferenceStoreTest extends TestCase {
public void testMetaGeneric() throws Exception { public void testMetaGeneric() throws Exception {
X4OLanguageSession context = null; X4OLanguageSession context = null;
MTestDriver driver = new MTestDriver(); MTestDriver driver = new MTestDriver();
X4OReaderContext<?> reader = driver.createReaderContext(); X4OReaderSession<?> reader = driver.createReaderSession();
reader.addPhaseSkip(X4OPhase.READ_RELEASE); reader.addPhaseSkip(X4OPhase.READ_RELEASE);
try { 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()); assertEquals(Date.class.getName(),context.getRootElement().getChilderen().get(0).getElementObject().getClass().getName());
} finally { } finally {
reader.releaseContext(context); reader.releaseSession(context);
} }
} }
public void testLoadClass() throws Exception { public void testLoadClass() throws Exception {
X4OLanguageSession context = null; X4OLanguageSession context = null;
MTestDriver driver = new MTestDriver(); MTestDriver driver = new MTestDriver();
X4OReaderContext<?> reader = driver.createReaderContext(); X4OReaderSession<?> reader = driver.createReaderSession();
reader.addPhaseSkip(X4OPhase.READ_RELEASE); reader.addPhaseSkip(X4OPhase.READ_RELEASE);
try { 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(0).getElementObject().getClass().getName());
} finally { } finally {
reader.releaseContext(context); reader.releaseSession(context);
} }
} }
public void testStoreRef() throws Exception { public void testStoreRef() throws Exception {
X4OLanguageSession context = null; X4OLanguageSession context = null;
MTestDriver driver = new MTestDriver(); MTestDriver driver = new MTestDriver();
X4OReaderContext<?> reader = driver.createReaderContext(); X4OReaderSession<?> reader = driver.createReaderSession();
reader.addPhaseSkip(X4OPhase.READ_RELEASE); reader.addPhaseSkip(X4OPhase.READ_RELEASE);
try { 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(0).getElementObject().getClass().getName());
assertEquals(Date.class.getName(),context.getRootElement().getChilderen().get(1).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(2).getElementObject().getClass().getName());
assertEquals(Date.class.getName(),context.getRootElement().getChilderen().get(3).getElementObject().getClass().getName()); assertEquals(Date.class.getName(),context.getRootElement().getChilderen().get(3).getElementObject().getClass().getName());
} finally { } finally {
reader.releaseContext(context); reader.releaseSession(context);
} }
} }

View file

@ -37,7 +37,7 @@
<mkdir dir="${test.dir}/cel"/> <mkdir dir="${test.dir}/cel"/>
<x4oTask languageName="cel" taskId="eld-doc"> <x4oTask languageName="cel" taskId="eld-doc">
<x4oTaskProperty <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" value="${test.dir}/cel"
/> />
</x4oTask> </x4oTask>
@ -47,7 +47,7 @@
<mkdir dir="${test.dir}/cel-verbose"/> <mkdir dir="${test.dir}/cel-verbose"/>
<x4oTask languageName="cel" taskId="eld-doc" verbose="true"> <x4oTask languageName="cel" taskId="eld-doc" verbose="true">
<x4oTaskProperty <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" value="${test.dir}/cel-verbose"
/> />
</x4oTask> </x4oTask>
@ -57,7 +57,7 @@
<mkdir dir="${test.dir}/eld"/> <mkdir dir="${test.dir}/eld"/>
<x4oTask languageName="eld" taskId="eld-doc"> <x4oTask languageName="eld" taskId="eld-doc">
<x4oTaskProperty <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" value="${test.dir}/eld"
/> />
</x4oTask> </x4oTask>
@ -67,24 +67,24 @@
<mkdir dir="${test.dir}/eld-custom"/> <mkdir dir="${test.dir}/eld-custom"/>
<x4oTask languageName="eld" taskId="eld-doc"> <x4oTask languageName="eld" taskId="eld-doc">
<x4oTaskProperty <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" value="${test.dir}/eld-custom"
/> />
<x4oTaskProperty <x4oTaskProperty
key="http://language.x4o.org/xml/properties/content/output/charTab" key="http://x4o.org/properties/content/output/charTab"
value=" " value=" "
/> />
<x4oTaskProperty <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" value="jdk6"
/> />
<x4oTaskProperty <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/" value="http://docs.oracle.com/javase/7/docs/api/"
/> />
<!-- fixme map type property config <!-- fixme map type property config
<x4oTaskProperty <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" value="http://www.x4o.org/apidocs/,file:///home/willemc/devv/git/x4o/x4o-driver/target/apidocs"
/> />
--> -->

View file

@ -37,7 +37,7 @@
<mkdir dir="${test.dir}/cel-full"/> <mkdir dir="${test.dir}/cel-full"/>
<x4oTask languageName="cel" taskId="eld-xsd"> <x4oTask languageName="cel" taskId="eld-xsd">
<x4oTaskProperty <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" value="${test.dir}/cel-full"
/> />
</x4oTask> </x4oTask>
@ -47,11 +47,11 @@
<mkdir dir="${test.dir}/cel-single"/> <mkdir dir="${test.dir}/cel-single"/>
<x4oTask languageName="cel" taskId="eld-xsd"> <x4oTask languageName="cel" taskId="eld-xsd">
<x4oTaskProperty <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" value="${test.dir}/cel-single"
/> />
<x4oTaskProperty <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" value="http://cel.x4o.org/xml/ns/cel-core"
/> />
</x4oTask> </x4oTask>
@ -61,11 +61,11 @@
<mkdir dir="${test.dir}/cel-single-verbose"/> <mkdir dir="${test.dir}/cel-single-verbose"/>
<x4oTask languageName="cel" taskId="eld-xsd" verbose="true"> <x4oTask languageName="cel" taskId="eld-xsd" verbose="true">
<x4oTaskProperty <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" value="${test.dir}/cel-single-verbose"
/> />
<x4oTaskProperty <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" value="http://cel.x4o.org/xml/ns/cel-core"
/> />
</x4oTask> </x4oTask>

View file

@ -46,10 +46,11 @@
<plugin> <plugin>
<artifactId>x4o-plugin-maven</artifactId> <artifactId>x4o-plugin-maven</artifactId>
<configuration> <configuration>
<outputDirectory>target/jtest/test-plugin-conf-all</outputDirectory> <languageName>cel</languageName>
<languages> <taskId>eld-xsd</taskId>
<eld>1.0</eld> <taskPropertyValues>
</languages> <taskPropertyValue>http://x4o.org/properties/eld-xsd/output/path=target/jtest/test-plugin-conf-all/cel</taskPropertyValue>
</taskPropertyValues>
<verbose>false</verbose> <verbose>false</verbose>
<failOnError>false</failOnError> <failOnError>false</failOnError>
</configuration> </configuration>

View file

@ -49,7 +49,7 @@
<languageName>cel</languageName> <languageName>cel</languageName>
<taskId>eld-xsd</taskId> <taskId>eld-xsd</taskId>
<taskPropertyValues> <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> </taskPropertyValues>
</configuration> </configuration>
</plugin> </plugin>