Java Code Examples for org.dom4j.Element

The following are top voted examples for showing how to use org.dom4j.Element. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: joai-project   File: EditorRenderer.java   View source code 7 votes vote down vote up
/**
 *  Create label for a mulitBoxLabel element that will collapse the mulitBox
 *  input.<P>
 *
 *  Based on getComplexTypeLabel, but will always display collapse widget,
 *  rather than first testing for nodeIsExpandable as getComplexTypeLabel does.
 *  <P>
 *
 *  Depends on the multibox input having an id and display style initialized to
 *  value of collapseBean.displayState.
 *
 * @param  xpath  NOT YET DOCUMENTED
 * @return        The multiBoxLabel value
 */
public Label getMultiBoxLabel(String xpath) {
	ComplexTypeLabel labelObj = getComplexTypeLabel(xpath);
	Element alwaysExpandable = df.createElement("c__if")
		.addAttribute("test", "${true}");
	Element labelLink = alwaysExpandable.addElement("a")
		.addAttribute("href", "javascript__toggleDisplayState(" + RendererHelper.jspQuotedString("${id}") + ");");

	Element notExpandableTest = df.createElement("c__if")
		.addAttribute("test", "${false}");

	labelObj.isExpandableTest = alwaysExpandable.createCopy();
	labelObj.notExpandableTest = notExpandableTest.createCopy();
	labelObj.collapseWidget = getCollapseWidget().createCopy();
	return labelObj;
}
 
Example 2
Project: joai-project   File: MdeComplexType.java   View source code 6 votes vote down vote up
/**
 *  Create "choose" controller for the case where an empty requiredMultiSelect
 *  node is closed. Called from renderComplexTypeConcrete, this controller
 *  provides a prompt for user when the required multiselect boxes are empty
 *  and not visible
 *
 * @return    The requiredMultiSelectControl value
 */
public Element getRequiredMultiSelectControl() {

	Element actionElement = df.createElement("span")
		.addAttribute("class", "action-button");

	// test to see if child node (the multiSelect) is empty
	Element isEmptyTest = actionElement.addElement("logic__equal")
		.addAttribute("name", formBeanName)
		.addAttribute("property", "nodeIsEmpty(" + xpath + ")")
		.addAttribute("value", "true");

	// test to see if the node is closed
	Element isOpenTest = isEmptyTest.addElement("c__if")
		.addAttribute("test", "${not " + formBeanName + ".collapseBean.isOpen}");

	//  "choose" controller link that toogles DisplayState of node
	Element chooseController = isOpenTest.addElement("a")
		.addAttribute("href", "javascript__toggleDisplayState(" + RendererHelper.jspQuotedString("${id}") + ")");
	chooseController.setText("choose");

	return actionElement;
}
 
Example 3
Project: PackagePlugin   File: FileUtil.java   View source code 6 votes vote down vote up
/**
 * 摸查项目输出目录
 * <p>
 * @param projectPath
 * @param kind        output 或 src
 * @return
 */
public static String readXML(String projectPath, String kind) {
    try {
        SAXReader saxReader = new SAXReader();
        File classpath = new File(projectPath + "/.classpath");
        if (classpath.exists()) {
            Document document = saxReader.read(classpath);
            List<Element> out = (List<Element>) document.selectNodes("/classpath/classpathentry[@kind='" + kind + "']");
            String tmp = "";
            for (Element out1 : out) {
                String combineaccessrules = out1.attributeValue("combineaccessrules");
                if ("false".equals(combineaccessrules) && "src".equals(kind)) {
                    continue;
                }
                tmp += out1.attributeValue("path") + ",";
            }
            return tmp.isEmpty() ? tmp : tmp.substring(0, tmp.length() - 1);
        }
    } catch (DocumentException ex) {
        MainFrame.LOGGER.log(Level.SEVERE, null, ex);
        JOptionPane.showMessageDialog(null, ex.getLocalizedMessage());
    }
    return "";
}
 
Example 4
Project: bdf2   File: ModelBuilder.java   View source code 6 votes vote down vote up
private Element buildValidatorElement(Validator validator){
	BaseElement element=new BaseElement("Validator");
	int pos=validator.getName().lastIndexOf("Validator");
	String validatorType=validator.getName().substring(0,pos);
	validatorType=validatorType.substring(0,1).toLowerCase()+validatorType.substring(1,validatorType.length());
	element.addAttribute("type",validatorType);
	if(validator.getProperties()!=null){
		for(ValidatorProperty vp:validator.getProperties()){
			if(StringHelper.isNotEmpty(vp.getName()) && StringHelper.isNotEmpty(vp.getValue())){
				Element propertyElement=createPropertyElement(vp.getName(),vp.getValue());
				element.add(propertyElement);					
			}
		}
	}
	return element;
}
 
