org.dom4j.Attribute Java Examples

The following examples show how to use org.dom4j.Attribute. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VersionProperty.java    From jfinal-api-scaffold with MIT License 6 votes vote down vote up
public void setVersion(ClientType type, String version) {
    Element clientElement = null;
    switch (type) {
        case ANDROID:
            clientElement = getElement("client.android");
            break;
        case IPHONE:
            clientElement = getElement("client.iphone");
            break;
        default:
            return;
    }

    Attribute attribute = clientElement.attribute("default");

    if (attribute != null) {
        attribute.setValue(version);
        saveProperties();
    }
}
 
Example #2
Source File: MaterialParser.java    From olat with Apache License 2.0 6 votes vote down vote up
/**
*/
  @Override
  public Object parse(final Element element) {
      // assert element.getName().equalsIgnoreCase("material");

      final List materials = element.elements();
      if (materials.size() == 0) {
          return null;
      }

      final Material material = new Material();
      // ATTRIBUTES
      final Attribute label = element.attribute("label");
      if (label != null) {
          material.setLable(label.getValue());
      }

      // ELEMENTS
      for (final Iterator i = materials.iterator(); i.hasNext();) {
          final QTIObject obj = (QTIObject) parserManager.parse((Element) i.next());
          if (obj != null) {
              material.getElements().add(obj);
          }
      }
      return material;
  }
 
Example #3
Source File: XMLProperties.java    From Openfire with Apache License 2.0 6 votes vote down vote up
/**
 * Removes the given attribute from the XML document.
 *
 * @param name the property name to lookup - ie, "foo.bar"
 * @param attribute the name of the attribute, ie "id"
 * @return the value of the attribute of the given property or {@code null} if
 *      it did not exist.
 */
public String removeAttribute(String name, String attribute) {
    if (name == null || attribute == null) {
        return null;
    }
    String[] propName = parsePropertyName(name);
    // Search for this property by traversing down the XML hierarchy.
    Element element = document.getRootElement();
    for (String child : propName) {
        element = element.element(child);
        if (element == null) {
            // This node doesn't match this part of the property name which
            // indicates this property doesn't exist so return empty array.
            break;
        }
    }
    String result = null;
    if (element != null) {
        // Get the attribute value and then remove the attribute
        Attribute attr = element.attribute(attribute);
        result = attr.getValue();
        element.remove(attr);
    }
    return result;
}
 
Example #4
Source File: WeChatFactory.java    From wechat-framework with GNU General Public License v2.0 6 votes vote down vote up
private void loadHandles() {
    try {
        SAXReader reader = new SAXReader();
        Document document = reader.read(WeChatFactory.class.getResourceAsStream(config));
        Element list = document.getRootElement();
        List<Element> elements = list.elements();
        for (Element element : elements) {
            if (element.getName().equals("bean")) {
                Attribute className = element.attribute("class");
                log.debug(className.getStringValue());
                handles.add(loadClass(className.getStringValue()));
            }
        }
    } catch (Exception e) {
        log.error("", e);
    }
}
 
Example #5
Source File: LowercaseTableNames.java    From unitime with Apache License 2.0 6 votes vote down vote up
protected void writeAttributes(Element element) throws IOException {
    for (int i = 0, size = element.attributeCount(); i < size; i++) {
        Attribute attribute = element.attribute(i);
           char quote = format.getAttributeQuoteCharacter();
           if (element.attributeCount() > 2) {
               writePrintln();
               indent();
               writer.write(format.getIndent());
           } else {
           	writer.write(" ");
           }
           writer.write(attribute.getQualifiedName());
           writer.write("=");
           writer.write(quote);
           writeEscapeAttributeEntities(attribute.getValue());
           writer.write(quote);
    }
}
 
