-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JavaDoc fix, added missing deps to mgmt
- Loading branch information
Showing
2 changed files
with
97 additions
and
86 deletions.
There are no files selected for viewing
171 changes: 86 additions & 85 deletions
171
impl/yaml/src/main/java/io/github/mmm/marshall/yaml/impl/YamlFormat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,86 @@ | ||
/* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 | ||
* http://www.apache.org/licenses/LICENSE-2.0 */ | ||
package io.github.mmm.marshall.yaml.impl; | ||
|
||
import java.io.Reader; | ||
|
||
import io.github.mmm.marshall.MarshallingConfig; | ||
import io.github.mmm.marshall.StructuredFormat; | ||
import io.github.mmm.marshall.StructuredReader; | ||
import io.github.mmm.marshall.StructuredWriter; | ||
import io.github.mmm.marshall.spi.AbstractStructuredTextFormat; | ||
import io.github.mmm.scanner.CharReaderScanner; | ||
import io.github.mmm.scanner.CharSequenceScanner; | ||
|
||
/** | ||
* Implementation of {@link StructuredFormat} for JSON (JavaScript Object Notation). | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
public class YamlFormat extends AbstractStructuredTextFormat { | ||
|
||
private static final YamlFormat DEFAULT = of(MarshallingConfig.DEFAULTS); | ||
|
||
/** | ||
* The constructor. | ||
* | ||
* @param config the {@link MarshallingConfig}. | ||
* @see io.github.mmm.marshall.StructuredFormatFactory#create(String, MarshallingConfig) | ||
*/ | ||
public YamlFormat(MarshallingConfig config) { | ||
|
||
super(config); | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
|
||
return ID_YAML; | ||
} | ||
|
||
@Override | ||
public StructuredReader reader(Reader reader) { | ||
|
||
return new YamlReader(new CharReaderScanner(reader), this); | ||
} | ||
|
||
@Override | ||
public StructuredReader reader(String data) { | ||
|
||
return new YamlReader(new CharSequenceScanner(data), this); | ||
} | ||
|
||
@Override | ||
public StructuredWriter writer(Appendable writer) { | ||
|
||
return new YamlWriter(writer, this); | ||
} | ||
|
||
@Override | ||
public boolean isSupportingComments() { | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* @return the default instance of {@link YamlFormat}. | ||
*/ | ||
public static YamlFormat of() { | ||
|
||
return DEFAULT; | ||
} | ||
|
||
/** | ||
* @param config the {@link MarshallingConfig} for the JSON vendor implementation. | ||
* @return the new instance of {@link YamlFormat} with the given {@code config}. | ||
*/ | ||
public static YamlFormat of(MarshallingConfig config) { | ||
|
||
if (config == null) { | ||
return DEFAULT; | ||
} | ||
return new YamlFormat(config); | ||
} | ||
|
||
} | ||
/* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 | ||
* http://www.apache.org/licenses/LICENSE-2.0 */ | ||
package io.github.mmm.marshall.yaml.impl; | ||
|
||
import java.io.Reader; | ||
|
||
import io.github.mmm.marshall.MarshallingConfig; | ||
import io.github.mmm.marshall.StructuredFormat; | ||
import io.github.mmm.marshall.StructuredReader; | ||
import io.github.mmm.marshall.StructuredWriter; | ||
import io.github.mmm.marshall.spi.AbstractStructuredTextFormat; | ||
import io.github.mmm.scanner.CharReaderScanner; | ||
import io.github.mmm.scanner.CharSequenceScanner; | ||
|
||
/** | ||
* Implementation of {@link StructuredFormat} for YAML (YAML Ain't Markup Language) that extends JSON with nice and | ||
* advanced features. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
public class YamlFormat extends AbstractStructuredTextFormat { | ||
|
||
private static final YamlFormat DEFAULT = of(MarshallingConfig.DEFAULTS); | ||
|
||
/** | ||
* The constructor. | ||
* | ||
* @param config the {@link MarshallingConfig}. | ||
* @see io.github.mmm.marshall.StructuredFormatFactory#create(String, MarshallingConfig) | ||
*/ | ||
public YamlFormat(MarshallingConfig config) { | ||
|
||
super(config); | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
|
||
return ID_YAML; | ||
} | ||
|
||
@Override | ||
public StructuredReader reader(Reader reader) { | ||
|
||
return new YamlReader(new CharReaderScanner(reader), this); | ||
} | ||
|
||
@Override | ||
public StructuredReader reader(String data) { | ||
|
||
return new YamlReader(new CharSequenceScanner(data), this); | ||
} | ||
|
||
@Override | ||
public StructuredWriter writer(Appendable writer) { | ||
|
||
return new YamlWriter(writer, this); | ||
} | ||
|
||
@Override | ||
public boolean isSupportingComments() { | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* @return the default instance of {@link YamlFormat}. | ||
*/ | ||
public static YamlFormat of() { | ||
|
||
return DEFAULT; | ||
} | ||
|
||
/** | ||
* @param config the {@link MarshallingConfig} for the JSON vendor implementation. | ||
* @return the new instance of {@link YamlFormat} with the given {@code config}. | ||
*/ | ||
public static YamlFormat of(MarshallingConfig config) { | ||
|
||
if (config == null) { | ||
return DEFAULT; | ||
} | ||
return new YamlFormat(config); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters