@Override public boolean isAutoAdjustingTimeCoding() { final MetadataElement tsRootElement = tsProduct.getMetadataRoot().getElement(TIME_SERIES_ROOT_NAME); if (!tsRootElement.containsAttribute(AUTO_ADJUSTING_TIME_CODING)) { setAutoAdjustingTimeCoding(true); } final String autoAdjustString = tsRootElement.getAttributeString(AUTO_ADJUSTING_TIME_CODING); return Boolean.parseBoolean(autoAdjustString); }
private static void initParameter(MetadataElement parentElement, Field field, Map<String, Object> parameters) throws OperatorException { Parameter annotation = field.getAnnotation(Parameter.class); String name = annotation.alias(); if (name.isEmpty()) { name = field.getName(); } try { if (parentElement.containsAttribute(name)) { final Converter converter = getConverter(field.getType(), annotation); final String parameterText = parentElement.getAttributeString(name); final Object value = converter.parse(parameterText); parameters.put(name, value); } else { final MetadataElement element = parentElement.getElement(name); if (element != null) { final Object obj = field.getType().newInstance(); final HashMap<String, Object> objParams = new HashMap<String, Object>(); collectParameters(obj.getClass(), element, objParams); initObject(objParams, obj); parameters.put(name, obj); } } } catch (Exception e) { throw new OperatorException(String.format("Cannot initialise operator parameter '%s'", name), e); } }
/** * Tests the functionality for containsAttribute() */ public void testContainsAttribute() { MetadataElement annot = new MetadataElement("test_me"); MetadataAttribute att = new MetadataAttribute("Test1", ProductData.createInstance(ProductData.TYPE_INT32), false); // should not contain anything now assertEquals(false, annot.containsAttribute("Test1")); // add attribute an check again annot.addAttribute(att); assertEquals(true, annot.containsAttribute("Test1")); // tis one should not be there assertEquals(false, annot.containsAttribute("NotMe")); }