Example #6
Source File: ManifestFileUtils.java    From atlas with Apache License 2.0 6 votes vote down vote up
public static String getVersionCode(File androidManifestFile) throws IOException, DocumentException {
    SAXReader reader = new SAXReader();
    String versionCode = "";
    if (androidManifestFile.exists()) {
        Document document = reader.read(androidManifestFile);// Read the XML file
        Element root = document.getRootElement();// Get the root node
        if ("manifest".equalsIgnoreCase(root.getName())) {
            List<Attribute> attributes = root.attributes();
            for (Attribute attr : attributes) {
                if (StringUtils.equalsIgnoreCase(attr.getName(), "versionCode")) {
                    versionCode = attr.getValue();
                }
            }
        }
    }
    return versionCode;
}
 
Example #7
Source File: ManifestFileUtils.java    From atlas with Apache License 2.0 6 votes vote down vote up
/**
 * Update the plug-in's minSdkVersion and targetSdkVersion
 *
 * @param androidManifestFile
 * @throws IOException
 * @throws DocumentException
 */
public static String getVersionName(File androidManifestFile) throws IOException, DocumentException {
    SAXReader reader = new SAXReader();
    String versionName = "";
    if (androidManifestFile.exists()) {
        Document document = reader.read(androidManifestFile);// Read the XML file
        Element root = document.getRootElement();// Get the root node
        if ("manifest".equalsIgnoreCase(root.getName())) {
            List<Attribute> attributes = root.attributes();
            for (Attribute attr : attributes) {
                if (StringUtils.equalsIgnoreCase(attr.getName(), "versionName")) {
                    versionName = attr.getValue();
                }
            }
        }
    }
    return versionName;
}
 
Example #8
Source File: ManifestFileUtils.java    From atlas with Apache License 2.0 6 votes vote down vote up
/**
 * Update the attributes of element
 *
 * @param element
 * @param properties
 */
private static void updateElement(Element element, Map<String, String> properties) {
    for (Map.Entry<String, String> entry : properties.entrySet()) {
        String key = entry.getKey();
        if (key.startsWith("tools:")) {
            continue;
        }
        String keyNoPrefix = key;
        String[] values = StringUtils.split(key, ":");
        if (values.length > 1) {
            keyNoPrefix = values[1];
        }
        if (null == entry.getValue()) {
            continue;
        } else {
            Attribute attribute = element.attribute(keyNoPrefix);
            if (null != attribute) {
                attribute.setValue(entry.getValue());
            } else {
                element.addAttribute(key, entry.getValue());
            }
        }
    }
}
 
Example #9
Source File: Update1To2.java    From jeveassets with GNU General Public License v2.0 6 votes vote down vote up
private String convertFlag(final Document doc) {
	XPath flagSelector = DocumentHelper.createXPath("/settings/flags/flag");
	List<?> flagResults = flagSelector.selectNodes(doc);
	boolean text = false;
	boolean window = false;
	for (Iterator<?> iter = flagResults.iterator(); iter.hasNext();) {
		Element element = (Element) iter.next();
		Attribute key = element.attribute("key");
		Attribute visible = element.attribute("enabled");
		if (key.getText().equals("FLAG_AUTO_RESIZE_COLUMNS_TEXT")) {
			text = visible.getText().equals("true");
			element.detach();
		}
		if (key.getText().equals("FLAG_AUTO_RESIZE_COLUMNS_WINDOW")) {
			window = visible.getText().equals("true");
			element.detach();
		}
	}
	if (text) {
		return "TEXT";
	}
	if (window) {
		return "WINDOW";
	}
	return "NONE";
}
 
Example #10
Source File: XmppStreamOpen.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public String toXml() {
    StringWriter out = new StringWriter();
    XMLWriter writer = new XMLWriter(out, OutputFormat.createCompactFormat());
    try {
        out.write("<");
        writer.write(element.getQualifiedName());
        for (Attribute attr : (List<Attribute>) element.attributes()) {
            writer.write(attr);
        }
        writer.write(Namespace.get(this.element.getNamespacePrefix(), this.element.getNamespaceURI()));
        writer.write(Namespace.get("jabber:client"));
        out.write(">");
    } catch (IOException ex) {
        log.info("Error writing XML", ex);
    }
    return out.toString();
}
 
