Skip to content

Commit 2819976

Browse files
authored
Merge pull request #9 from cordisvictor/v1.4.3
v1.4.3: pending ExternalizableStrategy
2 parents 44e7dfe + 40ffbf3 commit 2819976

File tree

8 files changed

+255
-26
lines changed

8 files changed

+255
-26
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ EasyML
99
(http://sourceforge.net/projects/kxml/files/kxml2/2.3.0/kxml2-min-2.3.0.jar/download)
1010

1111

12+
!Release 1.4.3
13+
- feature: new n.s.e.m.j.i.ExternalizableStrategy offers support for the
14+
Java Externalizable protocol.
15+
- feature: new n.s.e.XMLReader.hasMore method.
16+
- feature: new n.s.e.m.j.u.BitSetStrategy available and included into the
17+
EasyML.Profile.Generic for more portable XML.
18+
- performance: n.s.e.m.j.i.SerializableStrategy prevent auto-boxing in
19+
object input and output streams.
20+
21+
1222
!Release 1.4.2
1323
- bugfix: n.s.e.m.j.i.SerializableStrategy GetFieldImpl readFields fix.
1424

easyml/src/net/sourceforge/easyml/EasyML.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import net.sourceforge.easyml.marshalling.java.net.URIStrategy;
4848
import net.sourceforge.easyml.marshalling.java.net.URLStrategy;
4949
import net.sourceforge.easyml.marshalling.java.util.ArrayListStrategy;
50+
import net.sourceforge.easyml.marshalling.java.util.BitSetStrategy;
5051
import net.sourceforge.easyml.marshalling.java.util.HashMapStrategy;
5152
import net.sourceforge.easyml.marshalling.java.util.HashSetStrategy;
5253
import net.sourceforge.easyml.marshalling.java.util.HashtableStrategy;
@@ -184,7 +185,7 @@ public void applyTo(XMLWriter writer) {
184185
* instances from scratch.
185186
*
186187
* @author Victor Cordis ( cordis.victor at gmail.com)
187-
* @version 1.3.5
188+
* @version 1.4.3
188189
* @see XMLReader
189190
* @see XMLWriter
190191
* @since 1.0
@@ -221,6 +222,7 @@ public void configure(XMLWriter writer) {
221222
simple.add(UUIDStrategy.INSTANCE);
222223
final XMLWriter.StrategyRegistry<CompositeStrategy> composite = writer.getCompositeStrategies();
223224
composite.add(ColorStrategy.INSTANCE);
225+
composite.add(BitSetStrategy.INSTANCE);
224226
composite.add(ArrayListStrategy.INSTANCE);
225227
composite.add(HashMapStrategy.INSTANCE);
226228
composite.add(HashSetStrategy.INSTANCE);
@@ -257,6 +259,7 @@ public void configure(XMLReader reader) {
257259
simple.put(UUIDStrategy.NAME, UUIDStrategy.INSTANCE);
258260
final Map<String, CompositeStrategy> composite = reader.getCompositeStrategies();
259261
composite.put(ColorStrategy.NAME, ColorStrategy.INSTANCE);
262+
composite.put(BitSetStrategy.NAME, BitSetStrategy.INSTANCE);
260263
composite.put(ArrayListStrategy.NAME, ArrayListStrategy.INSTANCE);
261264
composite.put(HashMapStrategy.NAME, HashMapStrategy.INSTANCE);
262265
composite.put(HashSetStrategy.NAME, HashSetStrategy.INSTANCE);
@@ -305,6 +308,7 @@ public void configure(XMLWriter writer) {
305308
composite.add(ArrayStrategy.INSTANCE);
306309
composite.add(ObjectStrategy.INSTANCE);
307310
composite.add(SerializableStrategy.INSTANCE);
311+
// composite.add(BitSetStrategy.INSTANCE);
308312
composite.add(ArrayListStrategy.INSTANCE);
309313
composite.add(HashMapStrategy.INSTANCE);
310314
composite.add(HashSetStrategy.INSTANCE);
@@ -357,6 +361,7 @@ public void configure(XMLReader reader) {
357361
composite.put(ObjectStrategy.NAME, ObjectStrategy.INSTANCE);
358362
composite.put(ObjectStrategyV1_3_4.NAME, ObjectStrategyV1_3_4.INSTANCE);
359363
// backwards compatibility.
364+
// composite.put(BitSetStrategy.NAME, BitSetStrategy.INSTANCE);
360365
composite.put(ArrayListStrategy.NAME, ArrayListStrategy.INSTANCE);
361366
composite.put(HashMapStrategy.NAME, HashMapStrategy.INSTANCE);
362367
composite.put(HashSetStrategy.NAME, HashSetStrategy.INSTANCE);

easyml/src/net/sourceforge/easyml/XMLReader.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
*
8181
* @author Victor Cordis ( cordis.victor at gmail.com)
8282
* @since 1.0
83-
* @version 1.4.0
83+
* @version 1.4.3
8484
*/
8585
public class XMLReader implements Closeable {
8686

@@ -775,6 +775,16 @@ public void alias(Field f, String alias) {
775775
f);
776776
}
777777

778+
/**
779+
* Returns {@code true} if there is more to be read from the current input
780+
* or {@code false} if the document end tag was reached.
781+
*
782+
* @return {@code true} if there are more objects to be read
783+
*/
784+
public boolean hasMore() {
785+
return !isRootEnd();
786+
}
787+
778788
/**
779789
* Reads a boolean from XML.
780790
*
@@ -1129,12 +1139,16 @@ private void ensureRootStartPos() {
11291139
}
11301140

11311141
private void ensureRootEndClear() {
1132-
if (this.driver.atElementEnd() && this.driver.elementName().equals(this.rootTag)) {
1142+
if (isRootEnd()) {
11331143
this.decoded.clear();
11341144
this.beforeRoot = true;
11351145
}
11361146
}
11371147

1148+
private boolean isRootEnd() {
1149+
return this.driver.atElementEnd() && this.driver.elementName().equals(this.rootTag);
1150+
}
1151+
11381152
/**
11391153
* Resets this instance, setting it to the new <code>reader</code>.
11401154
*

easyml/src/net/sourceforge/easyml/marshalling/java/io/SerializableStrategy.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
*
5555
* @author Victor Cordis ( cordis.victor at gmail.com)
5656
* @since 1.0
57-
* @version 1.4.2
57+
* @version 1.4.3
5858
*/
5959
public class SerializableStrategy extends AbstractStrategy<Serializable>
6060
implements CompositeStrategy<Serializable> {
@@ -481,7 +481,7 @@ public void useProtocolVersion(int version) throws IOException {
481481

482482
@Override
483483
public void write(int val) throws IOException {
484-
this.writer.write((byte) val);
484+
this.writer.writeByte((byte) val);
485485
}
486486

487487
@Override
@@ -496,12 +496,12 @@ public void write(byte[] buf, int off, int len) throws IOException {
496496

497497
@Override
498498
public void writeBoolean(boolean val) throws IOException {
499-
this.writer.write(val);
499+
this.writer.writeBoolean(val);
500500
}
501501

502502
@Override
503503
public void writeByte(int val) throws IOException {
504-
this.writer.write((byte) val);
504+
this.writer.writeByte((byte) val);
505505
}
506506

507507
@Override
@@ -511,7 +511,7 @@ public void writeBytes(String str) throws IOException {
511511

512512
@Override
513513
public void writeChar(int val) throws IOException {
514-
this.writer.write((char) val);
514+
this.writer.writeChar((char) val);
515515
}
516516

517517
@Override
@@ -523,7 +523,7 @@ public void writeChars(String str) throws IOException {
523523

524524
@Override
525525
public void writeDouble(double val) throws IOException {
526-
this.writer.write(val);
526+
this.writer.writeDouble(val);
527527
}
528528

529529
@Override
@@ -551,17 +551,17 @@ public void writeFields() throws IOException {
551551

552552
@Override
553553
public void writeFloat(float val) throws IOException {
554-
this.writer.write(val);
554+
this.writer.writeFloat(val);
555555
}
556556

557557
@Override
558558
public void writeInt(int val) throws IOException {
559-
this.writer.write(val);
559+
this.writer.writeInt(val);
560560
}
561561

562562
@Override
563563
public void writeLong(long val) throws IOException {
564-
this.writer.write(val);
564+
this.writer.writeLong(val);
565565
}
566566

567567
@Override
@@ -571,7 +571,7 @@ protected void writeObjectOverride(Object obj) throws IOException {
571571

572572
@Override
573573
public void writeShort(int val) throws IOException {
574-
this.writer.write((short) val);
574+
this.writer.writeShort((short) val);
575575
}
576576

577577
@Override
@@ -673,7 +673,7 @@ public void defaultReadObject() throws IOException, ClassNotFoundException {
673673

674674
@Override
675675
public int read() throws IOException {
676-
return (Integer) this.reader.read();
676+
return (int) this.reader.readByte();
677677
}
678678

679679
@Override
@@ -685,22 +685,22 @@ public int read(byte[] buf, int off, int len) throws IOException {
685685

686686
@Override
687687
public boolean readBoolean() throws IOException {
688-
return (Boolean) this.reader.read();
688+
return this.reader.readBoolean();
689689
}
690690

691691
@Override
692692
public byte readByte() throws IOException {
693-
return (Byte) this.reader.read();
693+
return this.reader.readByte();
694694
}
695695

696696
@Override
697697
public char readChar() throws IOException {
698-
return (Character) this.reader.read();
698+
return this.reader.readChar();
699699
}
700700

701701
@Override
702702
public double readDouble() throws IOException {
703-
return (Double) this.reader.read();
703+
return this.reader.readDouble();
704704
}
705705

706706
@Override
@@ -751,7 +751,7 @@ public GetField readFields() throws IOException, ClassNotFoundException {
751751

752752
@Override
753753
public float readFloat() throws IOException {
754-
return (Float) this.reader.read();
754+
return this.reader.readFloat();
755755
}
756756

757757
@Override
@@ -766,12 +766,12 @@ public void readFully(byte[] buf, int off, int len) throws IOException {
766766

767767
@Override
768768
public int readInt() throws IOException {
769-
return (Integer) this.reader.read();
769+
return this.reader.readInt();
770770
}
771771

772772
@Override
773773
public long readLong() throws IOException {
774-
return (Long) this.reader.read();
774+
return this.reader.readLong();
775775
}
776776

777777
@Override
@@ -781,7 +781,7 @@ protected Object readObjectOverride() throws IOException, ClassNotFoundException
781781

782782
@Override
783783
public short readShort() throws IOException {
784-
return (Short) this.reader.read();
784+
return this.reader.readShort();
785785
}
786786

787787
@Override
@@ -796,12 +796,12 @@ public Object readUnshared() throws IOException, ClassNotFoundException {
796796

797797
@Override
798798
public int readUnsignedByte() throws IOException {
799-
return (Integer) this.reader.read();
799+
return this.reader.readByte();
800800
}
801801

802802
@Override
803803
public int readUnsignedShort() throws IOException {
804-
return (Integer) this.reader.read();
804+
return this.reader.readShort();
805805
}
806806

807807
@Override

0 commit comments

Comments
 (0)