-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b0f187a
commit f6aecdf
Showing
3 changed files
with
37 additions
and
19 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -28,12 +28,7 @@ | |
package com.amihaiemil.eoyaml; | ||
|
||
/** | ||
* YAML Plain scalar from String. Use this class when dealing with | ||
* built YAML or in the unit tests. | ||
* | ||
* DO NOT use it when READING yaml. For reading use | ||
* {@link ReadPlainScalar}! | ||
* | ||
* YAML Plain Scalar from String. | ||
* @author Mihai Andronache ([email protected]) | ||
* @version $Id$ | ||
* @since 1.0.0 | ||
|
@@ -94,12 +89,39 @@ final class PlainStringScalar extends BaseScalar { | |
*/ | ||
@Override | ||
public String value() { | ||
return this.value; | ||
final String unescaped; | ||
if("null".equals(this.value)) { | ||
unescaped = null; | ||
} else { | ||
unescaped = this.unescape(this.value); | ||
} | ||
return unescaped; | ||
} | ||
|
||
@Override | ||
public Comment comment() { | ||
return this.comment; | ||
} | ||
|
||
/** | ||
* Remove the possible escaping quotes or apostrophes surrounding the | ||
* given value. | ||
* @param escaped The value to unescape. | ||
* @return The value without quotes or apostrophes. | ||
*/ | ||
private String unescape(final String escaped) { | ||
final String unescaped; | ||
if(escaped == null) { | ||
unescaped = escaped; | ||
} else { | ||
if (escaped.startsWith("\"") && escaped.endsWith("\"")) { | ||
unescaped = escaped.substring(1, escaped.length() - 1); | ||
} else if (escaped.startsWith("'") && escaped.endsWith("'")) { | ||
unescaped = escaped.substring(1, escaped.length() - 1); | ||
} else { | ||
unescaped = escaped; | ||
} | ||
} | ||
return unescaped; | ||
} | ||
} |
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
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
f6aecdf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amihaiemil I've closed the Issues [#602] since their to-dos disappeared from the code.
The to-dos may have been removed in an earlier commit, but I've found it just now.