Permalink
Browse files

Run formatter over existing files

  • Loading branch information...
ansell committed Jun 11, 2013
1 parent 3afd505 commit 6f7e9661d4844603be6cc04f3e6125845ac2ba6a
Showing with 9,702 additions and 8,938 deletions.
  1. +153 −143 core/src/main/java/com/github/jsonldjava/core/ActiveContext.java
  2. +445 −422 core/src/main/java/com/github/jsonldjava/core/JSONLD.java
  3. +7 −7 core/src/main/java/com/github/jsonldjava/core/JSONLDConsts.java
  4. +45 −44 core/src/main/java/com/github/jsonldjava/core/JSONLDProcessingError.java
  5. +1,596 −1,394 core/src/main/java/com/github/jsonldjava/core/JSONLDProcessor.java
  6. +36 −39 core/src/main/java/com/github/jsonldjava/core/JSONLDTripleCallback.java
  7. +1,493 −1,372 core/src/main/java/com/github/jsonldjava/core/JSONLDUtils.java
  8. +555 −514 core/src/main/java/com/github/jsonldjava/core/NormalizeUtils.java
  9. +60 −56 core/src/main/java/com/github/jsonldjava/core/Options.java
  10. +628 −514 core/src/main/java/com/github/jsonldjava/core/RDFDataset.java
  11. +522 −495 core/src/main/java/com/github/jsonldjava/core/RDFDatasetUtils.java
  12. +39 −46 core/src/main/java/com/github/jsonldjava/core/RDFParser.java
  13. +50 −34 core/src/main/java/com/github/jsonldjava/core/Regex.java
  14. +62 −62 core/src/main/java/com/github/jsonldjava/core/UniqueNamer.java
  15. +11 −15 core/src/main/java/com/github/jsonldjava/impl/NQuadRDFParser.java
  16. +4 −7 core/src/main/java/com/github/jsonldjava/impl/NQuadTripleCallback.java
  17. +556 −508 core/src/main/java/com/github/jsonldjava/impl/TurtleRDFParser.java
  18. +356 −330 core/src/main/java/com/github/jsonldjava/impl/TurtleTripleCallback.java
  19. +83 −69 core/src/main/java/com/github/jsonldjava/utils/JSONUtils.java
  20. +55 −49 core/src/main/java/com/github/jsonldjava/utils/Obj.java
  21. +171 −136 core/src/main/java/com/github/jsonldjava/utils/URL.java
  22. +100 −90 core/src/test/java/com/github/jsonldjava/core/IgnoreKeysTest.java
  23. +390 −315 core/src/test/java/com/github/jsonldjava/core/JSONLDProcessorTest.java
  24. +197 −241 core/src/test/java/com/github/jsonldjava/core/RegexTest.java
  25. +389 −343 core/src/test/java/com/github/jsonldjava/impl/TurtleRDFParserTest.java
  26. +623 −629 core/src/test/java/com/github/jsonldjava/impl/TurtleRegexTests.java
  27. +120 −119 core/src/test/java/com/github/jsonldjava/utils/EarlTestSuite.java
  28. +95 −102 core/src/test/java/com/github/jsonldjava/utils/JSONUtilsTest.java
  29. +65 −62 integration/clerezza/src/main/java/com/github/jsonldjava/impl/ClerezzaTripleCallback.java
  30. +35 −35 integration/clerezza/src/test/java/com/github/jsonldjava/impl/ClerezzaTripleCallbackTest.java
  31. +58 −56 integration/jena/src/main/java/com/github/jsonldjava/impl/JenaRDFParser.java
  32. +25 −28 integration/jena/src/main/java/com/github/jsonldjava/impl/JenaTripleCallback.java
  33. +51 −39 integration/jena/src/test/java/com/github/jsonldjava/impl/JenaRDFParserTest.java
  34. +58 −44 integration/jena/src/test/java/com/github/jsonldjava/impl/JenaTripleCallbackTest.java
  35. +31 −34 integration/sesame/src/main/java/com/github/jsonldjava/impl/SesameJSONLDParser.java
  36. +2 −2 integration/sesame/src/main/java/com/github/jsonldjava/impl/SesameJSONLDParserFactory.java
  37. +55 −63 integration/sesame/src/main/java/com/github/jsonldjava/impl/SesameJSONLDWriter.java
  38. +3 −3 integration/sesame/src/main/java/com/github/jsonldjava/impl/SesameJSONLDWriterFactory.java
  39. +77 −82 integration/sesame/src/main/java/com/github/jsonldjava/impl/SesameRDFParser.java
  40. +168 −168 integration/sesame/src/main/java/com/github/jsonldjava/impl/SesameTripleCallback.java
  41. +21 −30 integration/sesame/src/test/java/com/github/jsonldjava/impl/SesameJSONLDParserHandlerTest.java
  42. +77 −81 integration/sesame/src/test/java/com/github/jsonldjava/impl/SesameJSONLDWriterTest.java
  43. +41 −40 integration/sesame/src/test/java/com/github/jsonldjava/impl/SesameTripleCallbackTest.java
  44. +94 −76 tools/src/main/java/com/github/jsonldjava/impl/Playground.java