Example #11
Source File: SelectTagTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
private void validateOutput(String output, boolean selected) throws DocumentException {
	SAXReader reader = new SAXReader();
	Document document = reader.read(new StringReader(output));
	Element rootElement = document.getRootElement();
	assertEquals("select", rootElement.getName());
	assertEquals("country", rootElement.attribute("name").getValue());

	List children = rootElement.elements();
	assertEquals("Incorrect number of children", 4, children.size());

	Element e = (Element) rootElement.selectSingleNode("option[@value = 'UK']");
	Attribute selectedAttr = e.attribute("selected");
	if (selected) {
		assertTrue(selectedAttr != null && "selected".equals(selectedAttr.getValue()));
	}
	else {
		assertNull(selectedAttr);
	}
}
 
Example #12
Source File: TestSummaryCreatorTask.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the value of the specified attribute of the node determined by the given xpath.
 * 
 * @param doc      The XML document
 * @param xpath    The xpath selecting the node whose attribute we want
 * @param attrName The name of the attribute
 * @return The attribute value
 */
private String getAttrValue(Document doc, String xpath, String attrName)
{
	Node node = doc.selectSingleNode(xpath);

	if (node instanceof Attribute)
	{
		// we ignore the attribute name then
		return ((Attribute)node).getValue();
	}
	else if (node != null)
	{
		return node.valueOf("@" + attrName);
	}
    else
    {
        return null;
    }
}
 
Example #13
Source File: ManifestFileUtils.java    From atlas with Apache License 2.0 6 votes vote down vote up
private static void singleProcess(Document document, String applicationId) {
        List<Node> nodes = document.getRootElement().selectNodes("//provider");
    for (Node node : nodes) {
        Element element = (Element)node;
        String value = element.attributeValue("name");
        if (value.equals(INSTANT_RUN_CONTENTPROVIDER)){
            element.addAttribute("name",ALI_INSTANT_RUN_CONTENTPROVIDER);
            element.addAttribute("authorities",applicationId+"."+ALI_INSTANT_RUN_CONTENTPROVIDER);
            Attribute attribute = element.attribute("multiprocess");
            if (attribute!= null) {
                attribute.setValue("false");
                logger.warn("singleProcess  com.android.tools.ir.server.InstantRunContentProvider.......");
            }

        }

    }

}
 
Example #14
Source File: CheckMessages.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Attribute checkAttribute(Node node, String attrName) throws DocumentException {
    if (!(node instanceof Element)) {
        throw new CheckMessagesException("Node is not an element", this, node);
    }
    Element element = (Element) node;
    Attribute attr = element.attribute(attrName);
    if (attr == null) {
        throw new CheckMessagesException("Missing " + attrName + " attribute", this, node);
    }
    return attr;
}
 
Example #15
Source File: HbmBinder.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static void bindManyToOne(Element node, ManyToOne manyToOne, String path,
		boolean isNullable, Mappings mappings) throws MappingException {

	bindColumnsOrFormula( node, manyToOne, path, isNullable, mappings );
	initOuterJoinFetchSetting( node, manyToOne );
	initLaziness( node, manyToOne, mappings, true );

	Attribute ukName = node.attribute( "property-ref" );
	if ( ukName != null ) {
		manyToOne.setReferencedPropertyName( ukName.getValue() );
	}

	manyToOne.setReferencedEntityName( getEntityName( node, mappings ) );

	String embed = node.attributeValue( "embed-xml" );
	manyToOne.setEmbedded( embed == null || "true".equals( embed ) );

	String notFound = node.attributeValue( "not-found" );
	manyToOne.setIgnoreNotFound( "ignore".equals( notFound ) );

	if( ukName != null && !manyToOne.isIgnoreNotFound() ) {
		if ( !node.getName().equals("many-to-many") ) { //TODO: really bad, evil hack to fix!!!
			mappings.addSecondPass( new ManyToOneSecondPass(manyToOne) );
		}
	}

	Attribute fkNode = node.attribute( "foreign-key" );
	if ( fkNode != null ) manyToOne.setForeignKeyName( fkNode.getValue() );

	validateCascade( node, path );
}
 
