Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Created StAX reader and writer to read/write directly from JDOM Documents... #105

Merged
merged 13 commits into from

2 participants

@gburgett

Hi,

I've been working for fun on an embedded XML database using JDOM 2.x. I found that I needed to use JAXB to serialize a Pojo directly to an Element. Unfortunately there was no direct way to do this, so I created a SAX Reader and a SAX Writer to read and write directly to JDOM Document objects in memory. Using this I was able to marshal and unmarshal to JDOM documents very easily:

JAXBContext context = JAXBContext.newInstance(Baz.class);

Baz baz;
JDOMStreamReader instance = new JDOMStreamReader(doc);
 try{
      baz = (Baz)context.createUnmarshaller().unmarshal(instance);
 }
finally{
      instance.close();
}

I think this would be valuable to include in the JDOM API. This would provide more options to convert to and from JDOM documents.

Also, if you'd like to check out my embedded XML db, take a look at it here https://github.com/gburgett/XFlat

@gburgett gburgett Created SAX reader and writer to read/write directly from JDOM Docume…
…nts.

Signed-off-by: gburgett <gordon.burgett@gmail.com>
ac5f25a
@rolfl
Collaborator

Hi Gordon. I am looking through your code and I have some questions/comments. I will contact you directly though.

rolfl and others added some commits
@rolfl rolfl Move classes to separate package to make them part of coverage report…
… and also to make them self-contained. They may move again later.
c7c15fe
@rolfl rolfl Fix eclipse compile warnings 04a4886
@rolfl rolfl move tests to jaxb package and fix eclipse compile warnings too. ca90504
@rolfl rolfl Add tests for NamespaceContext with changes to the class to match spec.
Also change base storage from list to array.
359a998
@rolfl rolfl getPrefix should return null for not-in-scope namespace URIs f1c765a
@rolfl rolfl Build round-trip test case, and feed it in to StreamWriter using othe…
…r JDOM Classes as feed-back. This allows a direct test.

Get the StreamWriter to have some success on the round-trip, but not 100% yet
1f898d5
@rolfl rolfl Get Namespace support working. Fix bug in StAXStreamProcessor related…
… to setPrefix declaration in stream prior to calling writeStartElement(). Add new features to NamespaceStack.
4521c3b
@gburgett gburgett Added round-trip tests for JDOMStreamReader.java
Signed-off-by: gburgett <gordon.burgett@gmail.com>
660ae11
@rolfl rolfl Add mechanism to get number of attributes on an Element c67fdb2
@rolfl rolfl Add revised version of the JDOMStreamReader together with some implem…
…entation details for JDOM integration, and a round-trip test
9b019b1
@rolfl rolfl Merge branch 'stream_reader' of github.com:gburgett/jdom into stream_…
…reader

Conflicts:
	core/src/java/org/jdom2/jaxb/JDOMStreamReader.java
	test/src/java/org/jdom2/test/cases/output/TestStAXWriterReader.java
7bfd216
@rolfl rolfl Sort out failing test-case. Improve code namespace handling.
Remove enumeration for tracking state... it's easier with a simple boolean and some condition checks.
ba464a7
@rolfl rolfl merged commit 98bbbd5 into hunterhacker:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 2, 2013
  1. @gburgett

    Created SAX reader and writer to read/write directly from JDOM Docume…

    gburgett authored
    …nts.
    
    Signed-off-by: gburgett <gordon.burgett@gmail.com>
Commits on Jan 3, 2013
  1. @rolfl

    Move classes to separate package to make them part of coverage report…

    rolfl authored
    … and also to make them self-contained. They may move again later.
  2. @rolfl

    Fix eclipse compile warnings

    rolfl authored
  3. @rolfl
  4. @rolfl

    Add tests for NamespaceContext with changes to the class to match spec.

    rolfl authored
    Also change base storage from list to array.
Commits on Jan 4, 2013
  1. @rolfl
Commits on Jan 5, 2013
  1. @rolfl

    Build round-trip test case, and feed it in to StreamWriter using othe…

    rolfl authored
    …r JDOM Classes as feed-back. This allows a direct test.
    
    Get the StreamWriter to have some success on the round-trip, but not 100% yet
Commits on Jan 6, 2013
  1. @rolfl

    Get Namespace support working. Fix bug in StAXStreamProcessor related…

    rolfl authored
    … to setPrefix declaration in stream prior to calling writeStartElement(). Add new features to NamespaceStack.
Commits on Jan 7, 2013
  1. @gburgett

    Added round-trip tests for JDOMStreamReader.java

    gburgett authored
    Signed-off-by: gburgett <gordon.burgett@gmail.com>
  2. @rolfl
  3. @rolfl

    Add revised version of the JDOMStreamReader together with some implem…

    rolfl authored
    …entation details for JDOM integration, and a round-trip test
  4. @rolfl

    Merge branch 'stream_reader' of github.com:gburgett/jdom into stream_…

    rolfl authored
    …reader
    
    Conflicts:
    	core/src/java/org/jdom2/jaxb/JDOMStreamReader.java
    	test/src/java/org/jdom2/test/cases/output/TestStAXWriterReader.java
Commits on Jan 10, 2013
  1. @rolfl

    Sort out failing test-case. Improve code namespace handling.

    rolfl authored
    Remove enumeration for tracking state... it's easier with a simple boolean and some condition checks.
Something went wrong with that request. Please try again.