Example 5
Project: lams   File: JPAOverriddenAnnotationReader.java   View source code 6 votes vote down vote up
private NamedStoredProcedureQueries getNamedStoredProcedureQueries(Element tree, XMLContext.Default defaults) {
	List<NamedStoredProcedureQuery> queries = buildNamedStoreProcedureQueries( tree, defaults );
	if ( defaults.canUseJavaAnnotations() ) {
		NamedStoredProcedureQuery annotation = getPhysicalAnnotation( NamedStoredProcedureQuery.class );
		addNamedStoredProcedureQueryIfNeeded( annotation, queries );
		NamedStoredProcedureQueries annotations = getPhysicalAnnotation( NamedStoredProcedureQueries.class );
		if ( annotations != null ) {
			for ( NamedStoredProcedureQuery current : annotations.value() ) {
				addNamedStoredProcedureQueryIfNeeded( current, queries );
			}
		}
	}
	if ( queries.size() > 0 ) {
		AnnotationDescriptor ad = new AnnotationDescriptor( NamedStoredProcedureQueries.class );
		ad.setValue( "value", queries.toArray( new NamedStoredProcedureQuery[queries.size()] ) );
		return AnnotationFactory.create( ad );
	}
	else {
		return null;
	}
}
 
Example 6
Project: joai-project   File: MdeNode.java   View source code 6 votes vote down vote up
/**
 *  Insert an HTML comment into the html source.
 *
 * @param  e  NOT YET DOCUMENTED
 * @param  s  NOT YET DOCUMENTED
 */
protected void insertHtmlComment(Element e, String s) {
	prtln("\ninsertHtmlComment()");
	Element comment = df.createElement("st__htmlComment");
	comment.setText(s);
	Element parent = e.getParent();

	if (parent != null) {
		List children = parent.elements();
		int index = children.indexOf(e);
		children.add(index, comment);
	}
	else {
		// prtlnErr("PARENT NOT FOUND");
	}
}
 
Example 7
Project: bdf2   File: AbstractConverter.java   View source code 6 votes vote down vote up
protected void fillDataSetAndDataPathProperty(Element element,ComponentInfo component,boolean isCollection){
	String[] dataSetDataPath=this.retriveDataSetAndDataPath(component);
	if(dataSetDataPath!=null){
		if(StringHelper.isNotEmpty(dataSetDataPath[0])){
			BaseElement dataSetElement=new BaseElement("Property");	
			dataSetElement.addAttribute("name", "dataSet");
			dataSetElement.setText(dataSetDataPath[0]);
			element.add(dataSetElement);
		}
		if(StringHelper.isNotEmpty(dataSetDataPath[1]) && !hasDataPath(component)){
			BaseElement dataPathElement=new BaseElement("Property");
			dataPathElement.addAttribute("name", "dataPath");
			String dataPath=dataSetDataPath[1];
			if(!isCollection){
				int pos=dataPath.lastIndexOf(".");
				if(pos>0){
					dataPath=dataPath.substring(0,pos)+".#"+dataPath.substring(pos+1,dataPath.length());
				}					
			}
			
			dataPathElement.setText(dataPath);
			element.add(dataPathElement);
		}
	}
}
 
Example 8
Project: bdf2   File: ModelBuilder.java   View source code 6 votes vote down vote up
private Element createReferencePropertyDef(Entity entity,RuleSet ruleSet,boolean isSelf){
	String nodeName=Reference.class.getSimpleName();
	Rule rule=ruleSet.getRule(nodeName);
	Element referenceDefElement=new BaseElement(rule.getNodeName());
	referenceDefElement.addAttribute("name", entity.getName());
	//创建dataType与dataProvider属性
	Element dataTypeElement=createPropertyElement("dataType",null);
	if(isSelf){
		dataTypeElement.setText("[SELF]");			
	}else{
		dataTypeElement.setText("["+ entity.getName()+"]");						
	}
	referenceDefElement.add(dataTypeElement);
	String entityName=entity.getName();
	Element dataProviderElement=createPropertyElement("dataProvider","dataProvider"+entityName.substring(0,1).toUpperCase()+entityName.substring(1,entityName.length()));
	if(entity.getPageSize()>0){
		Element pageSizeElement=createPropertyElement("pageSize",String.valueOf(entity.getPageSize()));
		referenceDefElement.add(pageSizeElement);
	}
	referenceDefElement.add(dataProviderElement);
	referenceDefElement.add(createReferenceParameterElement(entity));
	return referenceDefElement;
}
 
