Java Code Examples for org.dom4j.Element#getTextTrim()

The following examples show how to use org.dom4j.Element#getTextTrim() . 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: VCardManager.java    From Openfire with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the user's vCard information for a given vcard property name. If the property
 * has no defined text then an empty string will be returned. However, if the property
 * does not exist then a {@code null} value will be answered. Advanced user systems can
 * use vCard information to link to user directory information or store other relevant
 * user information.
 * <p>
 * Note that many elements in the vCard may have the same path so the returned value in that
 * case will be the first found element. For instance, "ADR:STREET" may be present in
 * many addresses of the user. Use {@link #getVCard(String)} to get the whole vCard of
 * the user.</p>
 *
 * @param username The username of the user to return his vCard property.
 * @param name     The name of the vcard property to retrieve encoded with ':' to denote
 *                 the path.
 * @return The vCard value found
 */
public String getVCardProperty(String username, String name) {
    String answer = null;
    Element vCardElement = getOrLoadVCard(username);
    if (vCardElement != null) {
        // A vCard was found for this user so now look for the correct element
        Element subElement = null;
        StringTokenizer tokenizer = new StringTokenizer(name, ":");
        while (tokenizer.hasMoreTokens()) {
            String tok = tokenizer.nextToken();
            if (subElement == null) {
                subElement = vCardElement.element(tok);
            }
            else {
                subElement = subElement.element(tok);
            }
            if (subElement == null) {
                break;
            }
        }
        if (subElement != null) {
            answer = subElement.getTextTrim();
        }
    }
    return answer;
}
 
Example 2
Source File: JPAOverriddenAnnotationReader.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private static void buildUniqueConstraints(AnnotationDescriptor annotation, Element element) {
	List uniqueConstraintElementList = element.elements( "unique-constraint" );
	UniqueConstraint[] uniqueConstraints = new UniqueConstraint[uniqueConstraintElementList.size()];
	int ucIndex = 0;
	Iterator ucIt = uniqueConstraintElementList.listIterator();
	while ( ucIt.hasNext() ) {
		Element subelement = (Element) ucIt.next();
		List<Element> columnNamesElements = subelement.elements( "column-name" );
		String[] columnNames = new String[columnNamesElements.size()];
		int columnNameIndex = 0;
		Iterator it = columnNamesElements.listIterator();
		while ( it.hasNext() ) {
			Element columnNameElt = (Element) it.next();
			columnNames[columnNameIndex++] = columnNameElt.getTextTrim();
		}
		AnnotationDescriptor ucAnn = new AnnotationDescriptor( UniqueConstraint.class );
		copyStringAttribute( ucAnn, subelement, "name", false );
		ucAnn.setValue( "columnNames", columnNames );
		uniqueConstraints[ucIndex++] = AnnotationFactory.create( ucAnn );
	}
	annotation.setValue( "uniqueConstraints", uniqueConstraints );
}
 
Example 3
Source File: JPAOverriddenAnnotationReader.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private void getEnumerated(List<Annotation> annotationList, Element element) {
	Element subElement = element != null ? element.element( "enumerated" ) : null;
	if ( subElement != null ) {
		AnnotationDescriptor ad = new AnnotationDescriptor( Enumerated.class );
		String enumerated = subElement.getTextTrim();
		if ( "ORDINAL".equalsIgnoreCase( enumerated ) ) {
			ad.setValue( "value", EnumType.ORDINAL );
		}
		else if ( "STRING".equalsIgnoreCase( enumerated ) ) {
			ad.setValue( "value", EnumType.STRING );
		}
		else if ( StringHelper.isNotEmpty( enumerated ) ) {
			throw new AnnotationException( "Unknown EnumType: " + enumerated + ". " + SCHEMA_VALIDATION );
		}
		annotationList.add( AnnotationFactory.create( ad ) );
	}
}
 
Example 4
Source File: BeanUtil.java    From anyline with Apache License 2.0 6 votes vote down vote up
public static Map<String,Object> xml2map(String xml){ 
	Map<String,Object> map = new HashMap<String,Object>(); 
	Document document; 
	try { 
		document =  DocumentHelper.parseText(xml);  
		Element root = document.getRootElement(); 
		for(Iterator<Element> itrProperty=root.elementIterator(); itrProperty.hasNext();){ 
			Element element = itrProperty.next(); 
			String key = element.getName(); 
			String value = element.getTextTrim(); 
			map.put(key, value); 
		} 
	} catch (DocumentException e) { 
		e.printStackTrace(); 
	} 
	return map; 
}
 
Example 5
Source File: WebXmlUtils.java    From Openfire with Apache License 2.0 5 votes vote down vote up
private static Set<String> getUrlPatterns( String type, Document webXml, String typeName )
{
    final Set<String> result = new HashSet<>();
    final List<Element> elements = webXml.getRootElement().elements( type + "-mapping" ); // all elements of 'type'-mapping (filter-mapping or servlet-mapping).
    for ( final Element element : elements )
    {
        final String name = element.elementTextTrim( type + "-name" );
        if ( typeName.equals( name ) )
        {
            final List<Element> urlPatternElements = element.elements( "url-pattern" );
            for ( final Element urlPatternElement : urlPatternElements )
            {
                final String urlPattern = urlPatternElement.getTextTrim();
                if ( urlPattern != null )
                {
                    result.add( urlPattern );
                }
            }

            // A filter can also be mapped to a servlet (by name). In that case, all url-patterns of the corresponding servlet-mapping should be used.
            if ( "filter".equals( type ) )
            {
                final List<Element> servletNameElements = element.elements( "servlet-name" );
                for ( final Element servletNameElement : servletNameElements )
                {
                    final String servletName = servletNameElement.getTextTrim();
                    if ( servletName != null )
                    {
                        result.addAll( getUrlPatterns( "servlet", webXml, servletName ) );
                    }
                }
            }
            break;
        }
    }

    return result;
}
 
Example 6
Source File: DurationParser.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
*/
  @Override
  public Object parse(final Element element) {
      // assert element.getName().equalsIgnoreCase("duration");

      // attributes
      final String sISODuration = element.getTextTrim();
      // null values no problems (default: null = false)
      final long millis = QTIHelper.parseISODuration(sISODuration);
      if (millis == 0) {
          return null;
      }
      return new Duration(millis);
  }
 
Example 7
Source File: XmlProperty.java    From jfinal-api-scaffold with MIT License 5 votes vote down vote up
/**
 * Returns the value of the specified property.
 *
 * @param name the name of the property to get.
 * @return the value of the specified property.
 */
public synchronized String getProperty(String name) {
    String value = propertyCache.get(name);
    if (value != null) {
        return value;
    }

    String[] propName = parsePropertyName(name);
    // Search for this property by traversing down the XML heirarchy.
    Element element = document.getRootElement();
    for (String aPropName : propName) {
        element = element.element(aPropName);
        if (element == null) {
            // This node doesn't match this part of the property name which
            // indicates this property doesn't exist so return null.
            return null;
        }
    }
    // At this point, we found a matching property, so return its value.
    // Empty strings are returned as null.
    value = element.getTextTrim();
    if ("".equals(value)) {
        return null;
    }
    else {
        // Add to cache so that getting property next time is fast.
        propertyCache.put(name, value);
        return value;
    }
}
 
Example 8
Source File: CfTableRepository.java    From mybatis-dalgen with Apache License 2.0 5 votes vote down vote up
/**
 * Sets cf operation cdata.
 *
 * @param cfTable the cf table
 * @param e the e
 * @param cfOperation the cf operation
 */
private void setCfOperationCdata(CfTable cfTable, Element e, CfOperation cfOperation) {
    String cXml = e.asXML();
    String[] lines = StringUtils.split(cXml, "\n");
    StringBuilder sb = new StringBuilder();
    for (int i = 1; i < lines.length - 1; i++) {
        if (i > 1) {
            sb.append("\n");
        }
        sb.append(lines[i]);
    }
    String cdata = sb.toString();
    //SQlDESC
    String sqlDesc = cdata.replaceAll(FOR_DESC_SQL_P, " ");
    sqlDesc = sqlDesc.replaceAll(FOR_DESC_SQL_PN, " ");
    cfOperation.setSqlDesc(sqlDesc);

    String text = e.getTextTrim();
    if (StringUtils.indexOf(text, "*") > 0) {
        Matcher m = STAR_BRACKET.matcher(text);
        if (!m.find()) {
            cdata = StringUtils.replace(cdata, "*", "<include refid=\"Base_Column_List\" />");
        }
    }
    //? 参数替换 不指定类型
    cdata = delQuestionMarkParam(cdata, cfOperation, cfTable);

    //添加sql注释,以便于DBA 分析top sql 定位
    cfOperation.setCdata(addSqlAnnotation(cdata, cfOperation.getName(), cfTable.getSqlname()));
    //pageCount添加
    setCfOperationPageCdata(cdata, cfOperation);
}
 
Example 9
Source File: LdapVCardProvider.java    From Openfire with Apache License 2.0 5 votes vote down vote up
private void treeWalk(Element rootElement, Set<String> set) {
    for ( final Element element : rootElement.elements() ) {
        final String value = element.getTextTrim();
        if ( value != null && !value.isEmpty()) {
            final Matcher matcher = PATTERN.matcher(value);
            while (matcher.find()) {
                final String match = matcher.group(2);
                Log.trace("Found attribute '{}'", match);
                set.add(match);
            }
        }
        treeWalk(element, set);
    }
}
 
Example 10
Source File: UserSetHelper.java    From cuba with Apache License 2.0 5 votes vote down vote up
public static String removeEntities(String filterXml, Collection ids) {
    Document document;
    try {
        document = DocumentHelper.parseText(filterXml);
    } catch (DocumentException e) {
        throw new RuntimeException(e);
    }
    Element param = document.getRootElement().element("and").element("c").element("param");
    String currentIds = param.getTextTrim();
    Set<String> set = parseSet(currentIds);
    String listOfIds = removeIds(set, ids);
    param.setText(listOfIds);
    return document.asXML();
}
 
Example 11
Source File: MattextParser.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
*/
  @Override
  public Object parse(final Element element) {
      // assert element.getName().equalsIgnoreCase("mattext");
      final String text = element.getTextTrim();
      if (text != null && text.length() > 0) {
          return new Mattext(text);
      }
      return null;
  }
 
Example 12
Source File: XMLProperties.java    From Openfire with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the value of the specified property.
 *
 * @param name the name of the property to get.
 * @param ignoreEmpty Ignore empty property values (return null)
 * @return the value of the specified property.
 */
public synchronized String getProperty(String name, boolean ignoreEmpty) {
    String value = propertyCache.get(name);
    if (value != null) {
        return value;
    }

    String[] propName = parsePropertyName(name);
    // Search for this property by traversing down the XML hierarchy.
    Element element = document.getRootElement();
    for (String aPropName : propName) {
        element = element.element(aPropName);
        if (element == null) {
            // This node doesn't match this part of the property name which
            // indicates this property doesn't exist so return null.
            return null;
        }
    }
    // At this point, we found a matching property, so return its value.
    // Empty strings are returned as null.
    value = element.getTextTrim();
    if (ignoreEmpty && "".equals(value)) {
        return null;
    }
    else {
        // check to see if the property is marked as encrypted
        if (JiveGlobals.isXMLPropertyEncrypted(name)) {
            Attribute encrypted = element.attribute(ENCRYPTED_ATTRIBUTE);
            if (encrypted != null) {
                value = JiveGlobals.getPropertyEncryptor().decrypt(value);
            } else {
                // rewrite property as an encrypted value
                Log.info("Rewriting XML property " + name + " as an encrypted value");
                setProperty(name, value);
            }
        }
        // Add to cache so that getting property next time is fast.
        propertyCache.put(name, value);
        return value;
    }
}
 
Example 13
Source File: WxWebMobilePay.java    From pay-spring-boot with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 预支付
 * @param trade
 * @return
 * @throws DocumentException
 */
private String prepay(WxTrade trade) throws DocumentException {
    Jedis redis = null;
    try{
        redis = CommonConfig.getJedisPool().getResource();
        String codeUrlKey = "pay:wx:out_trade_no:".concat(trade.getOutTradeNo()).concat(":code_url");

        /**
         * 从缓存中寻找二维码链接
         */
        String reply = redis.get(codeUrlKey);
        if(StringUtils.isNotBlank(reply)){
            return reply;
        }

        /**
         * 远程请求二维码链接
         */
        log.info("[微信支付]开始预支付");

        Map<String, String> params = new HashMap<String, String>();
        params.put("appid", trade.getAppid());
        params.put("mch_id", trade.getMchid());
        params.put("nonce_str", trade.getNonceStr());
        params.put("body", trade.getBody());
        params.put("detail", trade.getDetail());
        params.put("out_trade_no", trade.getOutTradeNo());
        params.put("total_fee", trade.getTotalFee());
        params.put("spbill_create_ip", trade.getSpbillCreateIp());
        params.put("notify_url", trade.getNotifyUrl());
        params.put("trade_type", trade.getTradeType());
        params.put("scene_info", trade.getSceneInfo());
        params.put("sign", signMD5(params));

        log.info("[微信支付]预支付参数构造完成\n" + JSON.toJSONString(params));

        Document paramsDoc = buildDocFromMap(params);

        log.info("[微信支付]预支付XML参数构造完成\n" + paramsDoc.asXML());

        log.info("[微信支付]开始请求微信服务器进行预支付");

        SimpleResponse response = HttpClient.getClient().post(WxPayConfig.getUnifiedorderURL(), paramsDoc.asXML());
        if(response.getCode() != 200){
            throw new RuntimeException("请求预支付通信失败, HTTP STATUS[" + response.getCode() + "]");
        }
        String responseBody = response.getStringBody();

        log.info("[微信支付]预支付通信成功\n" + responseBody);

        /**
         * 解析响应数据
         */
        Document responseDoc = DocumentHelper.parseText(responseBody);
        Element mwebUrlElement = responseDoc.getRootElement().element("mweb_url");
        if(mwebUrlElement == null){
            throw new RuntimeException("请求预支付未找到付款链接(mweb_url)");
        }
        String mwebUrl = mwebUrlElement.getTextTrim();

        log.info("[微信支付]成功获取付款链接[" + mwebUrl + "]");

        /**
         * 缓存二维码链接
         */
        redis.set(codeUrlKey, mwebUrl);
        redis.expire(codeUrlKey, 7170);

        return mwebUrl;
    }finally{
        if(redis != null){
            redis.close();
            redis = null;
        }
    }
}
 
Example 14
Source File: WxJsSdkPay.java    From pay-spring-boot with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 预支付
 * @param trade
 * @return
 * @throws DocumentException
 */
private String prepay(WxTrade trade) throws DocumentException {
    Jedis redis = null;
    try{
        redis = CommonConfig.getJedisPool().getResource();
        String prepayidKey = "pay:wx:out_trade_no:".concat(trade.getOutTradeNo()).concat(":prepay_id");

        /*
            从缓存中寻找预支付id
         */
        String reply = redis.get(prepayidKey);
        if(StringUtils.isNotBlank(reply)){
            return reply;
        }

        /*
            远程请求预支付id
         */
        log.info("[微信支付]开始预支付");

        Map<String, String> params = new HashMap<String, String>();
        params.put("appid", trade.getAppid());
        params.put("mch_id", trade.getMchid());
        params.put("nonce_str", trade.getNonceStr());
        params.put("body", trade.getBody());
        params.put("detail", trade.getDetail());
        params.put("out_trade_no", trade.getOutTradeNo());
        params.put("total_fee", trade.getTotalFee());
        params.put("spbill_create_ip", trade.getSpbillCreateIp());
        params.put("notify_url", trade.getNotifyUrl());
        params.put("trade_type", trade.getTradeType());
        params.put("openid", trade.getOpenid());
        params.put("sign", signMD5(params));

        log.info("[微信支付]预支付参数构造完成\n" + JSON.toJSONString(params));

        Document paramsDoc = buildDocFromMap(params);

        log.info("[微信支付]预支付XML参数构造完成\n" + paramsDoc.asXML());

        log.info("[微信支付]开始请求微信服务器进行预支付");

        SimpleResponse response = HttpClient.getClient().post(WxPayConfig.getUnifiedorderURL(), paramsDoc.asXML());
        if(response.getCode() != 200){
            throw new RuntimeException("请求预支付通信失败, HTTP STATUS[" + response.getCode() + "]");
        }
        String responseBody = response.getStringBody();

        log.info("[微信支付]预支付通信成功\n" + responseBody);

        /*
            解析响应数据
         */
        Document responseDoc = DocumentHelper.parseText(responseBody);
        Element prepayIdElement = responseDoc.getRootElement().element("prepay_id");
        if(prepayIdElement == null){
            throw new RuntimeException("请求预支付未找到预支付id(prepay_id)");
        }
        String prepayid = prepayIdElement.getTextTrim();

        log.info("[微信支付]成功获取预支付id[" + prepayid + "]");

        /*
            缓存预支付id
         */
        redis.set(prepayidKey, prepayid);
        redis.expire(prepayidKey, 7170);

        return prepayid;
    }finally{
        if(redis != null){
            redis.close();
            redis = null;
        }
    }
}
 
Example 15
Source File: XMLContext.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
private void setAccess(Element unitElement, Default defaultType) {
	if ( unitElement != null ) {
		String access = unitElement.getTextTrim();
		setAccess( access, defaultType );
	}
}
 
Example 16
Source File: FilterUtil.java    From CEC-Automatic-Annotation with Apache License 2.0 4 votes vote down vote up
public static void parseXML(String filePath) {
	// InputStream is = null;
	// try {
	// is = new InputStreamReader(new FileInputStream(new File(filePath)));
	// } catch (FileNotFoundException e1) {
	// e1.printStackTrace();
	// MyLogger.logger.error(e1.getMessage());
	// }
	SAXReader saxReader = new SAXReader();
	Document document = null;
	try {
		document = saxReader.read(new BufferedReader(new InputStreamReader(new FileInputStream(new File(filePath)),
				EncodingUtil.CHARSET_UTF8)));
	} catch (DocumentException | UnsupportedEncodingException | FileNotFoundException e1) {
		e1.printStackTrace();
		MyLogger.logger.error(e1.getMessage());
	}
	// Element rootElement = document.getRootElement();
	// System.out.println("根节点名称:" + rootElement.getName());
	// System.out.println("根节点的属性个数:" + rootElement.attributeCount());
	// System.out.println("根节点id属性的值:" + rootElement.attributeValue("id"));
	// System.out.println("根节点内文本:" + rootElement.getText());
	// System.out.println("根节点内去掉换行tab键等字符:" + rootElement.getTextTrim());
	// System.out.println("根节点子节点文本内容:" + rootElement.getStringValue());

	// Element content = rootElement.element("Content");
	// Element paragraph = content.element("Paragraph");
	// Element sentence = paragraph.element("Sentence");

	// Element event = sentence.element("Event");
	// Element event = paragraph.element("Event");
	@SuppressWarnings("unchecked")
	List<Element> event_list = document.selectNodes("//Sentence/Event");
	@SuppressWarnings("unchecked")
	List<Element> denoter_list = document.selectNodes("//Sentence/Event/Denoter");
	Iterator<Element> denoterIter = denoter_list.iterator();
	Iterator<Element> eventIter = event_list.iterator();
	// Element para = doc.element("para");
	// Element sent = para.element("sent");
	while (denoterIter.hasNext()) {
		Element denoter = denoterIter.next();
		Element event = eventIter.next();
		String denoterValue = denoter.getTextTrim();
		for (int i = 0; i < treeSetsList.size(); i++) {
			if (treeSetsList.get(i).contains(denoterValue)) {
				String typeValue = type_value.get(i);// 获取denoter的type值
				if (0 == i) {
					// 说明是意念事件,那么这时候拿到的typeValue是Event的属性值
					event.addAttribute("type", typeValue);
					denoter.addAttribute("type", "statement");// 默认意念事件触发词的类型都是statement
					// 注意如果是意念事件的话,event的type是thoughtEvent,denoter的属性是statement
					// 只要发现了一个意念事件,那个根据原则,就应该将意念事件的关系加到文档末尾
					document.getRootElement().addElement(Annotation.THOUGHTEVENT_RELATION);
				} else {
					// 为event添加属性和值
					denoter.addAttribute("type", typeValue);
				}
			}
		}
	}
	// 这部分用来实现判断Time是不是绝对时间
	@SuppressWarnings("unchecked")
	List<Element> time_list = document.selectNodes("//Sentence/Event/Time");
	Iterator<Element> timeIter = time_list.iterator();
	while (timeIter.hasNext()) {
		Element time = timeIter.next();
		String timeValue = time.getTextTrim();
		if (isAbsTime(timeValue)) {
			time.addAttribute("type", "absTime");
		}
	}

	try {
		// 使用XMLWriter写入,可以控制格式,经过调试,发现这种方式会出现乱码,主要是因为Eclipse中xml文件和JFrame中文件编码不一致造成的
		OutputFormat format = OutputFormat.createPrettyPrint();
		format.setEncoding(EncodingUtil.CHARSET_UTF8);
		// format.setSuppressDeclaration(true);//这句话会压制xml文件的声明,如果为true,就不打印出声明语句
		format.setIndent(true);// 设置缩进
		format.setIndent("	");// 空行方式缩进
		format.setNewlines(true);// 设置换行

		XMLWriter writer = new XMLWriter(new FileWriterWithEncoding(new File(filePath), EncodingUtil.CHARSET_UTF8), format);
		writer.write(document);
		writer.close();
		// 使用common的Util包写入
		// FileWriterWithEncoding out = new FileWriterWithEncoding(new File(filePath), "UTF-8");
		// document.write(out);
		// out.flush();
		// out.close();
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
Example 17
Source File: XmlToAsn1.java    From mts with GNU General Public License v3.0 4 votes vote down vote up
public Object parseField(Element element, String type, String className) throws IllegalArgumentException, IllegalAccessException, ClassNotFoundException, InstantiationException, InvocationTargetException, NoSuchMethodException 
{
    if (type.equals("java.lang.Boolean")||type.equals("boolean"))  
    {
        return Utils.parseBoolean(element.getTextTrim(), "type");
    }
    else if (type.equals("java.lang.String")||type.equals("String")) 
    {
        return element.getTextTrim();
    }
    else if (type.equals("java.lang.Integer")||type.equals("int")) 
    {
        return Integer.parseInt(element.getTextTrim());
    }
    else if (type.equals("java.lang.Float")||type.equals("float"))  
    {
        return Float.parseFloat(element.getTextTrim());
    }
    else if (type.equals("java.lang.Short")||type.equals("short"))  
    {
        return Short.parseShort(element.getTextTrim());
    }
    else if (type.equals("java.lang.Long")||type.equals("long"))  
    {
        return Long.parseLong(element.getTextTrim());
    }
    else if (type.equals("java.lang.Byte")||type.equals("byte"))  
    {
        return Byte.parseByte(element.getTextTrim());
    }
    else if (type.equals("byte[]")) 
    {
        return new DefaultArray(Utils.parseBinaryString(element.getTextTrim())).getBytes();
    }
    else 
    {
        String classNameCurrent = type.substring(type.lastIndexOf(".") + 1);
        if ((type.contains(className)) && (!(type.equals(className + classNameCurrent)))) 
        {
            // static class : h225.h323_className$staticClass
            type = type.substring(0, type.lastIndexOf(".")) + "$" + type.substring(type.lastIndexOf(".") + 1);
        }
        if (!type.contains(className)) 
        {
            className = "";
        }
        Object obj = Class.forName(type).newInstance();
        Object objComplexClass = this.instanceClass(obj.getClass().getName(), className);
        initObject(objComplexClass, element, className);
        return objComplexClass;
    }
}
 
Example 18
Source File: MsgRtpFlow.java    From mts with GNU General Public License v3.0 4 votes vote down vote up
public ArrayList<Array> parsePacketPayload(Element packet, Runner runner) throws Exception {
    List<Element> payloads = packet.elements("payload");
    ArrayList<Array> listPayloadData = new ArrayList<Array>();
    LinkedList<String> listPayload;
    String format = null;
    String text = null;

    for (Element element : payloads) {
        format = element.attributeValue("format");
        text = element.getTextTrim();

        if(Parameter.matchesParameter(text) && payloads.size() == 1){
            // optimisation, use cache
            Parameter parameter = runner.getParameterPool().get(text);
            if (format.equalsIgnoreCase("text")) {
                listPayloadData = (ArrayList<Array>) ParameterCache.getAsAsciiArrayList(parameter);
            }
            else if (format.equalsIgnoreCase("binary")) {
                listPayloadData = (ArrayList<Array>)  ParameterCache.getAsHexArrayList(parameter);
            }
            else {
                throw new Exception("format of payload <" + format + "> is unknown");
            }
        }
        else{
            listPayload = runner.getParameterPool().parse(text);
            if (format.equalsIgnoreCase("text")) {
                for (Iterator<String> it = listPayload.iterator(); it.hasNext();) {
                    listPayloadData.add(new DefaultArray(it.next().getBytes()));
                }
            }
            else if (format.equalsIgnoreCase("binary")) {
                for (Iterator<String> it = listPayload.iterator(); it.hasNext();) {
                    listPayloadData.add(Array.fromHexString(it.next()));
                }
            }
            else {
                throw new Exception("format of payload <" + format + "> is unknown");
            }
        }
    }
    return listPayloadData;
}
 
Example 19
Source File: CustomTag.java    From ofdrw with Apache License 2.0 2 votes vote down vote up
/**
 * 【可选】
 * 获取 指向自定义标引内容节点适用的Schema文件
 *
 * @return 指向自定义标引内容节点适用的Schema文件
 */
public ST_Loc getSchemaLoc() {
    Element e = this.getOFDElement("SchemaLoc");
    return e == null ? null : new ST_Loc(e.getTextTrim());
}
 
Example 20
Source File: Property.java    From ofdrw with Apache License 2.0 2 votes vote down vote up
/**
 * 【必选】
 * 获取 属性值
 *
 * @return 属性值
 */
public String getValue() {
    Element e = this.getOFDElement("Value");
    return e == null ? null : e.getTextTrim();
}