private void addAttributes(Variable v, DodsV dodsV) { List<DODSAttribute> atts = dodsV.attributes; for (Attribute ncatt : atts) { v.addAttribute(ncatt); } // this is the case where its (probably) a Grid, and so _Coordinate.Axes has been assigned, but if // theres also a coordinates attribute, need to add that info Attribute axes = v.findAttribute(CF.COORDINATES); Attribute _axes = v.findAttribute(_Coordinate.Axes); if ((null != axes) && (null != _axes)) { v.addAttribute(combineAxesAttrs(axes, _axes)); } }
public void testAxisAttrCombineOverlapMangled() { Attribute attr1 = new Attribute(_Coordinate.Axes, " abe bec cid dave "); Attribute attr2 = new Attribute(_Coordinate.Axes, "cid dave ed fin"); Attribute attr3 = combineAxesAttrs(attr1, attr2); // these will fail, because whitespace is all messed up in the attribute values assertFalse(attr3.getStringValue().contains(attr1.getStringValue())); assertFalse(attr3.getStringValue().contains(attr2.getStringValue())); assertEquals(attr3.getStringValue().split("\\s").length, 6); } }
@Test public void testAxisAttrCombineOverlap() { Attribute attr1 = new Attribute(_Coordinate.Axes, "abe bec cid dave"); Attribute attr2 = new Attribute(_Coordinate.Axes, "cid dave ed fin"); Attribute attr3 = combineAxesAttrs(attr1, attr2); assertTrue(attr3.getStringValue().contains(attr1.getStringValue())); assertTrue(attr3.getStringValue().contains(attr2.getStringValue())); assertEquals(attr3.getStringValue().split("\\s").length, 6); }
@Test public void testAxisAttrCombineDiff() { Attribute attr1 = new Attribute(_Coordinate.Axes, "abe bec cid dave"); Attribute attr2 = new Attribute(_Coordinate.Axes, "ed fin gabe hedi"); Attribute attr3 = combineAxesAttrs(attr1, attr2); assertTrue(attr3.getStringValue().contains(attr1.getStringValue())); assertTrue(attr3.getStringValue().contains(attr2.getStringValue())); }
@Test public void testAxisAttrCombineSame() { Attribute attr1 = new Attribute(_Coordinate.Axes, "abe bec cid dave"); Attribute attr2 = new Attribute(_Coordinate.Axes, "abe bec cid dave"); Attribute attr3 = combineAxesAttrs(attr1, attr2); assertEquals(attr3.getStringValue(), (attr1.getStringValue())); assertEquals(attr3.getStringValue(), attr2.getStringValue()); }