Example 9
Project: lams   File: HbmBinder.java   View source code 6 votes vote down vote up
private static void parseFilterDef(Element element, Mappings mappings) {
	String name = element.attributeValue( "name" );
	LOG.debugf( "Parsing filter-def [%s]", name );
	String defaultCondition = element.getTextTrim();
	if ( StringHelper.isEmpty( defaultCondition ) ) {
		defaultCondition = element.attributeValue( "condition" );
	}
	HashMap paramMappings = new HashMap();
	Iterator params = element.elementIterator( "filter-param" );
	while ( params.hasNext() ) {
		final Element param = (Element) params.next();
		final String paramName = param.attributeValue( "name" );
		final String paramType = param.attributeValue( "type" );
		LOG.debugf( "Adding filter parameter : %s -> %s", paramName, paramType );
		final Type heuristicType = mappings.getTypeResolver().heuristicType( paramType );
		LOG.debugf( "Parameter heuristic type : %s", heuristicType );
		paramMappings.put( paramName, heuristicType );
	}
	LOG.debugf( "Parsed filter-def [%s]", name );
	FilterDefinition def = new FilterDefinition( name, defaultCondition, paramMappings );
	mappings.addFilterDefinition( def );
}
 
Example 10
Project: uflo   File: ForeachParser.java   View source code 6 votes vote down vote up
public Object parse(Element element, long processId, boolean parseChildren) {
	ForeachNode node=new ForeachNode();
	node.setProcessId(processId);
	parseNodeCommonInfo(element, node);
	node.setSequenceFlows(parseFlowElement(element,processId,parseChildren));
	String type=element.attributeValue("foreach-type");
	if(StringUtils.isNotEmpty(type)){
		node.setForeachType(ForeachType.valueOf(type));			
	}
	node.setVariable(unescape(element.attributeValue("var")));
	if(StringUtils.isNotBlank(element.attributeValue("process-variable"))){
		node.setProcessVariable(unescape(element.attributeValue("process-variable")));			
	}else{
		node.setProcessVariable(unescape(element.attributeValue("in")));						
	}
	node.setHandlerBean(unescape(element.attributeValue("handler-bean")));
	NodeDiagram diagram=parseDiagram(element);
	diagram.setIcon("/icons/foreach.svg");
	diagram.setShapeType(ShapeType.Circle);
	diagram.setBorderWidth(1);
	node.setDiagram(diagram);
	return node;
}
 
Example 11
Project: minlia-iot   File: AbstractApiComponent.java   View source code 6 votes vote down vote up
/**
 * 获取节点值
 * @param root
 * @param clazz
 * @param name
 * @return
 */
@SuppressWarnings("unchecked")
protected Optional<Object> elementValue(Element root, Class<?> clazz, String name) {
    Optional<String> elementTextOptional = elementText(root, name);
    if (elementTextOptional.isPresent()) {
        if (clazz == Integer.class) {
            return Optional.of(new Integer(elementTextOptional.get()));
        } else if (clazz == Long.class) {
            return Optional.of(new Long(elementTextOptional.get()));
        } else if (Enum.class.isAssignableFrom(clazz)) {
            try {
                Class enumClass = Class.forName(clazz.getName());
                return Optional.of(Enum.valueOf(enumClass, elementTextOptional.get()));
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
                return Optional.empty();
            }
        } else {
            return Optional.of(elementTextOptional.get());
        }
    } else {
        return Optional.empty();
    }
}
 
Example 12
Project: joai-project   File: Choice.java   View source code 6 votes vote down vote up
/**
 * Returns the members that could be added to the specified instanceElement
 * according to schema constraints.
 */
public List getAcceptableMembers (Element instanceElement) { 
	prtln ("\ngetAcceptableMembers with instanceElement:");
	prtln (instanceElement.asXML());
	ChoiceGuard guard;
	try {
		guard = new ChoiceGuard (this, instanceElement);
	} catch (Exception e) {
		prtln ("ChoiceGard init error: " + e.getMessage());
		return new ArrayList();
	}
	prtln ("about to call ChoiceGuard getAcceptableMembers()");
	List members = guard.getAcceptableMembers();
	prtln ("acceptable members:");
	printMemberList (members);
	return members;
}
 
Example 13
Project: bdf2   File: DecisionConverter.java   View source code 6 votes vote down vote up
public JpdlInfo toJpdl(Element element) {
	BaseElement targetElement=new BaseElement("decision");
	String name=this.buildCommonJpdlElement(element, targetElement);
	String decisionType=element.attributeValue("decisionType");
	String decisionValue=element.attributeValue("decisionValue");
	if(decisionType.equals("handler")){
		BaseElement handlerElement=new BaseElement("handler");
		handlerElement.addAttribute("class", decisionValue);
		targetElement.add(handlerElement);
	}else{
		targetElement.addAttribute("expr",decisionValue);
	}
	JpdlInfo info=new JpdlInfo();
	info.setName(name);
	info.setElement(targetElement);
	return info;
}
 
