protected static boolean booleanValue(Attribute attribute) { if (attribute == null) { return false; } Object value = attribute.getData(); if (value == null) { return false; } else if (value instanceof Boolean) { Boolean b = (Boolean) value; return b.booleanValue(); } else { return "true".equalsIgnoreCase(value.toString()); } } }
throw new DiscoveryException("Attribute[" + ConfigConstant.SERVICE_NAME_ATTRIBUTE_NAME + "] in element[" + childElement.getName() + "] is missing"); String serviceName = serviceNameAttribute.getData().toString().trim(); throw new DiscoveryException("Attribute[" + ConfigConstant.KEY_ATTRIBUTE_NAME + "] in element[" + childElement.getName() + "] is missing"); String key = keyAttribute.getData().toString().trim(); throw new DiscoveryException("Attribute[" + ConfigConstant.VALUE_ATTRIBUTE_NAME + "] in element[" + childElement.getName() + "] is missing"); String value = valueAttribute.getData().toString().trim();
String globalFilterValue = globalFilterAttribute.getData().toString().trim(); if (StringUtils.isNotEmpty(globalFilterValue)) { Integer globalValue = null; throw new DiscoveryException("Attribute[" + ConfigConstant.SERVICE_NAME_ATTRIBUTE_NAME + "] in element[" + childElement.getName() + "] is missing"); String serviceName = serviceNameAttribute.getData().toString().trim(); String filterValue = filterValueAttribute.getData().toString().trim(); if (StringUtils.isNotEmpty(filterValue)) { try {
throw new DiscoveryException("Attribute[" + ConfigConstant.CONSUMER_SERVICE_NAME_ATTRIBUTE_NAME + "] in element[" + childElement.getName() + "] is missing"); String consumerServiceName = consumerServiceNameAttribute.getData().toString().trim(); versionEntity.setConsumerServiceName(consumerServiceName); throw new DiscoveryException("Attribute[" + ConfigConstant.PROVIDER_SERVICE_NAME_ATTRIBUTE_NAME + "] in element[" + childElement.getName() + "] is missing"); String providerServiceName = providerServiceNameAttribute.getData().toString().trim(); versionEntity.setProviderServiceName(providerServiceName); String consumerVersionValue = consumerVersionValueAttribute.getData().toString().trim(); List<String> consumerVersionValueList = StringUtil.splitToList(consumerVersionValue, DiscoveryConstant.SEPARATE); versionEntity.setConsumerVersionValueList(consumerVersionValueList); String providerVersionValue = providerVersionValueAttribute.getData().toString().trim(); List<String> providerVersionValueList = StringUtil.splitToList(providerVersionValue, DiscoveryConstant.SEPARATE); versionEntity.setProviderVersionValueList(providerVersionValueList);
String globalFilterValue = globalFilterAttribute.getData().toString().trim(); List<String> globalFilterValueList = StringUtil.splitToList(globalFilterValue, DiscoveryConstant.SEPARATE); hostFilterEntity.setFilterValueList(globalFilterValueList); throw new DiscoveryException("Attribute[" + ConfigConstant.SERVICE_NAME_ATTRIBUTE_NAME + "] in element[" + childElement.getName() + "] is missing"); String serviceName = serviceNameAttribute.getData().toString().trim(); String filterValue = filterValueAttribute.getData().toString().trim(); filterValueList = StringUtil.splitToList(filterValue, DiscoveryConstant.SEPARATE);
String consumerServiceName = null; if (consumerServiceNameAttribute != null) { consumerServiceName = consumerServiceNameAttribute.getData().toString().trim(); } else { consumerServiceName = StringUtils.EMPTY; throw new DiscoveryException("Attribute[" + ConfigConstant.PROVIDER_SERVICE_NAME_ATTRIBUTE_NAME + "] in element[" + childElement.getName() + "] is missing"); String providerServiceName = providerServiceNameAttribute.getData().toString().trim(); weightEntity.setProviderServiceName(providerServiceName); throw new DiscoveryException("Attribute[" + ConfigConstant.PROVIDER_WEIGHT_VALUE_ATTRIBUTE_NAME + "] in element[" + childElement.getName() + "] is missing"); String providerWeightValue = providerWeightValueAttribute.getData().toString().trim(); Map<String, Integer> weightMap = new LinkedHashMap<String, Integer>(); List<String> providerWeightValueList = StringUtil.splitToList(providerWeightValue, DiscoveryConstant.SEPARATE); throw new DiscoveryException("Attribute[" + ConfigConstant.PROVIDER_WEIGHT_VALUE_ATTRIBUTE_NAME + "] in element[" + childElement.getName() + "] is missing"); String providerWeightValue = providerWeightValueAttribute.getData().toString().trim(); Map<String, Integer> weightMap = new LinkedHashMap<String, Integer>(); List<String> providerWeightValueList = StringUtil.splitToList(providerWeightValue, DiscoveryConstant.SEPARATE);
protected static boolean booleanValue(Attribute attribute) { if (attribute == null) { return false; } Object value = attribute.getData(); if (value == null) { return false; } else if (value instanceof Boolean) { Boolean b = (Boolean) value; return b.booleanValue(); } else { return "true".equalsIgnoreCase(value.toString()); } } }
protected static boolean booleanValue(Attribute attribute) { if (attribute == null) { return false; } Object value = attribute.getData(); if (value == null) { return false; } else if (value instanceof Boolean) { Boolean b = (Boolean) value; return b.booleanValue(); } else { return "true".equalsIgnoreCase(value.toString()); } } }
protected static boolean booleanValue(Attribute attribute) { if (attribute == null) { return false; } Object value = attribute.getData(); if (value == null) { return false; } else if (value instanceof Boolean) { Boolean b = (Boolean) value; return b.booleanValue(); } else { return "true".equalsIgnoreCase(value.toString()); } } }
protected static boolean booleanValue(Attribute attribute) { if (attribute == null) { return false; } Object value = attribute.getData(); if (value == null) { return false; } else if (value instanceof Boolean) { Boolean b = (Boolean) value; return b.booleanValue(); } else { return "true".equalsIgnoreCase(value.toString()); } } }
protected static boolean booleanValue(Attribute attribute) { if (attribute == null) { return false; } Object value = attribute.getData(); if (value == null) { return false; } else if (value instanceof Boolean) { Boolean b = (Boolean) value; return b.booleanValue(); } else { return "true".equalsIgnoreCase(value.toString()); } } }
protected static boolean booleanValue(Attribute attribute) { if (attribute == null) { return false; } Object value = attribute.getData(); if (value == null) { return false; } else if (value instanceof Boolean) { Boolean b = (Boolean) value; return b.booleanValue(); } else { return "true".equalsIgnoreCase(value.toString()); } } }
protected static boolean booleanValue(Attribute attribute) { if (attribute == null) { return false; } Object value = attribute.getData(); if (value == null) { return false; } else if (value instanceof Boolean) { Boolean b = (Boolean) value; return b.booleanValue(); } else { return "true".equalsIgnoreCase(value.toString()); } } }
protected static boolean booleanValue(Attribute attribute) { if (attribute == null) { return false; } Object value = attribute.getData(); if (value == null) { return false; } else if (value instanceof Boolean) { Boolean b = (Boolean) value; return b.booleanValue(); } else { return "true".equalsIgnoreCase(value.toString()); } } }
public Map<String, String> getParameters() { return Collections.unmodifiableMap(getParamElements() .collect(Collectors.toMap(param -> param.attribute("name").getData().toString(), Element::getText))); }
private void validateLongAttribute(Element root) throws Exception { Attribute attr = root.attribute("longAttribute"); Object attrData = attr.getData(); validateData("testLongAttribute", attrData, new Long(123)); System.out.println("retrieved attribute " + attrData); }
public void xtestOneToOneInverse() { // system.addSpecification(BiDirectional.class.getName()); final PersistentNakedClasses classes = PersistentNakedClasses.buildPersistentNakedClasses(Boolean.TRUE); final Nof2HbmXml nof2HbmXml = new Nof2HbmXml(); final Document doc = nof2HbmXml.createDocument(classes.getPersistentClass(OneToOne.class.getName())); final Element manyToOne = doc.getRootElement().element("class").element("many-to-one"); assertEquals("name", "one", manyToOne.attribute("name").getData()); assertEquals("class", BiDirectional.class.getName(), manyToOne.attribute("class").getData()); assertEquals("unique", "true", manyToOne.attribute("unique").getData()); assertEquals("column", "FKone", manyToOne.attribute("column").getData()); }
public void xtestManyToManyInverse() { // system.addSpecification(BiDirectional.class.getName()); final PersistentNakedClasses classes = PersistentNakedClasses.buildPersistentNakedClasses(Boolean.TRUE); final Nof2HbmXml nof2HbmXml = new Nof2HbmXml(); final Document doc = nof2HbmXml.createDocument(classes.getPersistentClass(ManyToMany.class.getName())); final Element bag = doc.getRootElement().element("class").element("bag"); assertEquals("bag name", "many", bag.attribute("name").getData()); assertEquals("bag table", "BIDIRECTIONAL_MANYTOMANY", bag.attribute("table").getData()); assertEquals("bag inverse", "true", bag.attribute("inverse").getData()); assertEquals("key", "FKmanytomany", bag.element("key").attribute("column").getData()); final Element manyToMany = bag.element("many-to-many"); assertEquals("many class", BiDirectional.class.getName(), manyToMany.attribute("class").getData()); assertEquals("many column", "FKbidirectional", manyToMany.attribute("column").getData()); }
protected void testNodes(String xpath, Class type) { List<Node> list = document.selectNodes(xpath); assertTrue("Results are not empty", !list.isEmpty()); for (Node node : list) { if (node instanceof Element) { Element element = (Element) node; testDataType(element, element.getData(), type); } else if (node instanceof Attribute) { Attribute attribute = (Attribute) node; testDataType(attribute, attribute.getData(), type); } else { assertTrue("Did not find an attribute or element: " + node, false); } } }
@Test(expectedExceptions = IllegalArgumentException.class) public void testAttributeWithNamespace() throws Exception { QName personName = factory.createQName("person", "t", "urn://testing"); QName ageName = factory.createQName("age", "t", "urn://testing"); Element person = factory.createElement(personName); person.addAttribute(ageName, "10"); Attribute age = person.attribute(ageName); assertTrue("Created DatatypeAttribute not correct", age instanceof DatatypeAttribute); log("Found attribute: " + age); Object data = age.getData(); Object expected = new BigInteger("10"); assertEquals("Data is correct type", BigInteger.class, data.getClass()); assertEquals("Set age correctly", expected, data); age.setValue("32"); data = age.getData(); expected = new BigInteger("32"); assertEquals("Set age correctly", expected, data); age.setValue("abc"); fail("Appeared to set an invalid value"); }