@@ -1,5 +1,8 @@
package com.github.jsonldjava.core;
+import static com.github.jsonldjava.core.JSONLDUtils.compareShortestLeast;
+import static com.github.jsonldjava.core.JSONLDUtils.isArray;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -9,62 +12,60 @@
import com.github.jsonldjava.utils.URL;
-import static com.github.jsonldjava.core.JSONLDUtils.*;
-
/**
- * A helper class which still stores all the values in a map
- * but gives member variables easily access certain keys
+ * A helper class which still stores all the values in a map but gives member
+ * variables easily access certain keys
*
* @author tristan
- *
+ *
*/
public class ActiveContext extends LinkedHashMap<String, Object> {
public ActiveContext() {
- this(new Options());
+ this(new Options());
}
-
+
public ActiveContext(Options options) {
- super();
- init(options);
+ super();
+ init(options);
}
-
- public ActiveContext(Map<String,Object> map, Options options) {
- super(map);
- init(options);
+
+ public ActiveContext(Map<String, Object> map, Options options) {
+ super(map);
+ init(options);
}
-
- public ActiveContext(Map<String,Object> map) {
- super(map);
- init(new Options());
+
+ public ActiveContext(Map<String, Object> map) {
+ super(map);
+ init(new Options());
}
-
+
private void init(Options options) {
- Object base = URL.parse(options.base);
-
- this.put("mappings", new LinkedHashMap<String,Object>());
-
- this.put("@base", base);
- mappings = (Map<String, Object>) this.get("mappings");
+ final Object base = URL.parse(options.base);
+
+ this.put("mappings", new LinkedHashMap<String, Object>());
+
+ this.put("@base", base);
+ mappings = (Map<String, Object>) this.get("mappings");
}
public Object getContextValue(String key, String type) {
-
- // return null for invalid key
+
+ // return null for invalid key
if (key == null) {
return null;
}
-
+
Object rval = null;
-
+
// get default language
if ("@language".equals(type) && this.containsKey(type)) {
rval = this.get(type);
}
// get specific entry information
if (this.mappings.containsKey(key)) {
- Map<String, Object> entry = (Map<String, Object>) this.mappings.get(key);
+ final Map<String, Object> entry = (Map<String, Object>) this.mappings.get(key);
if (type == null) {
rval = entry;
@@ -75,129 +76,138 @@ public Object getContextValue(String key, String type) {
return rval;
}
-
+
+ @Override
public ActiveContext clone() {
- return (ActiveContext) super.clone();
+ return (ActiveContext) super.clone();
}
public Map<String, Object> mappings;
public Map<String, Object> inverse = null;
-
+
// TODO: remove this when it's not needed by old code
public Map<String, List<String>> keywords;
/**
- * Generates an inverse context for use in the compaction algorithm, if
- * not already generated for the given active context.
- *
+ * Generates an inverse context for use in the compaction algorithm, if not
+ * already generated for the given active context.
+ *
* @return the inverse context.
*/
- public Map<String, Object> getInverse() {
-
- // lazily create inverse
- if (inverse != null) {
- return inverse;
- }
-
- inverse = new LinkedHashMap<String, Object>();
-
- // handle default language
- String defaultLanguage = (String) this.get("@language");
- if (defaultLanguage == null) {
- defaultLanguage = "@none";
- }
- // create term selections for each mapping in the context, ordererd by
- // shortest and then lexicographically least
- List<String> terms = new ArrayList<String>(mappings.keySet());
- Collections.sort(terms, new Comparator<String>() {
- @Override
- public int compare(String a, String b) {
- return compareShortestLeast(a, b);
- }
- });
-
- for (String term : terms) {
- Map<String,Object> mapping = (Map<String, Object>) mappings.get(term);
- if (mappings.containsKey(term) && mapping == null) {
- continue;
- }
-
- String container = (String) mapping.get("@container");
- if (container == null) {
- container = "@none";
- }
-
- // iterate over every IRI in the mapping
- List<String> ids;
- if (!isArray(mapping.get("@id"))) {
- ids = new ArrayList<String>();
- ids.add((String) mapping.get("@id"));
- } else {
- ids = (List<String>) mapping.get("@id");
- }
- for (String iri : ids) {
- Map<String, Object> entry = (Map<String, Object>) inverse.get(iri);
-
- // initialize entry
- if (entry == null) {
- entry = new LinkedHashMap<String, Object>();
- inverse.put(iri, entry);
- }
-
- // add new entry
- if (!entry.containsKey(container) || entry.get(container) == null) {
- entry.put(container, new LinkedHashMap<String, Object>() {{
- put("@language", new LinkedHashMap<String, Object>());
- put("@type", new LinkedHashMap<String, Object>());
- }});
- }
- entry = (Map<String, Object>) entry.get(container);
-
- // term is preferred for values using @reverse
- if (mapping.containsKey("reverse") && Boolean.TRUE.equals(mapping.get("reverse"))) {
- addPreferredTerm(mapping, term, entry.get("@type"), "@reverse");
- }
- // term is preferred for values using specific type
- else if (mapping.containsKey("@type")) {
- addPreferredTerm(mapping, term, entry.get("@type"), mapping.get("@type"));
- }
- // term is preferred for values using specific language
- else if (mapping.containsKey("@language")) {
- String language = (String) mapping.get("@language");
- if (language == null) {
- language = "@null";
- }
- addPreferredTerm(mapping, term, entry.get("@language"), language);
- }
- // term is preferred for values w/default language or no type and no language
- else {
- // add an entry for the default language
- addPreferredTerm(mapping, term, entry.get("@type"), defaultLanguage);
-
- // add entries for no type and no language
- addPreferredTerm(mapping, term, entry.get("@type"), "@none");
- addPreferredTerm(mapping, term, entry.get("@language"), "@none");
- }
- }
- }
-
- return inverse;
- }
-
- /**
- * Adds the term for the given entry if not already added.
- *
- * @param mapping the term mapping.
- * @param term the term to add.
- * @param entry the inverse context typeOrLanguage entry to add to.
- * @param typeOrLanguageValue the key in the entry to add to.
- *
- * NOTE: variables are left as Object to make it look a bit nicer in the calling function
- */
- private void addPreferredTerm(Map<String, Object> mapping, String term,
- Object entry, Object typeOrLanguageValue) {
- if (!((Map<String, Object>) entry).containsKey(typeOrLanguageValue)) {
- ((Map<String, Object>) entry).put((String) typeOrLanguageValue, term);
- }
- }
+ public Map<String, Object> getInverse() {
+
+ // lazily create inverse
+ if (inverse != null) {
+ return inverse;
+ }
+
+ inverse = new LinkedHashMap<String, Object>();
+
+ // handle default language
+ String defaultLanguage = (String) this.get("@language");
+ if (defaultLanguage == null) {
+ defaultLanguage = "@none";
+ }
+ // create term selections for each mapping in the context, ordererd by
+ // shortest and then lexicographically least
+ final List<String> terms = new ArrayList<String>(mappings.keySet());
+ Collections.sort(terms, new Comparator<String>() {
+ @Override
+ public int compare(String a, String b) {
+ return compareShortestLeast(a, b);
+ }
+ });
+
+ for (final String term : terms) {
+ final Map<String, Object> mapping = (Map<String, Object>) mappings.get(term);
+ if (mappings.containsKey(term) && mapping == null) {
+ continue;
+ }
+
+ String container = (String) mapping.get("@container");
+ if (container == null) {
+ container = "@none";
+ }
+
+ // iterate over every IRI in the mapping
+ List<String> ids;
+ if (!isArray(mapping.get("@id"))) {
+ ids = new ArrayList<String>();
+ ids.add((String) mapping.get("@id"));
+ } else {
+ ids = (List<String>) mapping.get("@id");
+ }
+ for (final String iri : ids) {
+ Map<String, Object> entry = (Map<String, Object>) inverse.get(iri);
+
+ // initialize entry
+ if (entry == null) {
+ entry = new LinkedHashMap<String, Object>();
+ inverse.put(iri, entry);
+ }
+
+ // add new entry
+ if (!entry.containsKey(container) || entry.get(container) == null) {
+ entry.put(container, new LinkedHashMap<String, Object>() {
+ {
+ put("@language", new LinkedHashMap<String, Object>());
+ put("@type", new LinkedHashMap<String, Object>());
+ }
+ });
+ }
+ entry = (Map<String, Object>) entry.get(container);
+
+ // term is preferred for values using @reverse
+ if (mapping.containsKey("reverse") && Boolean.TRUE.equals(mapping.get("reverse"))) {
+ addPreferredTerm(mapping, term, entry.get("@type"), "@reverse");
+ }
+ // term is preferred for values using specific type
+ else if (mapping.containsKey("@type")) {
+ addPreferredTerm(mapping, term, entry.get("@type"), mapping.get("@type"));
+ }
+ // term is preferred for values using specific language
+ else if (mapping.containsKey("@language")) {
+ String language = (String) mapping.get("@language");
+ if (language == null) {
+ language = "@null";
+ }
+ addPreferredTerm(mapping, term, entry.get("@language"), language);
+ }
+ // term is preferred for values w/default language or no type
+ // and no language
+ else {
+ // add an entry for the default language
+ addPreferredTerm(mapping, term, entry.get("@type"), defaultLanguage);
+
+ // add entries for no type and no language
+ addPreferredTerm(mapping, term, entry.get("@type"), "@none");
+ addPreferredTerm(mapping, term, entry.get("@language"), "@none");
+ }
+ }
+ }
+
+ return inverse;
+ }
+
+ /**
+ * Adds the term for the given entry if not already added.
+ *
+ * @param mapping
+ * the term mapping.
+ * @param term
+ * the term to add.
+ * @param entry
+ * the inverse context typeOrLanguage entry to add to.
+ * @param typeOrLanguageValue
+ * the key in the entry to add to.
+ *
+ * NOTE: variables are left as Object to make it look a bit nicer
+ * in the calling function
+ */
+ private void addPreferredTerm(Map<String, Object> mapping, String term, Object entry,
+ Object typeOrLanguageValue) {
+ if (!((Map<String, Object>) entry).containsKey(typeOrLanguageValue)) {
+ ((Map<String, Object>) entry).put((String) typeOrLanguageValue, term);
+ }
+ }
}
Oops, something went wrong.

0 comments on commit 6f7e966

Please sign in to comment.