Example 14
Project: uflo   File: EndParser.java   View source code 6 votes vote down vote up
public Object parse(Element element,long processId,boolean parseChildren) {
	EndNode node=new EndNode();
	node.setProcessId(processId);
	parseNodeCommonInfo(element, node);
	String terminate=element.attributeValue("terminate");
	if(StringUtils.isNotEmpty(terminate)){
		node.setTerminate(Boolean.valueOf(terminate));
	}
	NodeDiagram diagram=parseDiagram(element);
	if(node.isTerminate()){
		diagram.setIcon("/icons/end-terminate.svg");
	}else{
		diagram.setIcon("/icons/end.svg");
	}
	diagram.setShapeType(ShapeType.Circle);
	diagram.setBorderWidth(1);
	node.setDiagram(diagram);
	return node;
}
 
Example 15
Project: Divinity_Original_Sin_2_zhCN   File: DOS2ToMap.java   View source code 6 votes vote down vote up
@Override
public Map toMap(Document document) {
  Map<String, String> m = new HashMap<String, String>();
  /**
   * <contentList> <content contentuid=
   * "h00007224gb454g4b8bgb762g7865d9ee3dbb">如果不是这样的话!哈,开玩笑啦,我们在一起很合适,就像面包上的果酱。你想和我组队吗?我敢说你们需要一点野兽风味!</content>
   * <content contentuid="h0001d8b9g13d6g4605g85e9g708fe1e537c8">定制</content> </contentList>
   */
  // 获取根节点元素对象
  Element root = document.getRootElement();
  // 子节点
  List<Element> list = root.elements();
  // 使用递归
  Iterator<Element> iterator = list.iterator();
  while (iterator.hasNext()) {
    Element e = iterator.next();
    Attribute attribute = e.attribute("contentuid");
    m.put(attribute.getValue(), e.getText());
  }
  return m;
}
 
Example 16
Project: etagate   File: GateSetting.java   View source code 6 votes vote down vote up
public void parse(URL is) {
		SAXReader saxReader = new SAXReader();

		try {
			Document document = saxReader.read(is);
			Element root = document.getRootElement();
			
			collectProperty(root);
			parseAuth(root);
			parseApp(root);
//			
//			System.out.println("====================parse ok=============");
//			System.out.println(properties.toString());
//			System.out.println(authSetting.toString());
		} catch (DocumentException e) {
			log.error("Load route.xml error.");
			e.printStackTrace();
		}

	}
 
Example 17
Project: bdf2   File: TabControlConverter.java   View source code 6 votes vote down vote up
public Element convert(ComponentInfo component, RuleSet ruleSet,
		Element rootElement) throws Exception {
	String name=TabControl.class.getSimpleName();
	XmlNode node=TabControl.class.getAnnotation(XmlNode.class);
	if(node!=null && StringHelper.isNotEmpty(node.nodeName())){
		name=node.nodeName();
	}
	Rule rule=ruleSet.getRule(name);
	BaseElement element = fillElement(component,ruleSet,rule,rootElement);
	if(component.getChildren()!=null){
		for(ComponentInfo c:component.getChildren()){
			this.buildChildren(element,c,ruleSet,rootElement);							
		}
	}
	return element;
}
 
Example 18
Project: SimpleController   File: XmlGenerator.java   View source code 6 votes vote down vote up
private Document readDocument(String path,String name, int age) throws DocumentException{
	SAXReader reader=new SAXReader();
	Document document=reader.read(path);
	Element root=document.getRootElement();
	List listOfTextView=document.selectNodes("view/body/form/textView");
	for(Iterator<Element> i=listOfTextView.listIterator();i.hasNext();){
		Element textView=i.next();
		if(textView.selectSingleNode("name").getText().equals("userName")){
			textView.selectSingleNode("value").setText(name);
		}
		if(textView.selectSingleNode("name").getText().equals("userAge")){
			textView.selectSingleNode("value").setText(""+age);
		}
	}
	System.out.println(document);
	return document;
}
 
Example 19
Project: lams   File: XMLContext.java   View source code 6 votes vote down vote up
private List<String> addEntityListenerClasses(Element element, String packageName, List<String> addedClasses) {
	List<String> localAddedClasses = new ArrayList<String>();
	Element listeners = element.element( "entity-listeners" );
	if ( listeners != null ) {
		@SuppressWarnings( "unchecked" )
		List<Element> elements = listeners.elements( "entity-listener" );
		for (Element listener : elements) {
			String listenerClassName = buildSafeClassName( listener.attributeValue( "class" ), packageName );
			if ( classOverriding.containsKey( listenerClassName ) ) {
				//maybe switch it to warn?
				if ( "entity-listener".equals( classOverriding.get( listenerClassName ).getName() ) ) {
					LOG.duplicateListener( listenerClassName );
					continue;
				}
				throw new IllegalStateException("Duplicate XML entry for " + listenerClassName);
			}
			localAddedClasses.add( listenerClassName );
			classOverriding.put( listenerClassName, listener );
		}
	}
	LOG.debugf( "Adding XML overriding information for listeners: %s", localAddedClasses );
	addedClasses.addAll( localAddedClasses );
	return localAddedClasses;
}
 