Example #16
Source File: Update1To2.java    From jeveassets with GNU General Public License v2.0 5 votes vote down vote up
private void convertDefaultPriceModes(final Document doc) {
	XPath xpathSelector = DocumentHelper.createXPath("/settings/marketstat");
	List<?> results = xpathSelector.selectNodes(doc);
	for (Iterator<?> iter = results.iterator(); iter.hasNext();) {
		Element elem = (Element) iter.next();
		Attribute attr = elem.attribute("defaultprice");
		if (attr != null) { //May not exist (in early versions)
			String currentValue = attr.getText();
			attr.setText(convertDefaultPriceMode(currentValue));
		}
	}
}
 
Example #17
Source File: JPAOverriddenAnnotationReader.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private IdClass getIdClass(Element tree, XMLContext.Default defaults) {
	Element element = tree == null ? null : tree.element( "id-class" );
	if ( element != null ) {
		Attribute attr = element.attribute( "class" );
		if ( attr != null ) {
			AnnotationDescriptor ad = new AnnotationDescriptor( IdClass.class );
			Class clazz;
			try {
				clazz = classLoaderAccess.classForName( XMLContext.buildSafeClassName( attr.getValue(), defaults )
				);
			}
			catch ( ClassLoadingException e ) {
				throw new AnnotationException( "Unable to find id-class: " + attr.getValue(), e );
			}
			ad.setValue( "value", clazz );
			return AnnotationFactory.create( ad );
		}
		else {
			throw new AnnotationException( "id-class without class. " + SCHEMA_VALIDATION );
		}
	}
	else if ( defaults.canUseJavaAnnotations() ) {
		return getPhysicalAnnotation( IdClass.class );
	}
	else {
		return null;
	}
}
 
Example #18
Source File: HbmBinder.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static final void makeVersion(Element node, SimpleValue model) {

		// VERSION UNSAVED-VALUE
		Attribute nullValueNode = node.attribute( "unsaved-value" );
		if ( nullValueNode != null ) {
			model.setNullValue( nullValueNode.getValue() );
		}
		else {
			model.setNullValue( "undefined" );
		}

	}
 
Example #19
Source File: XMLToObject.java    From FoxBPM with Apache License 2.0 5 votes vote down vote up
/**
 * 处理属性
 * 
 * @param element
 * @param paramObj
 * @param temp
 * @throws InvocationTargetException
 * @throws IllegalAccessException
 * @throws IllegalArgumentException
 */
private void doAttributes(Element element, Object paramObj, Map<String, Method> methods)
    throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
	// 处理element属性
	Method method = null;
	Attribute attribute = null;
	for (int i = 0, length = element.attributeCount(); i < length; i++) {
		attribute = element.attribute(i);
		method = methods.get(generateMethodName(GENERAL_M_PREFIX, attribute.getName()));
		if (null != method && method.getParameterTypes().length == 1) {
			doAttributeValue(paramObj, method, attribute.getValue(), method.getParameterTypes()[0]);
		}
	}
}
 
Example #20
Source File: Dom4jAccessor.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void set(Object target, Object value, SessionFactoryImplementor factory) 
throws HibernateException {
	Element owner = ( Element ) target;
	Attribute attribute = owner.attribute(attributeName);
	if (value==null) {
		if (attribute!=null) attribute.detach();
	}
	else {
		if (attribute==null) {
			owner.addAttribute(attributeName, "null");
			attribute = owner.attribute(attributeName);
		}
		super.propertyType.setToXMLNode(attribute, value, factory);
	}
}
 
