diff options
author | Ian Forsey <ian.forsey@net-a-porter.com> | 2014-03-06 17:40:17 +0000 |
---|---|---|
committer | Ian Forsey <ian.forsey@net-a-porter.com> | 2014-03-06 17:40:17 +0000 |
commit | 3f56c8f4c6e7ede3d996b8e64554030bfc401c54 (patch) | |
tree | 6ff93bfee0be9a812f22d72ca4f9eaa504fcf80a /src/main/scala/spray | |
parent | d6b6debbb3c23eb1743678ea229e22f68ac052aa (diff) | |
download | spray-json-3f56c8f4c6e7ede3d996b8e64554030bfc401c54.tar.gz spray-json-3f56c8f4c6e7ede3d996b8e64554030bfc401c54.tar.bz2 spray-json-3f56c8f4c6e7ede3d996b8e64554030bfc401c54.zip |
Make printer methods protected, so they can be overridden
Diffstat (limited to 'src/main/scala/spray')
-rw-r--r-- | src/main/scala/spray/json/CompactPrinter.scala | 4 | ||||
-rw-r--r-- | src/main/scala/spray/json/PrettyPrinter.scala | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/main/scala/spray/json/CompactPrinter.scala b/src/main/scala/spray/json/CompactPrinter.scala index b7d2856..eca616f 100644 --- a/src/main/scala/spray/json/CompactPrinter.scala +++ b/src/main/scala/spray/json/CompactPrinter.scala @@ -31,7 +31,7 @@ trait CompactPrinter extends JsonPrinter { } } - private def printObject(members: Map[String, JsValue], sb: StringBuilder) { + protected def printObject(members: Map[String, JsValue], sb: StringBuilder) { sb.append('{') printSeq(members, sb.append(',')) { m => printString(m._1, sb) @@ -41,7 +41,7 @@ trait CompactPrinter extends JsonPrinter { sb.append('}') } - private def printArray(elements: List[JsValue], sb: StringBuilder) { + protected def printArray(elements: List[JsValue], sb: StringBuilder) { sb.append('[') printSeq(elements, sb.append(','))(print(_, sb)) sb.append(']') diff --git a/src/main/scala/spray/json/PrettyPrinter.scala b/src/main/scala/spray/json/PrettyPrinter.scala index 0daaf71..f1604ff 100644 --- a/src/main/scala/spray/json/PrettyPrinter.scala +++ b/src/main/scala/spray/json/PrettyPrinter.scala @@ -29,7 +29,7 @@ trait PrettyPrinter extends JsonPrinter { print(x, sb, 0) } - private def print(x: JsValue, sb: StringBuilder, indent: Int) { + protected def print(x: JsValue, sb: StringBuilder, indent: Int) { x match { case JsObject(x) => printObject(x, sb, indent) case JsArray(x) => printArray(x, sb, indent) @@ -37,7 +37,7 @@ trait PrettyPrinter extends JsonPrinter { } } - private def printObject(members: Map[String, JsValue], sb: StringBuilder, indent: Int) { + protected def printObject(members: Map[String, JsValue], sb: StringBuilder, indent: Int) { sb.append("{\n") printSeq(members, sb.append(",\n")) { m => printIndent(sb, indent + Indent) @@ -50,14 +50,14 @@ trait PrettyPrinter extends JsonPrinter { sb.append("}") } - private def printArray(elements: List[JsValue], sb: StringBuilder, indent: Int) { + protected def printArray(elements: List[JsValue], sb: StringBuilder, indent: Int) { sb.append('[') printSeq(elements, sb.append(", "))(print(_, sb, indent)) sb.append(']') } @tailrec - private def printIndent(sb: StringBuilder, indent: Int) { + protected def printIndent(sb: StringBuilder, indent: Int) { if (indent > 0) { sb.append(' ') printIndent(sb, indent - 1) |