Example 20
Project: uflo   File: AbstractParser.java   View source code 6 votes vote down vote up
protected NodeDiagram parseDiagram(Element element){
	NodeDiagram diagram=new NodeDiagram();
	String g=element.attributeValue("g");
	String name=element.attributeValue("name");
	String label=element.attributeValue("label");
	diagram.setLabel(label);			
	diagram.setName(name);
	if(StringUtils.isNotBlank(g)){
		String[] info=g.split(",");
		if(info.length!=4){
			throw new IllegalArgumentException("Node "+element.attributeValue("name")+" diagram info is invalide!");
		}
		diagram.setX(Integer.valueOf(info[0]));
		diagram.setY(Integer.valueOf(info[1]));
		diagram.setWidth(Integer.valueOf(info[2]));
		diagram.setHeight(Integer.valueOf(info[3]));			
	}
	String x=element.attributeValue("x");
	String y=element.attributeValue("y");
	String width=element.attributeValue("width");
	String height=element.attributeValue("height");
	if(StringUtils.isNotBlank(x)){
		diagram.setX(Integer.valueOf(x));
	}
	if(StringUtils.isNotBlank(y)){
		diagram.setY(Integer.valueOf(y));
	}
	if(StringUtils.isNotBlank(width)){
		diagram.setWidth(Integer.valueOf(width));
	}
	if(StringUtils.isNotBlank(height)){
		diagram.setHeight(Integer.valueOf(height));
	}
	return diagram;
}
 
Example 21
Project: bdf2   File: AbstractConverter.java   View source code 6 votes vote down vote up
protected String buildCommonJpdlElement(Element element,Element targetElement){
	String name=element.attributeValue("name");
	String desc=element.attributeValue("desc");
	targetElement.addAttribute("name",name);
	Element descElement=new BaseElement("description");
	if(StringUtils.isNotEmpty(desc)){
		descElement.setText(desc);			
	}
	int width=Integer.parseInt(element.attributeValue("width"));
	int height=Integer.parseInt(element.attributeValue("height"));
	int x=Integer.parseInt(element.attributeValue("x"));
	int y=Integer.parseInt(element.attributeValue("y"));
	x=x-(width/2);
	y=y-(height/2);
	String g=x+","+y+","+width+","+height;
	if(this instanceof TransitionConverter){
		g=x+","+y;			
	}
	targetElement.addAttribute("g", g);
	/*for(Object obj:element.attributes()){
		Attribute attr=(Attribute)obj;
		targetElement.addAttribute(attr.getName(),attr.getValue());
	}*/
	return name;
}
 
Example 22
Project: urule   File: ParenParser.java   View source code 6 votes vote down vote up
@Override
public ParenValue parse(Element element) {
	ParenValue value=new ParenValue();
	for(Object obj:element.elements()){
		if(obj==null || !(obj instanceof Element)){
			continue;
		}
		Element ele=(Element)obj;
		if(valueParser.support(ele.getName())){
			value.setValue(valueParser.parse(ele));
		}else if(arithmeticParser.support(ele.getName())){
			value.setArithmetic(arithmeticParser.parse(ele));
		}
	}
	return value;
}
 
Example 23
Project: unitimes   File: CourseOfferingExport.java   View source code 6 votes vote down vote up
protected void exportCourse(Element courseElement, CourseOffering course, Session session) {
    courseElement.addAttribute("id", (course.getExternalUniqueId()!=null?course.getExternalUniqueId():course.getUniqueId().toString()));
    courseElement.addAttribute("subject", course.getSubjectArea().getSubjectAreaAbbreviation());
    courseElement.addAttribute("courseNbr", course.getCourseNbr());
    if (course.getReservation() != null)
    	courseElement.addAttribute("reserved", course.getReservation().toString());
    courseElement.addAttribute("controlling", course.isIsControl()?"true":"false");
    if (course.getConsentType()!=null)
    	courseElement.addElement("consent").addAttribute("type", course.getConsentType().getReference());
    if (course.getTitle()!=null)
        courseElement.addAttribute("title", course.getTitle());
    if (course.getScheduleBookNote()!=null)
        courseElement.addAttribute("scheduleBookNote", course.getScheduleBookNote());
    for (Iterator i=course.getCreditConfigs().iterator();i.hasNext();) {
        CourseCreditUnitConfig credit = (CourseCreditUnitConfig)i.next();
        exportCredit(courseElement.addElement("courseCredit"), credit, session);
    }
}
 