Example #21
Source File: XMLInputFieldsImportProgressDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void setAttributeField( Attribute attribute, IProgressMonitor monitor ) {
  // Get Attribute Name
  String attributname = attribute.getName();
  String attributnametxt = cleanString( attribute.getPath() );
  if ( !Utils.isEmpty( attributnametxt ) && !list.contains( attribute.getPath() ) ) {
    nr++;
    monitor.subTask( BaseMessages.getString( PKG, "GetXMLDataXMLInputFieldsImportProgressDialog.Task.FetchFields",
        String.valueOf( nr ) ) );
    monitor.subTask( BaseMessages.getString( PKG, "GetXMLDataXMLInputFieldsImportProgressDialog.Task.AddingField",
        attributname ) );

    RowMetaAndData row = new RowMetaAndData();
    row.addValue( VALUE_NAME, Value.VALUE_TYPE_STRING, attributname );
    row.addValue( VALUE_PATH, Value.VALUE_TYPE_STRING, attributnametxt );
    row.addValue( VALUE_ELEMENT, Value.VALUE_TYPE_STRING, GetXMLDataField.ElementTypeDesc[1] );
    row.addValue( VALUE_RESULT, Value.VALUE_TYPE_STRING, GetXMLDataField.ResultTypeDesc[0] );

    // Get attribute value
    String valueAttr = attribute.getText();

    // Try to get the Type

    if ( IsDate( valueAttr ) ) {
      row.addValue( VALUE_TYPE, Value.VALUE_TYPE_STRING, "Date" );
      row.addValue( VALUE_FORMAT, Value.VALUE_TYPE_STRING, "yyyy/MM/dd" );
    } else if ( IsInteger( valueAttr ) ) {
      row.addValue( VALUE_TYPE, Value.VALUE_TYPE_STRING, "Integer" );
      row.addValue( VALUE_FORMAT, Value.VALUE_TYPE_STRING, null );
    } else if ( IsNumber( valueAttr ) ) {
      row.addValue( VALUE_TYPE, Value.VALUE_TYPE_STRING, "Number" );
      row.addValue( VALUE_FORMAT, Value.VALUE_TYPE_STRING, null );
    } else {
      row.addValue( VALUE_TYPE, Value.VALUE_TYPE_STRING, "String" );
      row.addValue( VALUE_FORMAT, Value.VALUE_TYPE_STRING, null );
    }
    list.add( attribute.getPath() );
  } // end if

}
 
Example #22
Source File: MeijoFormat.java    From rcrs-server with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void readEdges(Document doc, GMLMap result) {
    for (Object next : EDGE_XPATH.selectNodes(doc)) {
        Element e = (Element)next;
        int id = readID(e);
        //            Logger.debug("Children: " + e.elements());
        //            Logger.debug("Start: " + EDGE_START_XPATH.evaluate(e));
        int startID = Integer.parseInt(((Attribute)EDGE_START_XPATH.evaluate(e)).getValue().substring(1));
        int endID = Integer.parseInt(((Attribute)EDGE_END_XPATH.evaluate(e)).getValue().substring(1));
        GMLEdge edge = new GMLEdge(id, result.getNode(startID), result.getNode(endID), false);
        // Read the edge coordinates
        edge.setPoints(GMLTools.getCoordinatesList(((Element)EDGE_COORDINATES_XPATH.evaluate(e)).getText()));
        result.addEdge(edge);
        Logger.debug("Read edge " + edge);
    }
}
 
