-
Notifications
You must be signed in to change notification settings - Fork 871
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: moved class for json formatting settings to specific file
- Loading branch information
Showing
4 changed files
with
68 additions
and
69 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
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
59 changes: 59 additions & 0 deletions
59
.../orientechnologies/orient/core/serialization/serializer/record/string/FormatSettings.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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.orientechnologies.orient.core.serialization.serializer.record.string; | ||
|
||
public class FormatSettings { | ||
public boolean includeVer; | ||
public boolean includeType; | ||
public boolean includeId; | ||
public boolean includeClazz; | ||
public boolean attribSameRow; | ||
public boolean alwaysFetchEmbeddedDocuments; | ||
public int indentLevel; | ||
public String fetchPlan = null; | ||
public boolean keepTypes = true; | ||
public boolean dateAsLong = false; | ||
public boolean prettyPrint = false; | ||
|
||
public FormatSettings(final String iFormat) { | ||
if (iFormat == null) { | ||
includeType = true; | ||
includeVer = true; | ||
includeId = true; | ||
includeClazz = true; | ||
attribSameRow = true; | ||
indentLevel = 0; | ||
fetchPlan = ""; | ||
keepTypes = true; | ||
alwaysFetchEmbeddedDocuments = true; | ||
} else { | ||
includeType = false; | ||
includeVer = false; | ||
includeId = false; | ||
includeClazz = false; | ||
attribSameRow = false; | ||
alwaysFetchEmbeddedDocuments = false; | ||
indentLevel = 0; | ||
keepTypes = false; | ||
|
||
if (iFormat != null && !iFormat.isEmpty()) { | ||
final String[] format = iFormat.split(","); | ||
for (String f : format) | ||
if (f.equals("type")) includeType = true; | ||
else if (f.equals("rid")) includeId = true; | ||
else if (f.equals("version")) includeVer = true; | ||
else if (f.equals("class")) includeClazz = true; | ||
else if (f.equals("attribSameRow")) attribSameRow = true; | ||
else if (f.startsWith("indent")) | ||
indentLevel = Integer.parseInt(f.substring(f.indexOf(':') + 1)); | ||
else if (f.startsWith("fetchPlan")) fetchPlan = f.substring(f.indexOf(':') + 1); | ||
else if (f.startsWith("keepTypes")) keepTypes = true; | ||
else if (f.startsWith("alwaysFetchEmbedded")) alwaysFetchEmbeddedDocuments = true; | ||
else if (f.startsWith("dateAsLong")) dateAsLong = true; | ||
else if (f.startsWith("prettyPrint")) prettyPrint = true; | ||
else if (f.startsWith("graph") || f.startsWith("shallow")) | ||
// SUPPORTED IN OTHER PARTS | ||
; | ||
else throw new IllegalArgumentException("Unrecognized JSON formatting option: " + f); | ||
} | ||
} | ||
} | ||
} |
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