Example 24
Project: atlas   File: ManifestFileUtils.java   View source code 6 votes vote down vote up
/**
 * Delete the custom header
 *
 * @param document
 * @param manifestOptions
 */
private static void removeCustomLaunches(Document document, ManifestOptions manifestOptions) {
    if (null == manifestOptions) {
        return;
    }
    Element root = document.getRootElement();// Get the root node
    // Update launch information
    if (manifestOptions.getRetainLaunches() != null && manifestOptions.getRetainLaunches().size() > 0) {
        List<? extends Node> nodes = root.selectNodes(
            "//activity/intent-filter/category|//activity-alias/intent-filter/category");
        for (Node node : nodes) {
            Element e = (Element)node;
            if ("android.intent.category.LAUNCHER".equalsIgnoreCase(e.attributeValue("name"))) {
                Element activityElement = e.getParent().getParent();
                String activiyName = activityElement.attributeValue("name");
                if (!manifestOptions.getRetainLaunches().contains(activiyName)) {
                    if (activityElement.getName().equalsIgnoreCase("activity-alias")) {
                        activityElement.getParent().remove(activityElement);
                    } else {
                        e.getParent().remove(e);
                    }
                }
            }
        }
    }
}
 
Example 25
Project: unitimes   File: PageAccessFilter.java   View source code 6 votes vote down vote up
public void init(FilterConfig cfg) throws ServletException {
	iContext = cfg.getServletContext();
	try {
		Document config = (new SAXReader()).read(cfg.getServletContext().getResource(cfg.getInitParameter("config")));
		for (Iterator i=config.getRootElement().element("action-mappings").elementIterator("action"); i.hasNext();) {
			Element action = (Element)i.next();
			String path = action.attributeValue("path");
			String input = action.attributeValue("input");
			if (path!=null && input!=null) {
				iPath2Tile.put(path+".do", input);
			}
		}
	} catch (Exception e) {
		sLog.error("Unable to read config "+cfg.getInitParameter("config")+", reason: "+e.getMessage());
	}
	if (cfg.getInitParameter("debug-time")!=null) {
		debugTime = Long.parseLong(cfg.getInitParameter("debug-time"));
	}
	if (cfg.getInitParameter("dump-time")!=null) {
		dumpTime = Long.parseLong(cfg.getInitParameter("dump-time"));
	}
	if (cfg.getInitParameter("session-attributes")!=null) {
		dumpSessionAttribues = Boolean.parseBoolean(cfg.getInitParameter("session-attributes"));
	}
}
 
Example 26
Project: sbc-qsystem   File: QIndicatorBoardMonitor.java   View source code 6 votes vote down vote up
@Override
public Element getConfig() {
    final File boardFile = new File(getConfigFile());
    if (boardFile.exists()) {
        try {
            return new SAXReader(false).read(boardFile).getRootElement();
        } catch (DocumentException ex) {
            QLog.l().logger()
                .error("Невозможно прочитать файл конфигурации главного табло. " + ex
                    .getMessage());
            return DocumentHelper.createElement("Ответ");
        }
    } else {
        QLog.l().logger()
            .warn("Файл конфигурации главного табло \"" + configFile + "\" не найден. ");
        return DocumentHelper.createElement("Ответ");
    }
}
 
Example 27
Project: ats-framework   File: XmlText.java   View source code 6 votes vote down vote up
/**
 * Returns the child XPaths of a XML element
 *
 * @return the XPath of the XML element.
 * @return the child XPaths of a XML element
 * @throws XMLException
 */
@PublicAtsApi
public String[] getElementXPaths(
                                  String xpath ) throws XMLException {

    ArrayList<String> elementXPaths = new ArrayList<>(1);

    if (StringUtils.isNullOrEmpty(xpath)) {
        throw new XMLException("Null/empty xpath is not allowed.");
    }

    Element element = findElement(xpath);

    if (element == null) {
        throw new XMLException("'" + xpath + "' is not a valid path");
    }

    Iterator<Element> it = element.elementIterator();

    while (it.hasNext()) {
        elementXPaths.add(it.next().getUniquePath());
    }

    return elementXPaths.toArray(new String[elementXPaths.size()]);
}
 
Example 28
Project: ats-framework   File: XmlText.java   View source code 6 votes vote down vote up
/**
 * Append text to a XML element.
 *
 * @param xpath XPath , pointing to a XML element
 * @param text the text , which will be appended to a XML element
 * @return this instance
 * @throws XMLException
 */
