Skip to content

Commit

Permalink
release v2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
SingingBush committed Jul 23, 2018
1 parent 8e69a16 commit 3548e6e
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 30 deletions.
21 changes: 19 additions & 2 deletions README.md
Expand Up @@ -18,20 +18,37 @@ Releases are available from Maven Central
<dependency>
<groupId>com.singingbush</groupId>
<artifactId>sdlang</artifactId>
<version>2.0.1</version>
<version>2.1.0</version>
</dependency>
```

### Usage

To parse an SDL file simply create an InputStreamReader and pass it into the constructor of Parser:

```Java
```java
final InputStream inputStream = new FileInputStream("c:\\data\\myfile.sdl");
final Reader inputStreamReader = new InputStreamReader(inputStream, "UTF-8");
final List<Tag> tags = new Parser(inputStreamReader).parse();
```

To write SDL from Java objects:

```java
final Tag tag = SDL.tag("thing")
.withNamespace("my")
.withComment("This text will precede the 'my:thing' when serialised")
.withValue(SDL.value('g'))
.withChild(SDL.tag("child")
.withComment("child tags can also have comments")
.withValues(SDL.value(ZonedDateTime.now()), SDL.value("some text"))
.build()
)
.withAttribute("flt", SDL.value(0.0f))
.withAttribute("lng", SDL.value(1_000L))
.build();
```

### Forked from [ikayzo/SDL](https://github.com/ikayzo/SDL):

This code was originally dumped in github in May 2011 with a single commit message stating that it was migrated from svn.
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -6,7 +6,7 @@

