List of usage examples for org.w3c.dom Element hasAttribute
public boolean hasAttribute(String name);
true
when an attribute with a given name is specified on this element or has a default value, false
otherwise. From source file:com.googlecode.ehcache.annotations.config.AnnotationDrivenEhCacheBeanDefinitionParser.java
/** * Create a {@link CacheAttributeSource} bean that will be used by the advisor and interceptor * //from w w w. j a v a 2 s . co m * @return Reference to the {@link CacheAttributeSource}. Should never be null. */ protected RuntimeBeanReference setupCacheAttributeSource(Element element, ParserContext parserContext, Object elementSource) { final RuntimeBeanReference cachingReflectionHelper = this.setupCachingReflectionHelper(parserContext, elementSource); final RuntimeBeanReference defaultCacheKeyGenerator = this.setupDefaultCacheKeyGenerators(element, parserContext, elementSource); final RuntimeBeanReference defaultCacheResolverFactory = this.setupDefaultCacheResolverFactory(element, parserContext, elementSource); final RuntimeBeanReference defaultCacheableInterceptor = this.setupDefaultCacheableInterceptor(element, parserContext, elementSource); final RuntimeBeanReference defaultTriggersRemoveInterceptor = this .setupDefaultTriggersRemoveInterceptor(element, parserContext, elementSource); final RootBeanDefinition cacheAttributeSource = new RootBeanDefinition(CacheAttributeSourceImpl.class); cacheAttributeSource.setSource(elementSource); cacheAttributeSource.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); final MutablePropertyValues propertyValues = cacheAttributeSource.getPropertyValues(); RuntimeBeanReference cacheManagerReference = new RuntimeBeanReference( element.getAttribute(XSD_ATTR__CACHE_MANAGER)); propertyValues.addPropertyValue("cacheManager", cacheManagerReference); propertyValues.addPropertyValue("createCaches", Boolean.parseBoolean(element.getAttribute(XSD_ATTR__CREATE_MISSING_CACHES))); propertyValues.addPropertyValue("defaultCacheKeyGenerator", defaultCacheKeyGenerator); propertyValues.addPropertyValue("reflectionHelper", cachingReflectionHelper); if (defaultCacheResolverFactory != null) { propertyValues.addPropertyValue("cacheResolverFactory", defaultCacheResolverFactory); } if (defaultCacheableInterceptor != null) { propertyValues.addPropertyValue("defaultCacheableInterceptor", defaultCacheableInterceptor); } if (defaultTriggersRemoveInterceptor != null) { propertyValues.addPropertyValue("defaultTriggersRemoveInterceptor", defaultTriggersRemoveInterceptor); } final String blockingCacheScope = element.getAttribute(XSD_ATTR__SELF_POPULATING_CACHE_SCOPE); if (blockingCacheScope != null) { propertyValues.addPropertyValue("selfPopulatingCacheScope", SelfPopulatingCacheScope.valueOf(blockingCacheScope.toUpperCase())); } if (element.hasAttribute(XSD_ATTR__EXECUTOR)) { RuntimeBeanReference executorReference = new RuntimeBeanReference( element.getAttribute(XSD_ATTR__EXECUTOR)); propertyValues.addPropertyValue("executor", executorReference); } if (element.hasAttribute(XSD_ATTR__SCHEDULER)) { RuntimeBeanReference schedulerReference = new RuntimeBeanReference( element.getAttribute(XSD_ATTR__SCHEDULER)); propertyValues.addPropertyValue("scheduler", schedulerReference); } final XmlReaderContext readerContext = parserContext.getReaderContext(); final String cacheAttributeSourceBeanName = readerContext.registerWithGeneratedName(cacheAttributeSource); return new RuntimeBeanReference(cacheAttributeSourceBeanName); }
From source file:de.xwic.appkit.core.config.XmlConfigLoader.java
/** * @param element// w w w .ja v a 2 s . co m * @throws IOException * @throws ParseException * @throws ConfigurationException */ private void loadEntities(Domain domain, Element entityElem) throws IOException, ParseException { List<URL> editorFiles = new ArrayList<URL>(); List<ListSetupFileIconWrapper> listFiles = new ArrayList<ListSetupFileIconWrapper>(); Model model = null; if (!profileMode) { String depends = entityElem.getAttribute("depends"); if (depends != null && depends.length() != 0) { try { Domain dm = setup.getDomain(depends); if (dm.getModel() == null) { throw new ParseException("Dependend model not found: " + depends); } model = new Model(dm.getModel()); } catch (ConfigurationException e) { throw new ParseException("Invalid depends reference: " + depends); } } else { model = new Model(); } domain.setModel(model); } else { model = domain.getModel(); } NodeList nl = entityElem.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) node; if (element.getNodeName().equals("entity")) { // load specific attributes for the entity descriptor String fileName = element.getAttribute("file"); String className = element.getAttribute("class"); String iconKey = element.getAttribute("icon"); try { EntityDescriptor descriptor = null; if (fileName != null && fileName.length() > 0) { URL entityFile = new URL(location, fileName); fileList.add(entityFile); if (!headerOnly && !profileMode) { descriptor = XmlEntityDescriptorReader.loadEntityDescriptor(entityFile); descriptor.setDomain(domain); model.addEntityDescriptor(descriptor); } } else if (!profileMode) { try { descriptor = new EntityDescriptor( XmlEntityDescriptorReader.getClassLoader().loadClass(className)); descriptor.setDomain(domain); model.addEntityDescriptor(descriptor); } catch (Exception e) { throw new ParseException("Illegal entity class specified: " + e); } } if (null != descriptor) { descriptor.setIconKey(iconKey); } // register list and editor files to be loaded after the model // is completed NodeList nlEntity = element.getChildNodes(); for (int a = 0; a < nlEntity.getLength(); a++) { if (nlEntity.item(a).getNodeType() == Node.ELEMENT_NODE) { Element subElm = (Element) nlEntity.item(a); if (subElm.getNodeName().equals("list")) { URL listFile = new URL(location, subElm.getAttribute("file")); fileList.add(listFile); ListSetupFileIconWrapper wrapper = new ListSetupFileIconWrapper(); wrapper.setUrl(listFile); wrapper.setIconKey(subElm.getAttribute("icon")); listFiles.add(wrapper); } else if (subElm.getNodeName().equals("editor")) { URL editorFile = new URL(location, subElm.getAttribute("file")); fileList.add(editorFile); editorFiles.add(editorFile); } else if (subElm.getNodeName().equals("mailtemplate") && !profileMode) { String templateFile = subElm.getAttribute("file"); if (templateFile != null && templateFile.length() > 0) { URL emailTemplate = new URL(location, templateFile); fileList.add(emailTemplate); if (!headerOnly) { descriptor.setEmailTemplate(emailTemplate); } } } else if (subElm.getNodeName().equals("report") && !profileMode) { String templateFile = subElm.getAttribute("file"); if (templateFile != null && templateFile.length() > 0) { URL reportTemplate = new URL(location, templateFile); fileList.add(reportTemplate); if (!headerOnly) { ReportTemplate tpl = new ReportTemplate(); tpl.setLocation(reportTemplate); tpl.setFilePath(templateFile); if (subElm.hasAttribute("title")) { tpl.setTitle(subElm.getAttribute("title")); } if (subElm.hasAttribute("right")) { tpl.setRight(subElm.getAttribute("right")); } descriptor.addReportTemplate(tpl); } } } } } } catch (Exception e) { log.warn("Error loading EntityDescriptor for entity " + className + ". Skipping Descriptor! :" + e.toString()); } } } } if (!profileMode) { setup.addModel(model); } if (!headerOnly) { // load lists first for (Iterator<ListSetupFileIconWrapper> it = listFiles.iterator(); it.hasNext();) { ListSetupFileIconWrapper lFile = it.next(); ListSetup ls = XmlListSetupReader.loadListSetup(model, lFile.getUrl()); ls.setIconKey(lFile.getIconKey()); profile.addListSetup(ls); } // load editors for (Iterator<URL> it = editorFiles.iterator(); it.hasNext();) { URL eFile = it.next(); EditorConfiguration conf = XmlEditorConfigReader.readConfiguration(model, eFile); profile.addEditorConfiguration(conf); } } }
From source file:de.interactive_instruments.ShapeChange.Options.java
private ProcessMode parseMode(Element processElement) { ProcessMode result = ProcessMode.enabled; if (processElement.hasAttribute("mode")) { String mode = processElement.getAttribute("mode"); if (mode.equalsIgnoreCase("diagnostics-only")) { mode = "diagnosticsonly"; }//from ww w . j a v a 2 s . c o m result = ProcessMode.fromString(mode); } return result; }
From source file:org.romaz.spring.scripting.ext.ExtScriptBeanDefinitionParser.java
/** * Parses the dynamic object element and returns the resulting bean definition. * Registers a {@link ScriptFactoryPostProcessor} if needed. *//*from w w w. java 2s . c o m*/ @Override protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { // Resolve the script source. String value = resolveScriptSource(element, parserContext.getReaderContext()); if (value == null) { return null; } // Set up infrastructure. LangNamespaceUtils.registerScriptFactoryPostProcessorIfNecessary(parserContext.getRegistry()); // Create script factory bean definition. GenericBeanDefinition bd = new GenericBeanDefinition(); bd.setBeanClassName(this.scriptFactoryClassName); bd.setSource(parserContext.extractSource(element)); // Determine bean scope. String scope = element.getAttribute(SCOPE_ATTRIBUTE); if (StringUtils.hasLength(scope)) { bd.setScope(scope); } // Determine autowire mode. String autowire = element.getAttribute(AUTOWIRE_ATTRIBUTE); int autowireMode = parserContext.getDelegate().getAutowireMode(autowire); // Only "byType" and "byName" supported, but maybe other default inherited... if (autowireMode == GenericBeanDefinition.AUTOWIRE_AUTODETECT) { autowireMode = GenericBeanDefinition.AUTOWIRE_BY_TYPE; } else if (autowireMode == GenericBeanDefinition.AUTOWIRE_CONSTRUCTOR) { autowireMode = GenericBeanDefinition.AUTOWIRE_NO; } bd.setAutowireMode(autowireMode); // Determine dependency check setting. String dependencyCheck = element.getAttribute(DEPENDENCY_CHECK_ATTRIBUTE); bd.setDependencyCheck(parserContext.getDelegate().getDependencyCheck(dependencyCheck)); // Retrieve the defaults for bean definitions within this parser context BeanDefinitionDefaults beanDefinitionDefaults = parserContext.getDelegate().getBeanDefinitionDefaults(); // Determine init method and destroy method. String initMethod = element.getAttribute(INIT_METHOD_ATTRIBUTE); if (StringUtils.hasLength(initMethod)) { bd.setInitMethodName(initMethod); } else if (beanDefinitionDefaults.getInitMethodName() != null) { bd.setInitMethodName(beanDefinitionDefaults.getInitMethodName()); } String destroyMethod = element.getAttribute(DESTROY_METHOD_ATTRIBUTE); if (StringUtils.hasLength(destroyMethod)) { bd.setDestroyMethodName(destroyMethod); } else if (beanDefinitionDefaults.getDestroyMethodName() != null) { bd.setDestroyMethodName(beanDefinitionDefaults.getDestroyMethodName()); } // Attach any refresh metadata. String refreshCheckDelay = element.getAttribute(REFRESH_CHECK_DELAY_ATTRIBUTE); if (StringUtils.hasText(refreshCheckDelay)) { bd.setAttribute(ScriptFactoryPostProcessor.REFRESH_CHECK_DELAY_ATTRIBUTE, new Long(refreshCheckDelay)); } // Add constructor arguments. ConstructorArgumentValues cav = bd.getConstructorArgumentValues(); int constructorArgNum = 0; cav.addIndexedArgumentValue(constructorArgNum++, value); if (element.hasAttribute(SCRIPT_INTERFACES_ATTRIBUTE)) { cav.addIndexedArgumentValue(constructorArgNum++, element.getAttribute(SCRIPT_INTERFACES_ATTRIBUTE)); } if (element.hasAttribute(SCRIPT_CONFIG_ATTRIBUTE)) { cav.addIndexedArgumentValue(constructorArgNum++, new RuntimeBeanReference(element.getAttribute(SCRIPT_CONFIG_ATTRIBUTE))); } // Add any property definitions that need adding. parserContext.getDelegate().parsePropertyElements(element, bd); return bd; }
From source file:de.interactive_instruments.ShapeChange.Options.java
public void loadConfiguration() throws ShapeChangeAbortException { InputStream configStream = null; if (configFile == null) { // load minimal configuration, if no configuration file has been // provided configFile = "/config/minimal.xml"; configStream = getClass().getResourceAsStream(configFile); if (configStream == null) { configFile = "src/main/resources" + configFile; File file = new File(configFile); if (file.exists()) try { configStream = new FileInputStream(file); } catch (FileNotFoundException e1) { throw new ShapeChangeAbortException("Minimal configuration file not found: " + configFile); }/* ww w . jav a 2s . c om*/ else { URL url; String configURL = "http://shapechange.net/resources/config/minimal.xml"; try { url = new URL(configURL); configStream = url.openStream(); } catch (MalformedURLException e) { throw new ShapeChangeAbortException("Minimal configuration file not accessible from: " + configURL + " (malformed URL)"); } catch (IOException e) { throw new ShapeChangeAbortException( "Minimal configuration file not accessible from: " + configURL + " (IO error)"); } } } } else { File file = new File(configFile); if (file == null || !file.exists()) { try { configStream = (new URL(configFile)).openStream(); } catch (MalformedURLException e) { throw new ShapeChangeAbortException( "No configuration file found at " + configFile + " (malformed URL)"); } catch (IOException e) { throw new ShapeChangeAbortException( "No configuration file found at " + configFile + " (IO exception)"); } } else { try { configStream = new FileInputStream(file); } catch (FileNotFoundException e) { throw new ShapeChangeAbortException("No configuration file found at " + configFile); } } if (configStream == null) { throw new ShapeChangeAbortException("No configuration file found at " + configFile); } } DocumentBuilder builder = null; ShapeChangeErrorHandler handler = null; try { System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); factory.setValidating(true); factory.setFeature("http://apache.org/xml/features/validation/schema", true); factory.setIgnoringElementContentWhitespace(true); factory.setIgnoringComments(true); factory.setXIncludeAware(true); factory.setFeature("http://apache.org/xml/features/xinclude/fixup-base-uris", false); builder = factory.newDocumentBuilder(); handler = new ShapeChangeErrorHandler(); builder.setErrorHandler(handler); } catch (FactoryConfigurationError e) { throw new ShapeChangeAbortException("Unable to get a document builder factory."); } catch (ParserConfigurationException e) { throw new ShapeChangeAbortException("XML Parser was unable to be configured."); } // parse file try { Document document = builder.parse(configStream); if (handler.errorsFound()) { throw new ShapeChangeAbortException("Invalid configuration file."); } // parse input element specific content NodeList nl = document.getElementsByTagName("input"); Element inputElement = (Element) nl.item(0); if (inputElement.hasAttribute("id")) { inputId = inputElement.getAttribute("id").trim(); if (inputId.length() == 0) { inputId = null; } } else { inputId = Options.INPUTELEMENTID; } Map<String, String> inputParameters = new HashMap<String, String>(); nl = inputElement.getElementsByTagName("parameter"); for (int j = 0; j < nl.getLength(); j++) { Element e = (Element) nl.item(j); String key = e.getAttribute("name"); String val = e.getAttribute("value"); inputParameters.put(key, val); } Map<String, String> stereotypeAliases = new HashMap<String, String>(); nl = inputElement.getElementsByTagName("StereotypeAlias"); for (int j = 0; j < nl.getLength(); j++) { Element e = (Element) nl.item(j); String key = e.getAttribute("alias"); String val = e.getAttribute("wellknown"); // case shall be ignored key = key.toLowerCase(); val = val.toLowerCase(); stereotypeAliases.put(key, val); } Map<String, String> tagAliases = new HashMap<String, String>(); nl = inputElement.getElementsByTagName("TagAlias"); for (int j = 0; j < nl.getLength(); j++) { Element e = (Element) nl.item(j); String key = e.getAttribute("alias"); String val = e.getAttribute("wellknown"); // case not to be ignored for tagged values at the moment // key = key.toLowerCase(); // val = val.toLowerCase(); tagAliases.put(key, val); } Map<String, String> descriptorSources = new HashMap<String, String>(); nl = inputElement.getElementsByTagName("DescriptorSource"); for (int j = 0; j < nl.getLength(); j++) { Element e = (Element) nl.item(j); String key = e.getAttribute("descriptor"); String val = e.getAttribute("source"); // case shall be ignored for descriptor and source key = key.toLowerCase(); val = val.toLowerCase(); if (val.equals("sc:extract")) { String s = e.getAttribute("token"); val += "#" + (s == null ? "" : s); } else if (val.equals("tag")) { String s = e.getAttribute("tag"); val += "#" + (s == null ? "" : s); } descriptorSources.put(key, val); } Map<String, PackageInfoConfiguration> packageInfos = parsePackageInfos(inputElement); this.inputConfig = new InputConfiguration(inputId, inputParameters, stereotypeAliases, tagAliases, descriptorSources, packageInfos); // parse dialog specific parameters nl = document.getElementsByTagName("dialog"); if (nl != null && nl.getLength() != 0) { for (int k = 0; k < nl.getLength(); k++) { Node node = nl.item(k); if (node.getNodeType() == Node.ELEMENT_NODE) { Element dialogElement = (Element) node; this.dialogParameters = parseParameters(dialogElement, "parameter"); } } } // parse log specific parameters nl = document.getElementsByTagName("log"); if (nl != null && nl.getLength() != 0) { for (int k = 0; k < nl.getLength(); k++) { Node node = nl.item(k); if (node.getNodeType() == Node.ELEMENT_NODE) { Element logElement = (Element) node; this.logParameters = parseParameters(logElement, "parameter"); } } } // add standard rules, just so that configured rules can be // validated addStandardRules(); // Load transformer configurations (if any are provided in the // configuration file) Map<String, TransformerConfiguration> transformerConfigs = parseTransformerConfigurations(document); // Load target configurations this.targetConfigs = parseTargetConfigurations(document); this.resetFields(); // this.resetUponLoadFlag = false; // TBD discuss if there's a better way to support rule and // requirements matching for the input model // TBD apparently the matching requires all // applicable encoding rules to be known up front for (TargetConfiguration tgtConfig : targetConfigs) { // System.out.println(tgtConfig); String className = tgtConfig.getClassName(); String mode = tgtConfig.getProcessMode().name(); // set targets and their mode; if a target occurs multiple // times, keep the enabled one(s) if (!this.fTargets.containsKey(className)) { addTarget(className, mode); } else { if (this.fTargets.get(className).equals(ProcessMode.disabled)) { // set targets and their mode; if a target occurs // multiple times, keep the enabled one(s) addTarget(className, mode); } } // ensure that we have all the rules from all non-disabled // targets // we repeat this for the same target (if it is not disabled) to // ensure that we get the union of all encoding rules if (!tgtConfig.getProcessMode().equals(ProcessMode.disabled)) { for (ProcessRuleSet prs : tgtConfig.getRuleSets().values()) { String nam = prs.getName(); String ext = prs.getExtendedRuleSetName(); addExtendsEncRule(nam, ext); if (prs.hasAdditionalRules()) { for (String rule : prs.getAdditionalRules()) { addRule(rule, nam); } } } } /* * looks like we also need parameters like defaultEncodingRule * !!! IF THERE ARE DIFFERENT DEFAULT ENCODING RULES FOR * DIFFERENT TARGETS (WITH SAME CLASS) THIS WONT WORK!!! */ for (String paramName : tgtConfig.getParameters().keySet()) { setParameter(className, paramName, tgtConfig.getParameters().get(paramName)); } // in order for the input model load not to produce warnings, // we also need to load the map entries if (tgtConfig instanceof TargetXmlSchemaConfiguration) { TargetXmlSchemaConfiguration config = (TargetXmlSchemaConfiguration) tgtConfig; // add xml schema namespace information for (XmlNamespace xns : config.getXmlNamespaces()) { addNamespace(xns.getNsabr(), xns.getNs(), xns.getLocation()); // if (xns.getLocation() != null) { addSchemaLocation(xns.getNs(), xns.getLocation()); // } } // add xsd map entries for (XsdMapEntry xsdme : config.getXsdMapEntries()) { for (String xsdEncodingRule : xsdme.getEncodingRules()) { String type = xsdme.getType(); String xmlPropertyType = xsdme.getXmlPropertyType(); String xmlElement = xsdme.getXmlElement(); String xmlTypeContent = xsdme.getXmlTypeContent(); String xmlTypeNilReason = xsdme.getXmlTypeNilReason(); String xmlType = xsdme.getXmlType(); String xmlTypeType = xsdme.getXmlTypeType(); String xmlAttribute = xsdme.getXmlAttribute(); String xmlAttributeGroup = xsdme.getXmlAttributeGroup(); if (xmlPropertyType != null) { if (xmlPropertyType.equals("_P_") && xmlElement != null) { addTypeMapEntry(type, xsdEncodingRule, "propertyType", xmlElement); } else if (xmlPropertyType.equals("_MP_") && xmlElement != null) { addTypeMapEntry(type, xsdEncodingRule, "metadataPropertyType", xmlElement); } else { addTypeMapEntry(type, xsdEncodingRule, "direct", xmlPropertyType, xmlTypeType + "/" + xmlTypeContent, xmlTypeNilReason); } } if (xmlElement != null) { addElementMapEntry(type, xsdEncodingRule, "direct", xmlElement); } if (xmlType != null) { addBaseMapEntry(type, xsdEncodingRule, "direct", xmlType, xmlTypeType + "/" + xmlTypeContent); } if (xmlAttribute != null) { addAttributeMapEntry(type, xsdEncodingRule, xmlAttribute); } if (xmlAttributeGroup != null) { addAttributeGroupMapEntry(type, xsdEncodingRule, xmlAttributeGroup); } } } } else { // add map entries for Target (no need to do this for // transformers) for (ProcessMapEntry pme : tgtConfig.getMapEntries()) { addTargetTypeMapEntry(tgtConfig.getClassName(), pme.getType(), pme.getRule(), pme.getTargetType(), pme.getParam()); } } } // create "tree" for (TargetConfiguration tgtConfig : targetConfigs) { for (String inputIdref : tgtConfig.getInputIds()) { if (inputIdref.equals(getInputId())) { this.inputTargetConfigs.add(tgtConfig); } else { transformerConfigs.get(inputIdref).addTarget(tgtConfig); } } } for (TransformerConfiguration trfConfig : transformerConfigs.values()) { String inputIdref = trfConfig.getInputId(); if (inputIdref.equals(getInputId())) { this.inputTransformerConfigs.add(trfConfig); } else { transformerConfigs.get(inputIdref).addTransformer(trfConfig); } } // Determine constraint creation handling parameters: String classTypesToCreateConstraintsFor = parameter("classTypesToCreateConstraintsFor"); if (classTypesToCreateConstraintsFor != null) { classTypesToCreateConstraintsFor = classTypesToCreateConstraintsFor.trim(); if (classTypesToCreateConstraintsFor.length() > 0) { String[] stereotypes = classTypesToCreateConstraintsFor.split("\\W*,\\W*"); this.classTypesToCreateConstraintsFor = new HashSet<Integer>(); for (String stereotype : stereotypes) { String sForCons = stereotype.toLowerCase(); if (sForCons.equals("enumeration")) { this.classTypesToCreateConstraintsFor.add(new Integer(ENUMERATION)); } else if (sForCons.equals("codelist")) { this.classTypesToCreateConstraintsFor.add(new Integer(CODELIST)); } else if (sForCons.equals("schluesseltabelle")) { this.classTypesToCreateConstraintsFor.add(new Integer(OKSTRAKEY)); } else if (sForCons.equals("fachid")) { this.classTypesToCreateConstraintsFor.add(new Integer(OKSTRAFID)); } else if (sForCons.equals("datatype")) { this.classTypesToCreateConstraintsFor.add(new Integer(DATATYPE)); } else if (sForCons.equals("union")) { this.classTypesToCreateConstraintsFor.add(new Integer(UNION)); } else if (sForCons.equals("featureconcept")) { this.classTypesToCreateConstraintsFor.add(new Integer(FEATURECONCEPT)); } else if (sForCons.equals("attributeconcept")) { this.classTypesToCreateConstraintsFor.add(new Integer(ATTRIBUTECONCEPT)); } else if (sForCons.equals("valueconcept")) { this.classTypesToCreateConstraintsFor.add(new Integer(VALUECONCEPT)); } else if (sForCons.equals("interface")) { this.classTypesToCreateConstraintsFor.add(new Integer(MIXIN)); } else if (sForCons.equals("basictype")) { this.classTypesToCreateConstraintsFor.add(new Integer(BASICTYPE)); } else if (sForCons.equals("adeelement")) { this.classTypesToCreateConstraintsFor.add(new Integer(FEATURE)); } else if (sForCons.equals("featuretype")) { this.classTypesToCreateConstraintsFor.add(new Integer(FEATURE)); } else if (sForCons.equals("type")) { this.classTypesToCreateConstraintsFor.add(new Integer(OBJECT)); } else { this.classTypesToCreateConstraintsFor.add(new Integer(UNKNOWN)); } } } } String constraintCreationForProperties = parameter("constraintCreationForProperties"); if (constraintCreationForProperties != null) { if (constraintCreationForProperties.trim().equalsIgnoreCase("false")) { this.constraintCreationForProperties = false; } } /* * TODO add documentation */ String ignoreEncodingRuleTaggedValues = parameter("ignoreEncodingRuleTaggedValues"); if (ignoreEncodingRuleTaggedValues != null) { if (ignoreEncodingRuleTaggedValues.trim().equalsIgnoreCase("true")) { this.ignoreEncodingRuleTaggedValues = true; } } String useStringInterning_value = parameter(PARAM_USE_STRING_INTERNING); if (useStringInterning_value != null && useStringInterning_value.trim().equalsIgnoreCase("true")) { this.useStringInterning = true; } String loadGlobalIds_value = this.parameter(PARAM_LOAD_GLOBAL_IDENTIFIERS); if (loadGlobalIds_value != null && loadGlobalIds_value.trim().equalsIgnoreCase("true")) { this.loadGlobalIds = true; } String language_value = inputConfig.getParameters().get(PARAM_LANGUAGE); if (language_value != null && !language_value.trim().isEmpty()) { this.language = language_value.trim().toLowerCase(); } } catch (SAXException e) { String m = e.getMessage(); if (m != null) { throw new ShapeChangeAbortException( "Error while loading configuration file: " + System.getProperty("line.separator") + m); } else { e.printStackTrace(System.err); throw new ShapeChangeAbortException("Error while loading configuration file: " + System.getProperty("line.separator") + System.err); } } catch (IOException e) { String m = e.getMessage(); if (m != null) { throw new ShapeChangeAbortException( "Error while loading configuration file: " + System.getProperty("line.separator") + m); } else { e.printStackTrace(System.err); throw new ShapeChangeAbortException("Error while loading configuration file: " + System.getProperty("line.separator") + System.err); } } MapEntry nsme = namespace("gml"); if (nsme != null) { GML_NS = nsme.rule; } }
From source file:de.interactive_instruments.ShapeChange.Options.java
/** * @param trfE//from www .ja v a 2 s . c om * "Transformer" element from the configuration * @return list of tagged values defined for the transformer or * <code>null</code> if no tagged values are defined for it. */ private List<TaggedValueConfigurationEntry> parseTaggedValues(Element trfE) { List<TaggedValueConfigurationEntry> result = new ArrayList<TaggedValueConfigurationEntry>(); Element directTaggedValuesInTrf = null; /* * identify taggedValues element that is direct child of the Transformer * element - can be null */ NodeList children = trfE.getChildNodes(); if (children != null && children.getLength() != 0) { for (int k = 0; k < children.getLength(); k++) { Node n = children.item(k); if (n.getNodeType() == Node.ELEMENT_NODE && n.getNodeName().equals("taggedValues")) { directTaggedValuesInTrf = (Element) n; break; } } } if (directTaggedValuesInTrf != null) { NodeList taggedValuesNl = directTaggedValuesInTrf.getElementsByTagName("TaggedValue"); Node taggedValueN; Element taggedValueE; if (taggedValuesNl != null && taggedValuesNl.getLength() > 0) { for (int k = 0; k < taggedValuesNl.getLength(); k++) { taggedValueN = taggedValuesNl.item(k); if (taggedValueN.getNodeType() == Node.ELEMENT_NODE) { taggedValueE = (Element) taggedValueN; String value = null; if (taggedValueE.hasAttribute("value")) { value = taggedValueE.getAttribute("value"); } Pattern modelElementNamePattern = null; if (taggedValueE.hasAttribute("modelElementName")) { String modelElementName = taggedValueE.getAttribute("modelElementName"); modelElementNamePattern = Pattern.compile(modelElementName); } Pattern modelElementStereotypePattern = null; if (taggedValueE.hasAttribute("modelElementStereotype")) { String modelElementStereotype = taggedValueE.getAttribute("modelElementStereotype"); modelElementStereotypePattern = Pattern.compile(modelElementStereotype); } Pattern applicationSchemaNamePattern = null; if (taggedValueE.hasAttribute("applicationSchemaName")) { String applicationSchemaName = taggedValueE.getAttribute("applicationSchemaName"); applicationSchemaNamePattern = Pattern.compile(applicationSchemaName); } result.add(new TaggedValueConfigurationEntry(taggedValueE.getAttribute("name"), value, modelElementStereotypePattern, modelElementNamePattern, applicationSchemaNamePattern)); } } } } if (result.isEmpty()) return null; else return result; }
From source file:de.interactive_instruments.ShapeChange.Options.java
private List<Namespace> parseNamespaces(Element targetElement) { List<Namespace> result = new ArrayList<Namespace>(); NodeList namespacesNl = targetElement.getElementsByTagName("Namespace"); Node namespaceN;/* w ww .j av a2s .com*/ Element namespaceE; if (namespacesNl != null && namespacesNl.getLength() != 0) { for (int k = 0; k < namespacesNl.getLength(); k++) { namespaceN = namespacesNl.item(k); if (namespaceN.getNodeType() == Node.ELEMENT_NODE) { namespaceE = (Element) namespaceN; String nsabr = namespaceE.getAttribute("nsabr"); String ns = namespaceE.getAttribute("ns"); String location = namespaceE.hasAttribute("location") ? location = namespaceE.getAttribute("location") : null; result.add(new Namespace(nsabr, ns, location)); } } } return result; }
From source file:de.interactive_instruments.ShapeChange.Options.java
private List<XmlNamespace> parseXmlNamespaces(Element targetXmlSchemaElement) { List<XmlNamespace> result = new ArrayList<XmlNamespace>(); NodeList xmlNamespacesNl = targetXmlSchemaElement.getElementsByTagName("XmlNamespace"); Node xmlNamespaceN;// w w w . j a v a2 s . c o m Element xmlNamespaceE; if (xmlNamespacesNl != null && xmlNamespacesNl.getLength() != 0) { for (int k = 0; k < xmlNamespacesNl.getLength(); k++) { xmlNamespaceN = xmlNamespacesNl.item(k); if (xmlNamespaceN.getNodeType() == Node.ELEMENT_NODE) { xmlNamespaceE = (Element) xmlNamespaceN; String nsabr = xmlNamespaceE.getAttribute("nsabr"); String ns = xmlNamespaceE.getAttribute("ns"); String location = xmlNamespaceE.hasAttribute("location") ? location = xmlNamespaceE.getAttribute("location") : null; String packageName = xmlNamespaceE.hasAttribute("packageName") ? xmlNamespaceE.getAttribute("packageName") : null; result.add(new XmlNamespace(nsabr, ns, location, packageName)); } } } return result; }
From source file:de.interactive_instruments.ShapeChange.Options.java
/** * Parses the given process element and returns a map of all map entries it * contains./*from ww w .ja v a 2 s . c o m*/ * * @param processElement * A Transformer or Target element from the * ShapeChangeConfiguration * @param string * @return map of the map entries contained in the process element (key: * ProcessMapEntry type) */ private List<ProcessMapEntry> parseProcessMapEntries(Element processElement, String mapEntryElementTagName) { List<ProcessMapEntry> result = new ArrayList<ProcessMapEntry>(); NodeList processMapEntriesNl = processElement.getElementsByTagName(mapEntryElementTagName); Node processMapEntryN; Element processMapEntryE; if (processMapEntriesNl != null && processMapEntriesNl.getLength() != 0) { for (int k = 0; k < processMapEntriesNl.getLength(); k++) { processMapEntryN = processMapEntriesNl.item(k); if (processMapEntryN.getNodeType() == Node.ELEMENT_NODE) { processMapEntryE = (Element) processMapEntryN; String type = processMapEntryE.getAttribute("type"); String rule = processMapEntryE.getAttribute("rule"); String targetType = processMapEntryE.hasAttribute("targetType") ? processMapEntryE.getAttribute("targetType") : null; String param = processMapEntryE.hasAttribute("param") ? processMapEntryE.getAttribute("param") : null; result.add(new ProcessMapEntry(type, rule, targetType, param)); } } } return result; }
From source file:lucee.runtime.config.ConfigWebFactory.java
/** * loads datasource settings from XMl DOM * //from w w w .j av a 2 s . c o m * @param configServer * @param config * @param doc * @throws ClassNotFoundException */ private static void loadDataSources(ConfigServerImpl configServer, ConfigImpl config, Document doc) throws ClassException { // When set to true, makes JDBC use a representation for DATE data that // is compatible with the Oracle8i database. System.setProperty("oracle.jdbc.V8Compatible", "true"); boolean hasCS = configServer != null; Map<String, DataSource> datasources = new HashMap<String, DataSource>(); // Copy Parent datasources as readOnly if (hasCS) { Map<String, DataSource> ds = configServer.getDataSourcesAsMap(); Iterator<Entry<String, DataSource>> it = ds.entrySet().iterator(); Entry<String, DataSource> entry; while (it.hasNext()) { entry = it.next(); if (!entry.getKey().equals(QOQ_DATASOURCE_NAME)) datasources.put(entry.getKey(), entry.getValue().cloneReadOnly()); } } // TODO support H2 // Default query of query DB /* * setDatasource(datasources, QOQ_DATASOURCE_NAME, "org.h2.Driver" ,"" ,"" * ,-1 ,"jdbc:h2:.;MODE=HSQLDB" ,"sa" ,"" ,-1 ,-1 ,true ,true * ,DataSource.ALLOW_ALL, new StructImpl() ); */ // Default query of query DB setDatasource(config, datasources, QOQ_DATASOURCE_NAME, "org.hsqldb.jdbcDriver", "", "", -1, "jdbc:hsqldb:.", "sa", "", -1, -1, 60000, true, true, DataSource.ALLOW_ALL, false, false, null, new StructImpl(), ""); SecurityManager sm = config.getSecurityManager(); short access = sm.getAccess(SecurityManager.TYPE_DATASOURCE); int accessCount = -1; if (access == SecurityManager.VALUE_YES) accessCount = -1; else if (access == SecurityManager.VALUE_NO) accessCount = 0; else if (access >= SecurityManager.VALUE_1 && access <= SecurityManager.VALUE_10) { accessCount = access - SecurityManager.NUMBER_OFFSET; } // Databases Element databases = getChildByName(doc.getDocumentElement(), "data-sources"); // if(databases==null)databases=doc.createElement("data-sources"); // PSQ String strPSQ = databases.getAttribute("psq"); if (StringUtil.isEmpty(strPSQ)) { // prior version was buggy, was the opposite strPSQ = databases.getAttribute("preserve-single-quote"); if (!StringUtil.isEmpty(strPSQ)) { Boolean b = Caster.toBoolean(strPSQ, null); if (b != null) strPSQ = b.booleanValue() ? "false" : "true"; } } if (access != SecurityManager.VALUE_NO && !StringUtil.isEmpty(strPSQ)) { config.setPSQL(toBoolean(strPSQ, true)); } else if (hasCS) config.setPSQL(configServer.getPSQL()); // Data Sources Element[] dataSources = getChildren(databases, "data-source"); if (accessCount == -1) accessCount = dataSources.length; if (dataSources.length < accessCount) accessCount = dataSources.length; // if(hasAccess) { for (int i = 0; i < accessCount; i++) { Element dataSource = dataSources[i]; if (dataSource.hasAttribute("database")) { setDatasourceEL(config, datasources, dataSource.getAttribute("name"), deRailo(dataSource.getAttribute("class")), dataSource.getAttribute("host"), dataSource.getAttribute("database"), toInt(dataSource.getAttribute("port"), -1), dataSource.getAttribute("dsn"), dataSource.getAttribute("username"), decrypt(dataSource.getAttribute("password")), toInt(dataSource.getAttribute("connectionLimit"), -1), toInt(dataSource.getAttribute("connectionTimeout"), -1), toLong(dataSource.getAttribute("metaCacheTimeout"), 60000), toBoolean(dataSource.getAttribute("blob"), true), toBoolean(dataSource.getAttribute("clob"), true), toInt(dataSource.getAttribute("allow"), DataSource.ALLOW_ALL), toBoolean(dataSource.getAttribute("validate"), false), toBoolean(dataSource.getAttribute("storage"), false), dataSource.getAttribute("timezone"), toStruct(dataSource.getAttribute("custom")), dataSource.getAttribute("dbdriver")); } } // } config.setDataSources(datasources); }