@PublicAtsApi
public XmlText appendText(
                           String xpath,
                           String text ) throws XMLException {

    if (StringUtils.isNullOrEmpty(xpath)) {
        throw new XMLException("Null/empty xpath is not allowed.");
    }

    if (StringUtils.isNullOrEmpty(text)) {
        throw new XMLException("Null/empty text is not allowed.");
    }

    Element element = findElement(xpath);

    if (element == null) {
        throw new XMLException("'" + xpath + "' is not a valid path");
    }

    element.addText(text);

    return this;
}
 
Example 29
Project: unitimes   File: LowercaseTableNames.java   View source code 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 30
Project: joai-project   File: DcsViewRecord.java   View source code 6 votes vote down vote up
private void renderMaster () throws Exception {
	Element base = df.createElement("div");
	/* base.addAttribute ("class", "level--1"); */
	List elements = instanceDocument.getRootElement().elements();
	// prtln("batchRenderAndWrite found " + elements.size() + " elements");
	for (Iterator i = elements.iterator(); i.hasNext(); ) {
		Element child = (Element) i.next();
		String xpath = child.getPath();
		String pageName = XPathUtils.getNodeName(xpath);
		Element include = base.addElement("jsp__include");
		include.addAttribute("page", getMasterComponentPath (pageName));
	}
	
	File dest = getJspDest (null);
	if (!writeJsp(base, dest, this.getMasterJspHeader())) {
		throw new Exception ("renderMaster(): failed to write jsp to " + dest);
	}
	
}
 
Example 31
Project: ofmeet-openfire-plugin   File: OfMeetPlugin.java   View source code 6 votes vote down vote up
public void sessionDestroyed(Session session)
{
	Log.debug("OfMeet Plugin -  sessionDestroyed "+ session.getAddress().toString() + "\n" + ((ClientSession) session).getPresence().toXML());

	boolean skypeAvailable = XMPPServer.getInstance().getPluginManager().getPlugin("ofskype") != null;

	if (OfMeetAzure.skypeids.containsKey(session.getAddress().getNode()))
	{
		String sipuri = OfMeetAzure.skypeids.remove(session.getAddress().getNode());

		IQ iq = new IQ(IQ.Type.set);
		iq.setFrom(session.getAddress());
		iq.setTo(XMPPServer.getInstance().getServerInfo().getXMPPDomain());

		Element child = iq.setChildElement("request", "http://igniterealtime.org/protocol/ofskype");
		child.setText("{'action':'stop_skype_user', 'sipuri':'" + sipuri + "'}");
		XMPPServer.getInstance().getIQRouter().route(iq);

		Log.info("OfMeet Plugin - closing skype session " + sipuri);
	}
}
 
Example 32
Project: iBase4J   File: XmlUtil.java   View source code 6 votes vote down vote up
/**
 * 将List数据类型转换为符合XML格式规范的字符串(基于节点值的方式)
 * 
 * @param pList 传入的List数据(List对象可以是Dto、VO、Domain的属性集)
 * @param pRootNodeName 根节点名称
 * @param pFirstNodeName 行节点名称
 * @return string 返回XML格式字符串
 */
public static final String parseList2XmlBasedNode(List pList, String pRootNodeName, String pFirstNodeName) {
	Document document = DocumentHelper.createDocument();
	Element output = document.addElement(pRootNodeName);
	for (int i = 0; i < pList.size(); i++) {
		Map map = (Map) pList.get(i);
		Element elRow = output.addElement(pFirstNodeName);
		Iterator it = map.entrySet().iterator();
		while (it.hasNext()) {
			Map.Entry entry = (Map.Entry) it.next();
			Element leaf = elRow.addElement((String) entry.getKey());
			leaf.setText(String.valueOf(entry.getValue()));
		}
	}
	String outXml = document.asXML().substring(39);
	return outXml;
}
 
Example 33
Project: joai-project   File: AttributeGroup.java   View source code 5 votes vote down vote up
/**
 *  NOT YET DOCUMENTED
 *
 * @return    NOT YET DOCUMENTED
 */
public String toString() {
	String s = "AttributeGroup: " + name;
	s += super.toString();
		String nl = "\n\t";
	for (Iterator i=getAttributes().iterator();i.hasNext();) {
		Element e = (Element)i.next();
		s += nl + e.asXML();
	}
	return s;
}
 
Example 34
Project: unitimes   File: CourseOfferingExport.java   View source code 5 votes vote down vote up
protected void exportAssignment(Element classElement, Assignment assignment, Session session) {
    exportDatePattern(classElement, assignment.getDatePattern(), session);
    exportTimeLocation(classElement, assignment, session);
    exportRooms(classElement, assignment, session);
    if (iClassEvents != null)
    	exportEvent(classElement, iClassEvents.get(assignment.getClassId()), session);
    if (iExportGroupInfos)
    	exportGroupInfos(classElement, assignment, session);
}
 