Example #23
Source File: HbmBinder.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static void bindNamedQuery(Element queryElem, String path, Mappings mappings) {
	String queryName = queryElem.attributeValue( "name" );
	if (path!=null) queryName = path + '.' + queryName;
	String query = queryElem.getText();
	log.debug( "Named query: " + queryName + " -> " + query );

	boolean cacheable = "true".equals( queryElem.attributeValue( "cacheable" ) );
	String region = queryElem.attributeValue( "cache-region" );
	Attribute tAtt = queryElem.attribute( "timeout" );
	Integer timeout = tAtt == null ? null : new Integer( tAtt.getValue() );
	Attribute fsAtt = queryElem.attribute( "fetch-size" );
	Integer fetchSize = fsAtt == null ? null : new Integer( fsAtt.getValue() );
	Attribute roAttr = queryElem.attribute( "read-only" );
	boolean readOnly = roAttr != null && "true".equals( roAttr.getValue() );
	Attribute cacheModeAtt = queryElem.attribute( "cache-mode" );
	String cacheMode = cacheModeAtt == null ? null : cacheModeAtt.getValue();
	Attribute cmAtt = queryElem.attribute( "comment" );
	String comment = cmAtt == null ? null : cmAtt.getValue();

	NamedQueryDefinition namedQuery = new NamedQueryDefinition(
			query,
			cacheable,
			region,
			timeout,
			fetchSize,
			getFlushMode( queryElem.attributeValue( "flush-mode" ) ) ,
			getCacheMode( cacheMode ),
			readOnly,
			comment,
			getParameterTypes(queryElem)
		);

	mappings.addQuery( queryName, namedQuery );
}
 
Example #24
Source File: XmlToJson.java    From renrenpay-android with Apache License 2.0 5 votes vote down vote up
/**
 * org.dom4j.Element 转  com.alibaba.fastjson.JSONObject
 *
 * @param node
 * @return
 */
public static JSONObject elementToJSONObject(Element node) {
    JSONObject result = new JSONObject();
    // 当前节点的名称、文本内容和属性
    List<Attribute> listAttr = node.attributes();// 当前节点的所有属性的list
    for (Attribute attr : listAttr) {// 遍历当前节点的所有属性
        result.put(attr.getName(), attr.getValue());
    }
    // 递归遍历当前节点所有的子节点
    List<Element> listElement = node.elements();// 所有一级子节点的list
    if (!listElement.isEmpty()) {
        for (Element e : listElement) {// 遍历所有一级子节点
            if (e.attributes().isEmpty() && e.elements().isEmpty()) // 判断一级节点是否有属性和子节点
                result.put(e.getName(), e.getTextTrim());// 沒有则将当前节点作为上级节点的属性对待
            else {
                if (!result.containsKey(e.getName())) { // 判断父节点是否存在该一级节点名称的属性
                    if (getKeyCount(e.getName(), listElement) > 1) {
                        result.put(e.getName(), new JSONArray());// 没有则创建
                    } else {
                        result.put(e.getName(), elementToJSONObject(e));// 没有则创建
                        continue;
                    }
                }
                ((JSONArray) result.get(e.getName())).add(elementToJSONObject(e));// 将该一级节点放入该节点名称的属性对应的值中
            }
        }
    }
    return result;
}
 
Example #25
Source File: AddSpringConfigurationPropertyMigrationTask.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
private void addIgnoreExchangeEventProperty(CamelProcessItem item) throws PersistenceException, DocumentException {
	String springContent = item.getSpringContent();
	if (null != springContent && !springContent.isEmpty()) {
		Document document = DocumentHelper.parseText(springContent);
		QName qname = QName.get("bean", SPRING_BEANS_NAMESPACE);
		List<Element> beans = document.getRootElement().elements(qname);
		for (Element bean : beans) {
			if ("jmxEventNotifier".equals(bean.attributeValue("id")) &&
					"org.apache.camel.management.JmxNotificationEventNotifier".equals(bean.attributeValue("class")))
			{
				List<Element> properties = bean.elements(QName.get("property", SPRING_BEANS_NAMESPACE));
				boolean hasIgnore = false;
				for (Element property : properties) {
					List<Attribute> propertyAttributes = property.attributes();
					for (Attribute propertyAttribute : propertyAttributes) {
						if (propertyAttribute.getValue().equals(IGNORE_EXCHANGE_EVENTS)) {
							hasIgnore = true;
							break;
						}
					}
				}
				if (!hasIgnore)
				{
					DefaultElement ignoreExchangeElement = new DefaultElement("property", bean.getNamespace());
					ignoreExchangeElement.add(DocumentHelper.createAttribute(ignoreExchangeElement, "name", IGNORE_EXCHANGE_EVENTS));
					ignoreExchangeElement.add(DocumentHelper.createAttribute(ignoreExchangeElement, "value", "true"));
					bean.add(ignoreExchangeElement);
					item.setSpringContent(document.asXML());
					saveItem(item);
				}
				break;
			}
		}
	}
}
 