<groupId>com.singingbush</groupId>
<artifactId>sdlang</artifactId>
<version>2.0.2-SNAPSHOT</version>
<version>2.1.0</version>
<name>SDLang</name>
<description>Support for SDLang (Simple Declarative Language)</description>
<url>https://github.com/SingingBush/SDL</url>
Expand Down
26 changes: 13 additions & 13 deletions src/main/java/com/singingbush/sdl/SDL.java
Expand Up @@ -319,7 +319,7 @@ public static void validateIdentifier(String identifier) {
/**
* @param name must be a legal SDL identifier (see {@link SDL#validateIdentifier(String)})
* @return a {@link TagBuilder} which can be used to easily create a {@link Tag}
* @since 2.0.2
* @since 2.1.0
*/
public static TagBuilder tag(final String name) {
return new TagBuilder(name);
Expand All @@ -329,7 +329,7 @@ public static TagBuilder tag(final String name) {
* @param value text to be converted to SDL
* @param literal in SDLang multiline strings are supported
* @return an SDL string
* @since 2.0.2
* @since 2.1.0
*/
public static SdlValue<String> value(final String value, final boolean literal) {
return literal?
Expand All @@ -340,7 +340,7 @@ public static SdlValue<String> value(final String value, final boolean literal)
/**
* @param value text to be converted to SDL
* @return an SDL char
* @since 2.0.2
* @since 2.1.0
*/
public static SdlValue<Character> value(final char value) {
return new SdlValue<>(value, SdlType.CHARACTER);
Expand All @@ -349,7 +349,7 @@ public static SdlValue<Character> value(final char value) {
/**
* @param value text to be converted to SDL
* @return an SDL boolean
* @since 2.0.2
* @since 2.1.0
*/
public static SdlValue<Boolean> value(final boolean value) {
return new SdlValue<>(value, SdlType.BOOLEAN);
Expand All @@ -358,7 +358,7 @@ public static SdlValue<Boolean> value(final boolean value) {
/**
* @param value text to be converted to SDL
* @return an SDL long
* @since 2.0.2
* @since 2.1.0
*/
public static SdlValue<Long> value(final long value) {
return new SdlValue<>(value, SdlType.NUMBER);
Expand All @@ -367,7 +367,7 @@ public static SdlValue<Long> value(final long value) {
/**
* @param value text to be converted to SDL
* @return an SDL float
* @since 2.0.2
* @since 2.1.0
*/
public static SdlValue<Float> value(final float value) {
return new SdlValue<>(value, SdlType.NUMBER);
Expand All @@ -376,7 +376,7 @@ public static SdlValue<Float> value(final float value) {
/**
* @param value text to be converted to SDL
* @return an SDL double
* @since 2.0.2
* @since 2.1.0
*/
public static SdlValue<Double> value(final double value) {
return new SdlValue<>(value, SdlType.NUMBER);
Expand All @@ -385,7 +385,7 @@ public static SdlValue<Double> value(final double value) {
/**
* @param value text to be converted to SDL
* @return an SDL integer
* @since 2.0.2
* @since 2.1.0
*/
public static SdlValue<Integer> value(final int value) {
return new SdlValue<>(value, SdlType.NUMBER);
Expand All @@ -394,7 +394,7 @@ public static SdlValue<Integer> value(final int value) {
/**
* @param value text to be converted to SDL
* @return an SDL date
* @since 2.0.2
* @since 2.1.0
*/
public static SdlValue<LocalDate> value(final LocalDate value) {
return new SdlValue<>(value, SdlType.DATE);
Expand All @@ -403,7 +403,7 @@ public static SdlValue<LocalDate> value(final LocalDate value) {
/**
* @param value text to be converted to SDL
* @return an SDL datetime without timezone
* @since 2.0.2
* @since 2.1.0
*/
public static SdlValue<LocalDateTime> value(final LocalDateTime value) {
return new SdlValue<>(value, SdlType.DATETIME);
Expand All @@ -412,7 +412,7 @@ public static SdlValue<LocalDateTime> value(final LocalDateTime value) {
/**
* @param value text to be converted to SDL
* @return an SDL datetime with timezone
* @since 2.0.2
* @since 2.1.0
*/
public static SdlValue<ZonedDateTime> value(final ZonedDateTime value) {
return new SdlValue<>(value, SdlType.DATETIME);
Expand All @@ -421,7 +421,7 @@ public static SdlValue<ZonedDateTime> value(final ZonedDateTime value) {
/**
* @param value text to be converted to SDL
* @return an SDL timespan
* @since 2.0.2
* @since 2.1.0
*/
public static SdlValue<Duration> value(final Duration value) {
return new SdlValue<>(value, SdlType.DURATION);
Expand All @@ -430,7 +430,7 @@ public static SdlValue<Duration> value(final Duration value) {
/**
* @param value text to be converted to SDL
* @return an SDL binary
* @since 2.0.2
* @since 2.1.0
*/
public static SdlValue value(final byte[] value) {
return new SdlValue<>(value, SdlType.BINARY);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/singingbush/sdl/Tag.java
Expand Up @@ -354,7 +354,7 @@ public class Tag implements Serializable {
/**
* Creates an empty tag.
*
* @deprecated As of release 2.0.2, use {@link SDL#tag(String)} instead.
* @deprecated As of release 2.1.0, use {@link SDL#tag(String)} instead.
* This constructor will be made package-private in a future release
* @param name The name of this tag
* @throws IllegalArgumentException if the name is not a legal SDL
Expand All @@ -369,7 +369,7 @@ public Tag(String name) {
* Creates an empty tag in the given namespace. If the namespace is null
* it will be coerced to an empty String.
*
* @deprecated As of release 2.0.2, use {@link SDL#tag(String)} instead.
* @deprecated As of release 2.1.0, use {@link SDL#tag(String)} instead.
* This constructor will be made package-private in a future release
* @param namespace The namespace for this tag
* @param name The name of this tag
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/com/singingbush/sdl/TagBuilder.java
Expand Up @@ -11,7 +11,7 @@
/**
* @author Samael Bate (singingbush)
* created on 20/07/18
* @since 2.0.2
* @since 2.1.0
*/
public class TagBuilder {

Expand All @@ -24,7 +24,7 @@ public class TagBuilder {

/**
* @param name must be a legal SDL identifier (see {@link SDL#validateIdentifier(String)})
* @since 2.0.2
* @since 2.1.0
*/
TagBuilder(@NotNull final String name) {
this.name = name;
Expand All @@ -34,7 +34,7 @@ public class TagBuilder {
* In SDL you can optionally specify a namespace
* @param name must be a legal SDL identifier (see {@link SDL#validateIdentifier(String)})
* @return this TagBuilder
* @since 2.0.2
* @since 2.1.0
*/
@NotNull
public TagBuilder withNamespace(@NotNull final String name) {
Expand All @@ -46,7 +46,7 @@ public TagBuilder withNamespace(@NotNull final String name) {
*
* @param comment a single line of text that will precede the tag when serialised
* @return this TagBuilder
* @since 2.0.2
* @since 2.1.0
*/
public TagBuilder withComment(@NotNull final String comment) {
this.comment = comment;
Expand All @@ -57,7 +57,7 @@ public TagBuilder withComment(@NotNull final String comment) {
* In SDL you can optionally have one or more values
* @param value an SDL object, see {@link SdlValue}
* @return this TagBuilder
* @since 2.0.2
* @since 2.1.0
*/
@NotNull
public TagBuilder withValue(@NotNull final SdlValue value) {
Expand All @@ -69,7 +69,7 @@ public TagBuilder withValue(@NotNull final SdlValue value) {
* In SDL you can optionally have one or more values
* @param values multiple SDL objects, see {@link SdlValue}
* @return this TagBuilder
* @since 2.0.2
* @since 2.1.0
*/
@NotNull
public TagBuilder withValues(@NotNull final SdlValue... values) {
Expand All @@ -81,7 +81,7 @@ public TagBuilder withValues(@NotNull final SdlValue... values) {
* In SDL you can optionally have one or more values
* @param values multiple SDL objects, see {@link SdlValue}
* @return this TagBuilder
* @since 2.0.2
* @since 2.1.0
*/
@NotNull
public TagBuilder withValues(@NotNull final List<SdlValue> values) {
Expand All @@ -93,7 +93,7 @@ public TagBuilder withValues(@NotNull final List<SdlValue> values) {
* In SDL you can optionally have one or more children
* @param child a child {@link Tag} object
* @return this TagBuilder
* @since 2.0.2
* @since 2.1.0
*/
@NotNull
public TagBuilder withChild(@NotNull final Tag child) {
Expand All @@ -105,7 +105,7 @@ public TagBuilder withChild(@NotNull final Tag child) {
* In SDL you can optionally have one or more children
* @param children multiple child {@link Tag} objects
* @return this TagBuilder
* @since 2.0.2
* @since 2.1.0
*/
@NotNull
public TagBuilder withChildren(@NotNull final Tag... children) {
Expand All @@ -117,7 +117,7 @@ public TagBuilder withChildren(@NotNull final Tag... children) {
* In SDL you can optionally have one or more children
* @param children multiple child {@link Tag} objects
* @return this TagBuilder
* @since 2.0.2
* @since 2.1.0
*/
@NotNull
public TagBuilder withChildren(@NotNull final List<Tag> children) {
Expand All @@ -130,7 +130,7 @@ public TagBuilder withChildren(@NotNull final List<Tag> children) {
* @param key attribute key
* @param value attribute value
* @return this TagBuilder
* @since 2.0.2
* @since 2.1.0
*/
@NotNull
public TagBuilder withAttribute(@NotNull final String key, @NotNull final SdlValue value) {
Expand All @@ -142,7 +142,7 @@ public TagBuilder withAttribute(@NotNull final String key, @NotNull final SdlVal
* In SDL you can optionally have one or more attributes
* @param attributes multiple attributes
* @return this TagBuilder
* @since 2.0.2
* @since 2.1.0
*/
@NotNull
public TagBuilder withAttributes(@NotNull final Map<String, SdlValue> attributes) {
Expand Down

0 comments on commit 3548e6e

Please sign in to comment.