Skip to content

Commit

Permalink
avoid unnecessary conversion to OffsetDateTime in TextContent
Browse files Browse the repository at this point in the history
  • Loading branch information
clausnagel committed Mar 9, 2024
1 parent ea9d461 commit dee125e
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 84 deletions.
1 change: 1 addition & 0 deletions src/main/java/org/xmlobjects/annotation/XMLElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@
@Retention(value = RetentionPolicy.RUNTIME)
public @interface XMLElement {
String name();

String namespaceURI() default XMLConstants.NULL_NS_URI;
}
8 changes: 6 additions & 2 deletions src/main/java/org/xmlobjects/builder/ObjectBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
@IndexSubclasses
public interface ObjectBuilder<T> {
T createObject(QName name, Object parent) throws ObjectBuildException;
default void initializeObject(T object, QName name, Attributes attributes, XMLReader reader) throws ObjectBuildException, XMLReadException { }
default void buildChildObject(T object, QName name, Attributes attributes, XMLReader reader) throws ObjectBuildException, XMLReadException { }

default void initializeObject(T object, QName name, Attributes attributes, XMLReader reader) throws ObjectBuildException, XMLReadException {
}

default void buildChildObject(T object, QName name, Attributes attributes, XMLReader reader) throws ObjectBuildException, XMLReadException {
}
}
1 change: 1 addition & 0 deletions src/main/java/org/xmlobjects/model/Child.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

public interface Child {
Child getParent();

void setParent(Child parent);

default <T extends Child> T getParent(Class<T> type) {
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/org/xmlobjects/serializer/ObjectSerializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@

@IndexSubclasses
public interface ObjectSerializer<T> {
default Element createElement(T object, Namespaces namespaces) throws ObjectSerializeException { return null; }
default void initializeElement(Element element, T object, Namespaces namespaces, XMLWriter writer) throws ObjectSerializeException, XMLWriteException { }
default void writeChildElements(T object, Namespaces namespaces, XMLWriter writer) throws ObjectSerializeException, XMLWriteException { }
default Element createElement(T object, Namespaces namespaces) throws ObjectSerializeException {
return null;
}

default void initializeElement(Element element, T object, Namespaces namespaces, XMLWriter writer) throws ObjectSerializeException, XMLWriteException {
}

default void writeChildElements(T object, Namespaces namespaces, XMLWriter writer) throws ObjectSerializeException, XMLWriteException {
}
}
2 changes: 1 addition & 1 deletion src/main/java/org/xmlobjects/stream/BuildResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void ifDOMElement(Consumer<Element> action) {
}
}

public Element getDOMElement(){
public Element getDOMElement() {
return element;
}
}
2 changes: 1 addition & 1 deletion src/main/java/org/xmlobjects/stream/XMLWriterFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public XMLWriter createWriter(SAXWriter saxWriter) {
xmlWriter.setProperties(properties);
return xmlWriter;
}

public XMLWriter createWriter(ContentHandler contentHandler) {
XMLWriter xmlWriter = new XMLWriter(xmlObjects, new SAXOutputHandler(contentHandler));
xmlWriter.setProperties(properties);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/xmlobjects/util/Properties.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public boolean getAndCompare(String name, Object expectedValue) {

public <T> T getOrDefault(String name, Class<T> type, Supplier<T> supplier) {
T value = get(name, type);
return value != null ? value : supplier.get();
return value != null ? value : supplier.get();
}

public <T> T getOrSet(String name, Class<T> type, Supplier<T> supplier) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public int next() throws XMLStreamException {

@Override
public void require(int type, String namespaceURI, String localName) throws XMLStreamException {
reader.require(type,namespaceURI,localName);
reader.require(type, namespaceURI, localName);
}

@Override
Expand Down
Loading

0 comments on commit dee125e

Please sign in to comment.