- public static ValueAccessor contentDisplayValueAccessor = new ValueAccessor() {
-
- @Override
- public void setValue(WriteGraph graph, Variable context, Object value, Binding binding) throws DatabaseException {
- if (!Bindings.STRING.equals(binding)) throw new IllegalArgumentException();
- if (!(value instanceof String)) throw new IllegalArgumentException();
-
- if (((String)value).startsWith("=")) {
- context.getParent(graph).setValue(graph, value, Bindings.STRING);
- } else {
- context.getParent(graph).setValue(graph, new Variant(Bindings.STRING, value), Bindings.VARIANT);
- }
- }
-
- @Override
- public void setValue(WriteGraph graph, Variable context, Object value) throws DatabaseException {
- if (!(value instanceof String)) throw new IllegalArgumentException();
-
- if (((String)value).startsWith("=")) {
- context.getParent(graph).setValue(graph, value, Bindings.STRING);
- } else {
- context.getParent(graph).setValue(graph, new Variant(Bindings.STRING, value), Bindings.VARIANT);
- }
- }
-
- @Override
- public Object getValue(ReadGraph graph, Variable context, Binding binding) throws DatabaseException {
- return context.getParent(graph).getValue(graph, binding);
- }
-
- @Override
- public Object getValue(ReadGraph graph, Variable context) throws DatabaseException {
- return context.getParent(graph).getValue(graph);
- }
-
- @Override
- public Datatype getDatatype(ReadGraph graph, Variable context) throws DatabaseException {
- return context.getParent(graph).getDatatype(graph);
- }
-
- };
-
- @SCLValue(type = "VariableMap")
- public static VariableMap stringArrayChildren = new VariableMapImpl() {
-
- @Override
- public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {
-
- TMap<String, Variable> map = new THashMap<String, Variable>();
- getVariables(graph, context, map);
- return map.get(name);
-
- }
-
- @Override
- public Map<String, Variable> getVariables(ReadGraph graph, Variable context, Map<String, Variable> map) throws DatabaseException {
-
- Resource resource = context.getRepresents(graph);
-
- SpreadsheetResource sr = SpreadsheetResource.getInstance(graph);
-
- String location = graph.getPossibleRelatedValue(resource, sr.Range_location, Bindings.STRING);
- if(location == null) return map;
- Integer width = graph.getPossibleRelatedValue(resource, sr.Range_widthBound, Bindings.INTEGER);
- if(width == null) return map;
- String[] array = graph.getPossibleRelatedValue(resource, sr.StringArrayRange_array, Bindings.STRING_ARRAY);
- if(array == null) return map;
-
- int rows = array.length / width;
-
- if(map == null) map = new HashMap<String,Variable>();
-
- for(int offset=0,i=0;i<rows;i++) {
- for(int j=0;j<width;j++) {
-
- String value = array[offset++];
- String valueLocation = SpreadsheetUtils.offset(location, i, j);
-
- ConstantPropertyVariableBuilder labelBuilder = new ConstantPropertyVariableBuilder(ClientModel.LABEL, value, Bindings.STRING, Collections.<ConstantPropertyVariableBuilder>emptyList(), CLASSIFICATIONS);
- ConstantPropertyVariableBuilder typeBuilder = new ConstantPropertyVariableBuilder(Variables.TYPE, sr.Cell, null, Collections.<ConstantPropertyVariableBuilder>emptyList(), Collections.<String>emptySet());
-
- map.put(valueLocation, new ConstantChildVariable(context, valueLocation, labelBuilder, typeBuilder, immutableBuilder));
-
- }
- }
-
- return map;
-
- }
-
+ public static ValueAccessor contentDisplayValueAccessor = new ValueAccessor() {
+
+ @Override
+ public void setValue(WriteGraph graph, Variable context, Object value, Binding binding) throws DatabaseException {
+ if (!Bindings.STRING.equals(binding)) throw new IllegalArgumentException();
+ if (!(value instanceof String)) throw new IllegalArgumentException();
+
+ if (((String)value).startsWith("=")) {
+ context.getParent(graph).setValue(graph, value, Bindings.STRING);
+ } else {
+ context.getParent(graph).setValue(graph, new Variant(Bindings.STRING, value), Bindings.VARIANT);
+ }
+ }
+
+ @Override
+ public void setValue(WriteGraph graph, Variable context, Object value) throws DatabaseException {
+ if (!(value instanceof String)) throw new IllegalArgumentException();
+
+ if (((String)value).startsWith("=")) {
+ context.getParent(graph).setValue(graph, value, Bindings.STRING);
+ } else {
+ context.getParent(graph).setValue(graph, new Variant(Bindings.STRING, value), Bindings.VARIANT);
+ }
+ }
+
+ @Override
+ public Object getValue(ReadGraph graph, Variable context, Binding binding) throws DatabaseException {
+ return context.getParent(graph).getValue(graph, binding);
+ }
+
+ @Override
+ public Object getValue(ReadGraph graph, Variable context) throws DatabaseException {
+ return context.getParent(graph).getValue(graph);
+ }
+
+ @Override
+ public Datatype getDatatype(ReadGraph graph, Variable context) throws DatabaseException {
+ return context.getParent(graph).getDatatype(graph);
+ }
+
+ };
+
+ @SCLValue(type = "VariableMap")
+ public static VariableMap stringArrayChildren = new VariableMapImpl() {
+
+ @Override
+ public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {
+
+ TMap<String, Variable> map = new THashMap<String, Variable>();
+ getVariables(graph, context, map);
+ return map.get(name);
+
+ }
+
+ @Override
+ public Map<String, Variable> getVariables(ReadGraph graph, Variable context, Map<String, Variable> map) throws DatabaseException {
+
+ Resource resource = context.getRepresents(graph);
+
+ SpreadsheetResource sr = SpreadsheetResource.getInstance(graph);
+
+ String location = graph.getPossibleRelatedValue(resource, sr.Range_location, Bindings.STRING);
+ if(location == null) return map;
+ Integer width = graph.getPossibleRelatedValue(resource, sr.Range_widthBound, Bindings.INTEGER);
+ if(width == null) return map;
+ String[] array = graph.getPossibleRelatedValue(resource, sr.StringArrayRange_array, Bindings.STRING_ARRAY);
+ if(array == null) return map;
+
+ int rows = array.length / width;
+
+ if(map == null) map = new HashMap<String,Variable>();
+
+ for(int offset=0,i=0;i<rows;i++) {
+ for(int j=0;j<width;j++) {
+
+ String value = array[offset++];
+ String valueLocation = Spreadsheets.offset(location, i, j);
+
+ ConstantPropertyVariableBuilder labelBuilder = new ConstantPropertyVariableBuilder(ClientModel.LABEL, value, Bindings.STRING, Collections.<ConstantPropertyVariableBuilder>emptyList(), CLASSIFICATIONS);
+ ConstantPropertyVariableBuilder typeBuilder = new ConstantPropertyVariableBuilder(Variables.TYPE, sr.Cell, null, Collections.<ConstantPropertyVariableBuilder>emptyList(), Collections.<String>emptySet());
+
+ map.put(valueLocation, new ConstantChildVariable(context, valueLocation, labelBuilder, typeBuilder, immutableBuilder));
+
+ }
+ }
+
+ return map;
+
+ }
+