Example 35
Project: unitimes   File: BaseImport.java   View source code 5 votes vote down vote up
protected String getRequiredStringAttribute(Element element, String attributeName, String elementName) throws Exception{		
	String attributeValue = element.attributeValue(attributeName);
	if (attributeValue == null || attributeValue.trim().length() == 0){
		throw new Exception("For element '" + elementName + "' a '" + attributeName + "' is required");
	} else {
		attributeValue = attributeValue.trim().replace('\u0096', ' ').replace('\u0097', ' ');
	}						
	return(attributeValue);
}
 
Example 36
Project: ARCLib   File: XmlBuilderTest.java   View source code 5 votes vote down vote up
@Test
public void addSiblingNodeTest() throws IOException, SAXException, TransformerException {
    Document doc = DocumentHelper.createDocument(DocumentHelper.createElement("root"));

    Element root = doc.getRootElement();

    Element child = DocumentHelper.createElement("child");
    child.setText("test value 1");

    root.add(child);

    xmlBuilder.addNode(doc, "/root/child", "test value 2", uris.get("ARCLIB"));
    assertThat(doc.asXML(), is("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<root><child>test value 1</child><child xmlns=\"http://arclib.lib.cas.cz/ARCLIB_XML\">test value 2</child></root>"));
}
 
Example 37
Project: lams   File: JPAOverriddenAnnotationReader.java   View source code 5 votes vote down vote up
private static void buildIndex(AnnotationDescriptor annotation, Element element){
	List indexElementList = element.elements( "index" );
	Index[] indexes = new Index[indexElementList.size()];
	for(int i=0;i<indexElementList.size();i++){
		Element subelement = (Element)indexElementList.get( i );
		AnnotationDescriptor indexAnn = new AnnotationDescriptor( Index.class );
		copyStringAttribute( indexAnn, subelement, "name", false );
		copyStringAttribute( indexAnn, subelement, "column-list", true );
		copyBooleanAttribute( indexAnn, subelement, "unique" );
		indexes[i] = AnnotationFactory.create( indexAnn );
	}
	annotation.setValue( "indexes", indexes );
}
 
Example 38
Project: iBase4J   File: XmlUtil.java   View source code 5 votes vote down vote up
/**
 * 将XML规范的字符串转为List对象(XML基于节点属性值的方式)
 * 
 * @param pStrXml 传入的符合XML格式规范的字符串
 * @return list 返回List对象
 */
public static final List parseXml2List(String pStrXml) {
	List lst = new ArrayList();
	String strTitle = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
	Document document = null;
	try {
		if (pStrXml.indexOf("<?xml") < 0)
			pStrXml = strTitle + pStrXml;
		document = DocumentHelper.parseText(pStrXml);
	} catch (DocumentException e) {
		log.error("==开发人员请注意:==\n将XML格式的字符串转换为XML DOM对象时发生错误啦!" + "\n详细错误信息如下:", e);
	}
	// 获取到根节点
	Element elRoot = document.getRootElement();
	// 获取根节点的所有子节点元素
	Iterator elIt = elRoot.elementIterator();
	while (elIt.hasNext()) {
		Element el = (Element) elIt.next();
		Iterator attrIt = el.attributeIterator();
		Map map = new HashMap();
		while (attrIt.hasNext()) {
			Attribute attribute = (Attribute) attrIt.next();
			map.put(attribute.getName().toLowerCase(), attribute.getData());
		}
		lst.add(map);
	}
	return lst;
}
 
Example 39
Project: unitimes   File: PointInTimeDataExport.java   View source code 5 votes vote down vote up
private void exportCourseType(CourseType courseType){
	Element courseTypeElement = courseTypesElement.addElement(sCourseTypeElementName);
	courseTypeElement.addAttribute(sUniqueIdAttribute, courseType.getUniqueId().toString());
	courseTypeElement.addAttribute(sReferenceAttribute, courseType.getReference());
	courseTypeElement.addAttribute(sLabelAttribute, courseType.getLabel());
	courseTypeElements.put(courseType.getUniqueId(), courseTypeElement);
}
 
Example 40
Project: wherehowsX   File: XMLFileAnalyzer.java   View source code 5 votes vote down vote up
private void getChildNodes(Element node, String parent) {
    String nodeName = getNodename(node, parent);
    if (!node.getTextTrim().equals(""))
        keyToValues.put(nodeName, node.getTextTrim());

    List<Element> listElement = node.elements();
    for (Element e : listElement) {
        if (!parent.equals(""))
            getChildNodes(e, parent + "." + node.getName());
        else
            getChildNodes(e, node.getName());
    }
}