当前位置: 首页>>代码示例>>Java>>正文


Java UtilXml类代码示例

本文整理汇总了Java中org.ofbiz.base.util.UtilXml的典型用法代码示例。如果您正苦于以下问题:Java UtilXml类的具体用法?Java UtilXml怎么用?Java UtilXml使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


UtilXml类属于org.ofbiz.base.util包,在下文中一共展示了UtilXml类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Assert

import org.ofbiz.base.util.UtilXml; //导入依赖的package包/类
public Assert(Element element, SimpleMethod simpleMethod) throws MiniLangException {
    super(element, simpleMethod);
    if (MiniLangValidate.validationOn()) {
        MiniLangValidate.attributeNames(simpleMethod, element, "title", "error-list-name");
        MiniLangValidate.constantAttributes(simpleMethod, element, "title", "error-list-name");
    }
    errorListFma = FlexibleMapAccessor.getInstance(MiniLangValidate.checkAttribute(element.getAttribute("error-list-name"), "error_list"));
    titleExdr = FlexibleStringExpander.getInstance(element.getAttribute("title"));
    List<? extends Element> childElements = UtilXml.childElementList(element);
    if (MiniLangValidate.validationOn() && childElements.isEmpty()) {
        MiniLangValidate.handleError("No conditional elements.", simpleMethod, element);
    }
    List<Conditional> conditionalList = new ArrayList<Conditional>(childElements.size());
    for (Element conditionalElement : UtilXml.childElementList(element)) {
        conditionalList.add(ConditionalFactory.makeConditional(conditionalElement, simpleMethod));
    }
    this.conditionalList = Collections.unmodifiableList(conditionalList);
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:19,代码来源:Assert.java

示例2: addPackageElement

import org.ofbiz.base.util.UtilXml; //导入依赖的package包/类
private static void addPackageElement(DispatchContext dctx, Document requestDoc, Element shipmentElement, List<Map<String, Object>> shippableItemInfo, Map<String, BigDecimal> packageMap, BigDecimal minWeight) {
    BigDecimal packageWeight = checkForDefaultPackageWeight(ShipmentWorker.calcPackageWeight(dctx,packageMap, shippableItemInfo, BigDecimal.ZERO), minWeight);
    Element packageElement = UtilXml.addChildElement(shipmentElement, "Package", requestDoc);
    Element packagingTypeElement = UtilXml.addChildElement(packageElement, "PackagingType", requestDoc);
    UtilXml.addChildElementValue(packagingTypeElement, "Code", "00", requestDoc);
    UtilXml.addChildElementValue(packagingTypeElement, "Description", "Unknown PackagingType", requestDoc);
    UtilXml.addChildElementValue(packageElement, "Description", "Package Description", requestDoc);
    Element packageWeightElement = UtilXml.addChildElement(packageElement, "PackageWeight", requestDoc);
    UtilXml.addChildElementValue(packageWeightElement, "Weight", packageWeight.toPlainString(), requestDoc);
    //If product is in shippable Package then it we should have one product per packagemap
    if (packageMap.size() ==1) {
        Iterator<String> i = packageMap.keySet().iterator();
        String productId = i.next();
        Map<String, Object> productInfo = ShipmentWorker.getProductItemInfo(shippableItemInfo, productId);
        if (productInfo.get("inShippingBox") != null &&  ((String) productInfo.get("inShippingBox")).equalsIgnoreCase("Y")
                && productInfo.get("shippingDepth") !=null && productInfo.get("shippingWidth") !=null && productInfo.get("shippingHeight") !=null) {
            Element dimensionsElement = UtilXml.addChildElement(packageElement, "Dimensions", requestDoc);
            UtilXml.addChildElementValue(dimensionsElement, "Length", productInfo.get("shippingDepth").toString(), requestDoc);
            UtilXml.addChildElementValue(dimensionsElement, "Width", productInfo.get("shippingWidth").toString(), requestDoc);
            UtilXml.addChildElementValue(dimensionsElement, "Height", productInfo.get("shippingHeight").toString(), requestDoc);
        }
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:24,代码来源:UpsServices.java

示例3: OrderMapList

import org.ofbiz.base.util.UtilXml; //导入依赖的package包/类
public OrderMapList(Element element, SimpleMethod simpleMethod) throws MiniLangException {
    super(element, simpleMethod);
    if (MiniLangValidate.validationOn()) {
        MiniLangValidate.attributeNames(simpleMethod, element, "list");
        MiniLangValidate.requiredAttributes(simpleMethod, element, "list");
        MiniLangValidate.expressionAttributes(simpleMethod, element, "list");
        MiniLangValidate.childElements(simpleMethod, element, "order-by");
        MiniLangValidate.requiredChildElements(simpleMethod, element, "order-by");
    }
    listFma = FlexibleMapAccessor.getInstance(element.getAttribute("list"));
    List<? extends Element> orderByElements = UtilXml.childElementList(element, "order-by");
    if (orderByElements.size() > 0) {
        ArrayList<FlexibleMapAccessor<String>> orderByList = new ArrayList<FlexibleMapAccessor<String>>(orderByElements.size());
        for (Element orderByElement : orderByElements) {
            FlexibleMapAccessor<String> fma = FlexibleMapAccessor.getInstance(orderByElement.getAttribute("field"));
            orderByList.add(fma);
        }
        mc = new MapComparator(orderByList);
    } else {
        mc = null;
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:23,代码来源:OrderMapList.java

示例4: handleErrors

import org.ofbiz.base.util.UtilXml; //导入依赖的package包/类
public static void handleErrors(Element rootElement, List<Object> errorList, Locale locale) {
    Element errorElement = null;
    if ("Error".equalsIgnoreCase(rootElement.getNodeName())) {
        errorElement = rootElement;
    } else {
        errorElement = UtilXml.firstChildElement(rootElement, "Error");
    }
    if (UtilValidate.isNotEmpty(errorElement)) {
        Element errorCodeElement = UtilXml.firstChildElement(errorElement, "Code");
        Element errorMessageElement = UtilXml.firstChildElement(errorElement, "Message");
        if (errorCodeElement != null || errorMessageElement != null) {
            String errorCode = UtilXml.childElementValue(errorElement, "Code");
            String errorMessage = UtilXml.childElementValue(errorElement, "Message");
            if (UtilValidate.isNotEmpty(errorCode) || UtilValidate.isNotEmpty(errorMessage)) {
                errorList.add(UtilProperties.getMessage(resourceError, "FacilityShipmentFedexErrorMessage", 
                        UtilMisc.toMap("errorCode", errorCode, "errorMessage", errorMessage), locale));
            }
        }
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:21,代码来源:FedexServices.java

示例5: getMessageList

import org.ofbiz.base.util.UtilXml; //导入依赖的package包/类
private static List<String> getMessageList(Document responseDocument) {

        List<String> messageList = new ArrayList<String>();

        Element engineDocElement = UtilXml.firstChildElement(responseDocument.getDocumentElement(), "EngineDoc");
        Element messageListElement = UtilXml.firstChildElement(engineDocElement, "MessageList");
        List<? extends Element> messageElementList = UtilXml.childElementList(messageListElement, "Message");
        if (UtilValidate.isNotEmpty(messageElementList)) {
            for (Iterator<? extends Element> i = messageElementList.iterator(); i.hasNext();) {
                Element messageElement = i.next();
                int severity = 0;
                try {
                    severity = Integer.parseInt(UtilXml.childElementValue(messageElement, "Sev"));
                } catch (NumberFormatException nfe) {
                    Debug.logError("Error parsing message severity: " + nfe.getMessage(), module);
                    severity = 9;
                }
                String message = "[" + UtilXml.childElementValue(messageElement, "Audience") + "] " +
                        UtilXml.childElementValue(messageElement, "Text") + " (" + severity + ")";
                messageList.add(message);
            }
        }

        return messageList;
    }
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:26,代码来源:CCPaymentServices.java

示例6: getMessageListMaxSev

import org.ofbiz.base.util.UtilXml; //导入依赖的package包/类
private static int getMessageListMaxSev(Document responseDocument) {

        int maxSev = 0;

        Element engineDocElement = UtilXml.firstChildElement(responseDocument.getDocumentElement(), "EngineDoc");
        Element messageListElement = UtilXml.firstChildElement(engineDocElement, "MessageList");
        String maxSevStr = UtilXml.childElementValue(messageListElement, "MaxSev");
        if (UtilValidate.isNotEmpty(maxSevStr)) {
            try {
                maxSev = Integer.parseInt(maxSevStr);
            } catch (NumberFormatException nfe) {
                Debug.logError("Error parsing MaxSev: " + nfe.getMessage(), module);
                maxSev = 9;
            }
        }
        return maxSev;
    }
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:18,代码来源:CCPaymentServices.java

示例7: readSubNodeActions

import org.ofbiz.base.util.UtilXml; //导入依赖的package包/类
public static List<ModelAction> readSubNodeActions(ModelNode.ModelSubNode modelSubNode, Element actionsElement) {
    List<? extends Element> actionElementList = UtilXml.childElementList(actionsElement);
    List<ModelAction> actions = new ArrayList<ModelAction>(actionElementList.size());
    for (Element actionElement : actionElementList) {
        if ("service".equals(actionElement.getNodeName())) {
            actions.add(new Service(modelSubNode, actionElement));
        } else if ("entity-and".equals(actionElement.getNodeName())) {
            actions.add(new EntityAnd(modelSubNode, actionElement));
        } else if ("entity-condition".equals(actionElement.getNodeName())) {
            actions.add(new EntityCondition(modelSubNode, actionElement));
        } else if ("script".equals(actionElement.getNodeName())) {
            actions.add(new Script(modelSubNode, actionElement));
        } else {
            actions.add(AbstractModelAction.newInstance(modelSubNode, actionElement));
        }
    }
    return actions;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:19,代码来源:ModelTreeAction.java

示例8: getCDATADef

import org.ofbiz.base.util.UtilXml; //导入依赖的package包/类
private String getCDATADef(Element baseElement, String tagName) {
    String value = "";
    NodeList nl = baseElement.getElementsByTagName(tagName);

    // if there are more then one decriptions we will use only the first one
    if (nl.getLength() > 0) {
        Node n = nl.item(0);
        NodeList childNodes = n.getChildNodes();

        if (childNodes.getLength() > 0) {
            Node cdata = childNodes.item(0);

            value = UtilXml.checkEmpty(cdata.getNodeValue());
        }
    }
    return value;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:18,代码来源:ModelServiceReader.java

示例9: readCondition

import org.ofbiz.base.util.UtilXml; //导入依赖的package包/类
/**
 * SCIPIO: read the condition element, then tries the condition attribute.
 */
ModelCondition readCondition(ModelWidget modelWidget, ElementHelper elem, String directiveName) {
    Element conditionElement = elem.firstChildElement("condition");
    ModelCondition condition = null;
    Element conditionChildElement = UtilXml.firstChildElement(conditionElement);
    if (conditionChildElement != null) {
        condition = ModelScreenCondition.SCREEN_CONDITION_FACTORY.newInstance(modelWidget, conditionChildElement);
    }
    String conditionExdrStr = elem.attr("condition");
    if (!conditionExdrStr.isEmpty()) {
        if (condition == null) {
            condition = ModelScreenCondition.makeBooleanExprCondition(modelWidget, 
                    FlexibleStringExpander.getInstance(conditionExdrStr));
        } else {
            Debug.logError("Scipio: " + directiveName + " directive cannot have both condition element and condition attribute, will use only condition element" +
                    getLogDirectiveLocationString(), module);
        }
    }
    if (condition == null) {
        condition = AbstractModelCondition.FALSE_CONDITION;
        Debug.logError("Scipio: " + directiveName + " directive is missing condition in widget - will always evaluate to false" + getLogDirectiveLocationString(), module);
    }
    return condition;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:27,代码来源:AbstractModelAction.java

示例10: InlineHtmlTemplate

import org.ofbiz.base.util.UtilXml; //导入依赖的package包/类
public InlineHtmlTemplate(ModelScreen modelScreen, Element htmlTemplateElement) {
    super(modelScreen, htmlTemplateElement);
    String lang = htmlTemplateElement.getAttribute("lang");
    this.templateId = modelScreen.getSourceLocation() + "#" + modelScreen.getName() + "@" + this.getStartColumn() + "," + this.getStartLine();
    String templateBody = UtilXml.elementValue(htmlTemplateElement); // htmlTemplateElement.getTextContent();
    for(String tmplType : HtmlTemplate.getSupportedTypes()) {
        if (templateBody.startsWith(tmplType + ":")) {
            templateBody = templateBody.substring(tmplType.length() + 1);
            lang = tmplType;
            break;
        }
    }
    this.lang = lang;
    boolean trimLines = "true".equals(htmlTemplateElement.getAttribute("trim-lines"));
    this.templateBody = trimLines ? ScriptUtil.trimScriptLines(templateBody) : templateBody;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:17,代码来源:HtmlWidget.java

示例11: ValidateMethodCondition

import org.ofbiz.base.util.UtilXml; //导入依赖的package包/类
public ValidateMethodCondition(Element element, SimpleMethod simpleMethod) throws MiniLangException {
    super(element, simpleMethod);
    if (MiniLangValidate.validationOn()) {
        MiniLangValidate.attributeNames(simpleMethod, element, "field", "method", "class");
        MiniLangValidate.requiredAttributes(simpleMethod, element, "field", "method");
        MiniLangValidate.constantAttributes(simpleMethod, element, "method", "class");
        MiniLangValidate.expressionAttributes(simpleMethod, element, "field");
    }
    this.fieldFma = FlexibleMapAccessor.getInstance(element.getAttribute("field"));
    this.methodName = element.getAttribute("method");
    this.className = MiniLangValidate.checkAttribute(element.getAttribute("class"), "org.ofbiz.base.util.UtilValidate");
    Element childElement = UtilXml.firstChildElement(element);
    if (childElement != null && !"else".equals(childElement.getTagName())) {
        this.subOps = Collections.unmodifiableList(SimpleMethod.readOperations(element, simpleMethod));
    } else {
        this.subOps = null;
    }
    Element elseElement = UtilXml.firstChildElement(element, "else");
    if (elseElement != null) {
        this.elseSubOps = Collections.unmodifiableList(SimpleMethod.readOperations(elseElement, simpleMethod));
    } else {
        this.elseSubOps = null;
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:25,代码来源:ValidateMethodCondition.java

示例12: create

import org.ofbiz.base.util.UtilXml; //导入依赖的package包/类
/**
 * Returns a new <code>ModelRelation</code> instance, initialized with the specified values.
 * 
 * @param modelEntity The <code>ModelEntity</code> this relation is a member of.
 * @param relationElement The <code>&lt;relation&gt;</code> element containing the values for this relation.
 * @param isAutoRelation <code>true</code> if this relation was generated automatically by the entity engine.
 */
public static ModelRelation create(ModelEntity modelEntity, Element relationElement, boolean isAutoRelation) {
    String type = relationElement.getAttribute("type").intern();
    String title = relationElement.getAttribute("title").intern();
    String relEntityName = relationElement.getAttribute("rel-entity-name").intern();
    String fkName = relationElement.getAttribute("fk-name").intern();
    String description = UtilXml.childElementValue(relationElement, "description");
    List<ModelKeyMap >keyMaps = Collections.emptyList();
    List<? extends Element> elementList = UtilXml.childElementList(relationElement, "key-map");
    if (!elementList.isEmpty()) {
        keyMaps = new ArrayList<ModelKeyMap>(elementList.size());
        for (Element keyMapElement : elementList) {
            keyMaps.add(new ModelKeyMap(keyMapElement));
        }
        keyMaps = Collections.unmodifiableList(keyMaps);
    }
    return new ModelRelation(modelEntity, description, type, title, relEntityName, fkName, keyMaps, isAutoRelation);
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:25,代码来源:ModelRelation.java

示例13: ModelAliasAll

import org.ofbiz.base.util.UtilXml; //导入依赖的package包/类
public ModelAliasAll(Element aliasAllElement) {
    this.entityAlias = UtilXml.checkEmpty(aliasAllElement.getAttribute("entity-alias")).intern();
    this.prefix = UtilXml.checkEmpty(aliasAllElement.getAttribute("prefix")).intern();
    this.groupBy = "true".equals(UtilXml.checkEmpty(aliasAllElement.getAttribute("group-by")));
    this.function = UtilXml.checkEmpty(aliasAllElement.getAttribute("function"));
    this.fieldSet = UtilXml.checkEmpty(aliasAllElement.getAttribute("field-set")).intern();

    List<? extends Element> excludes = UtilXml.childElementList(aliasAllElement, "exclude");
    if (UtilValidate.isNotEmpty(excludes)) {
        this.fieldsToExclude = new HashSet<String>();
        for (Element excludeElement: excludes) {
            this.fieldsToExclude.add(excludeElement.getAttribute("field").intern());
        }
    } else {
        this.fieldsToExclude = null;
    }

}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:19,代码来源:ModelViewEntity.java

示例14: ModelScreen

import org.ofbiz.base.util.UtilXml; //导入依赖的package包/类
/** XML Constructor */
public ModelScreen(Element screenElement, ModelScreenGroup modelScreenGroup, String sourceLocation) {
    super(screenElement);
    this.sourceLocation = sourceLocation;
    this.transactionTimeoutExdr = FlexibleStringExpander.getInstance(screenElement.getAttribute("transaction-timeout"));
    this.modelScreenGroup = modelScreenGroup;
    this.useTransaction = "true".equals(screenElement.getAttribute("use-transaction"));
    this.useCache = "true".equals(screenElement.getAttribute("use-cache"));

    // read in the section, which will read all sub-widgets too
    Element sectionElement = UtilXml.firstChildElement(screenElement, "section");
    if (sectionElement == null) {
        // SCIPIO: we support actions or widgets block shorthand
        // NOTE: the XSD may not support widgets block shorthand for now, 
        // because unlike actions shorthand, widgets shorthand usually ends up counterproductive...
        sectionElement = UtilXml.firstChildElement(screenElement, "actions");
        if (sectionElement == null) {
            sectionElement = UtilXml.firstChildElement(screenElement, "widgets");
            if (sectionElement == null) {
                throw new IllegalArgumentException("No section (or actions/widgets shorthand) found for the screen definition with name: " + getName());
            }
        }
    } 
    this.section = new ModelScreenWidget.Section(this, sectionElement, true);
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:26,代码来源:ModelScreen.java

示例15: getGridFromLocationOrNull

import org.ofbiz.base.util.UtilXml; //导入依赖的package包/类
/**
 * SCIPIO: Gets widget from location or null if name not within the location.
 */
public static ModelGrid getGridFromLocationOrNull(String resourceName, String gridName, ModelReader entityModelReader, DispatchContext dispatchContext)
        throws IOException, SAXException, ParserConfigurationException {
    StringBuilder sb = new StringBuilder(dispatchContext.getDelegator().getDelegatorName());
    sb.append(":").append(resourceName).append("#").append(gridName);
    String cacheKey = sb.toString();
    ModelGrid modelGrid = gridLocationCache.get(cacheKey);
    if (modelGrid == null) {
        URL gridFileUrl = FlexibleLocation.resolveLocation(resourceName);
        Document gridFileDoc = UtilXml.readXmlDocument(gridFileUrl, true, true);
        if (gridFileDoc == null) {
            throw new IllegalArgumentException("Could not find resource [" + resourceName + "]");
        }
        // SCIPIO: New: Save original location as user data in Document
        if (gridFileDoc != null) {
            WidgetDocumentInfo.retrieveAlways(gridFileDoc).setResourceLocation(resourceName);
        }
        modelGrid = createModelGrid(gridFileDoc, entityModelReader, dispatchContext, resourceName, gridName);
        modelGrid = gridLocationCache.putIfAbsentAndGet(cacheKey, modelGrid);
    }
    return modelGrid;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:25,代码来源:GridFactory.java


注:本文中的org.ofbiz.base.util.UtilXml类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。