Example #26
Source File: EssayResponse.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the column size to the value stored in this column attribute. It the attribute is null the size is set to the default value
 * 
 * @param i
 */
public void setColumns(final Attribute i) {
    if (i == null) {
        columns = COLUMNS_DEFAULT;
    } else {
        final String value = i.getStringValue();
        setColumnsFromString(value);
    }
}
 
Example #27
Source File: JPAOverriddenAnnotationReader.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private void applyXmlDefinedConverts(
		Element containingElement,
		XMLContext.Default defaults,
		String attributeNamePrefix,
		Map<String,Convert> convertAnnotationsMap) {
	final List<Element> convertElements = containingElement.elements( "convert" );
	for ( Element convertElement : convertElements ) {
		final AnnotationDescriptor convertAnnotationDescriptor = new AnnotationDescriptor( Convert.class );
		copyStringAttribute( convertAnnotationDescriptor, convertElement, "attribute-name", false );
		copyBooleanAttribute( convertAnnotationDescriptor, convertElement, "disable-conversion" );

		final Attribute converterClassAttr = convertElement.attribute( "converter" );
		if ( converterClassAttr != null ) {
			final String converterClassName = XMLContext.buildSafeClassName(
					converterClassAttr.getValue(),
					defaults
			);
			try {
				final Class converterClass = classLoaderAccess.classForName( converterClassName );
				convertAnnotationDescriptor.setValue( "converter", converterClass );
			}
			catch (ClassLoadingException e) {
				throw new AnnotationException( "Unable to find specified converter class id-class: " + converterClassName, e );
			}
		}
		final Convert convertAnnotation = AnnotationFactory.create( convertAnnotationDescriptor );
		final String qualifiedAttributeName = qualifyConverterAttributeName(
				attributeNamePrefix,
				convertAnnotation.attributeName()
		);
		convertAnnotationsMap.put( qualifiedAttributeName, convertAnnotation );
	}

}
 
Example #28
Source File: HbmBinder.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static void bindSimpleValue(Element node, SimpleValue simpleValue, boolean isNullable,
		String path, Mappings mappings) throws MappingException {
	bindSimpleValueType( node, simpleValue, mappings );

	bindColumnsOrFormula( node, simpleValue, path, isNullable, mappings );

	Attribute fkNode = node.attribute( "foreign-key" );
	if ( fkNode != null ) simpleValue.setForeignKeyName( fkNode.getValue() );
}
 
Example #29
Source File: ManifestFileUtils.java    From atlas with Apache License 2.0 5 votes vote down vote up
private static void disableDebuggable(Document document) {
        Element root = document.getRootElement();// Get the root node
        Element app = root.element("application");
        Attribute attribute = app.attribute("debuggable");
        if (attribute!= null){
            attribute.setValue("false");
            logger.warn("disable android:debuggable .......");
//            app.remove(attribute);
        }
    }
 
Example #30
Source File: XMLUtil.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 设置或添加属性
 * @param element
 * @param name
 * @param value
 */
public static void setAttribute(Element element, String name, String value) {
    Attribute attribute = element.attribute(name);
    if (attribute != null) {
        attribute.setValue(value);
    } else {
        element.addAttribute(name, value);
    }
}