本文整理汇总了Java中org.ofbiz.base.util.UtilXml.childElementValue方法的典型用法代码示例。如果您正苦于以下问题:Java UtilXml.childElementValue方法的具体用法?Java UtilXml.childElementValue怎么用?Java UtilXml.childElementValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ofbiz.base.util.UtilXml
的用法示例。
在下文中一共展示了UtilXml.childElementValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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><relation></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);
}
示例3: 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));
}
}
}
}
示例4: handleErrors
import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
public static void handleErrors(Element responseElement, List<Object> errorList, Locale locale) {
Element faultsElement = UtilXml.firstChildElement(responseElement,
"Faults");
List<? extends Element> faultElements = UtilXml.childElementList(faultsElement, "Fault");
if (UtilValidate.isNotEmpty(faultElements)) {
for (Element errorElement: faultElements) {
StringBuilder errorMessageBuf = new StringBuilder();
String errorCode = UtilXml.childElementValue(errorElement, "Code");
String errorDescription = UtilXml.childElementValue(errorElement, "Desc");
String errorSource = UtilXml.childElementValue(errorElement, "Source");
if (UtilValidate.isEmpty(errorSource)) {
errorSource = UtilXml.childElementValue(errorElement, "Context");
}
errorMessageBuf.append(UtilProperties.getMessage(resourceError, "FacilityShipmentDhlErrorMessage",
UtilMisc.toMap("errorCode", errorCode, "errorDescription", errorDescription), locale));
if (UtilValidate.isNotEmpty(errorSource)) {
errorMessageBuf.append(UtilProperties.getMessage(resourceError,
"FacilityShipmentDhlErrorMessageElement",
UtilMisc.toMap("errorSource", errorSource), locale));
}
errorList.add(errorMessageBuf.toString());
}
}
}
示例5: integerSetting
import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
static Integer integerSetting(Element parentElement, String settingName, Integer defaultValue, boolean allowNegative) {
Integer value = null;
String strValue = UtilXml.childElementValue(parentElement, settingName, defaultValue != null ? defaultValue.toString() : null);
if (UtilValidate.isNotEmpty(strValue)) {
try {
value = Integer.parseInt(strValue);
if (!allowNegative && value < 0) {
value = (defaultValue != null) ? defaultValue : null;
}
} catch(Exception e) {
Debug.logError(e, "Couldn't parse " + settingName + ": " + e.getMessage(), module);
}
}
Debug.logInfo(" " + settingName + ": " + value, module);
return value;
}
示例6: create
import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
/**
* Returns a new <code>ModelIndex</code> instance, initialized with the specified values.
*
* @param modelEntity The <code>ModelEntity</code> this index is a member of.
* @param indexElement The <code><index></code> element containing the values for this index.
*/
public static ModelIndex create(ModelEntity modelEntity, Element indexElement) {
String name = indexElement.getAttribute("name").intern();
boolean unique = "true".equals(indexElement.getAttribute("unique"));
String description = UtilXml.childElementValue(indexElement, "description");
List<Field>fields = Collections.emptyList();
List<? extends Element> elementList = UtilXml.childElementList(indexElement, "index-field");
if (!elementList.isEmpty()) {
fields = new ArrayList<Field>(elementList.size());
for (Element indexFieldElement : elementList) {
String fieldName = indexFieldElement.getAttribute("name").intern();
String function = indexFieldElement.getAttribute("function").intern();
fields.add(new Field(fieldName, UtilValidate.isNotEmpty(function) ? Function.valueOf(function.toUpperCase()) : null));
}
fields = Collections.unmodifiableList(fields);
}
return new ModelIndex(modelEntity, description, name, fields, unique);
}
示例7: handleUpsAddressValidationResponse
import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
public static Map<String, Object> handleUpsAddressValidationResponse(Document rateResponseDocument, Locale locale) {
Element avResponseElement = rateResponseDocument.getDocumentElement();
Element responseElement = UtilXml.firstChildElement(avResponseElement, "Response");
String responseStatusCode = UtilXml.childElementValue(responseElement, "ResponseStatusCode");
List<Object> errorList = FastList.newInstance();
UpsServices.handleErrors(responseElement, errorList, locale);
if ("1".equals(responseStatusCode)) {
List<Map<String, String>> matches = FastList.newInstance();
List<? extends Element> avResultList = UtilXml.childElementList(avResponseElement, "AddressValidationResult");
// TODO: return error if there are no matches?
if (UtilValidate.isNotEmpty(avResultList)) {
for (Element avResultElement: avResultList) {
Map<String, String> match = FastMap.newInstance();
match.put("Rank", UtilXml.childElementValue(avResultElement, "Rank"));
match.put("Quality", UtilXml.childElementValue(avResultElement, "Quality"));
Element addressElement = UtilXml.firstChildElement(avResultElement, "Address");
match.put("City", UtilXml.childElementValue(addressElement, "City"));
match.put("StateProvinceCode", UtilXml.childElementValue(addressElement, "StateProvinceCode"));
match.put("PostalCodeLowEnd", UtilXml.childElementValue(avResultElement, "PostalCodeLowEnd"));
match.put("PostalCodeHighEnd", UtilXml.childElementValue(avResultElement, "PostalCodeHighEnd"));
matches.add(match);
}
}
Map<String, Object> result = ServiceUtil.returnSuccess();
result.put("matches", matches);
return result;
} else {
errorList.add(ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "FacilityShipmentUpsErrorStatusCode",
UtilMisc.toMap("responseStatusCode", responseStatusCode), locale)));
return ServiceUtil.returnError(errorList);
}
}
示例8: get
import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
public String get(String name) {
if (!checkOut(name)) {
throw new IllegalArgumentException("Field [" + name + "] is not a valid OUT parameter");
}
return UtilXml.childElementValue(req, name);
}
示例9: Property
import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
public Property(Element element) {
this.name = element.getAttribute("name");
this.value = element.getAttribute("value");
if (UtilValidate.isEmpty(this.value)) {
this.value = UtilXml.childElementValue(element, "property-value");
}
properties = new LinkedHashMap<String, Property>();
for (Element curElement: UtilXml.childElementList(element, "property")) {
Property property = new Property(curElement);
properties.put(property.name, property);
}
}
示例10: stringSetting
import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
static String stringSetting(Element parentElement, String settingName, String defaultValue, Set<String> specialNullValues) {
String value = UtilXml.childElementValue(parentElement, settingName, defaultValue);
if (value == null || value.isEmpty()) value = defaultValue;
Debug.logInfo(" " + settingName + ": " + value, module);
if (specialNullValues.contains(value)) return null;
return value;
}
示例11: booleanSetting
import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
static Boolean booleanSetting(Element parentElement, String settingName, Boolean defaultValue) {
String strValue = UtilXml.childElementValue(parentElement, settingName, (defaultValue != null) ? defaultValue.toString() : null);
Boolean value = booleanSetting(strValue);
if (value == null && strValue != null && strValue.length() > 0) {
Debug.logError("Invalid value for '" + settingName + "' setting: " + strValue + " (should be 'true'/'false' or 'enable'/'disable')", module);
}
if (value == null) value = defaultValue;
Debug.logInfo(" " + settingName + ": " + value, module);
return value;
}
示例12: localeSetting
import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
static Locale localeSetting(Element parentElement, String settingName, String defaultValue) {
Locale value = null;
String strValue = UtilXml.childElementValue(parentElement, settingName, defaultValue);
if (UtilValidate.isNotEmpty(strValue)) {
value = UtilMisc.parseLocale(strValue);
}
if (value == null && defaultValue != null) value = UtilMisc.parseLocale(defaultValue);
Debug.logInfo(" " + settingName + ": " + value, module);
return value;
}
示例13: RequestMap
import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
public RequestMap(Element requestMapElement) {
// Get the URI info
this.uri = requestMapElement.getAttribute("uri");
this.edit = !"false".equals(requestMapElement.getAttribute("edit"));
this.trackServerHit = !"false".equals(requestMapElement.getAttribute("track-serverhit"));
this.trackVisit = !"false".equals(requestMapElement.getAttribute("track-visit"));
// Check for security
Element securityElement = UtilXml.firstChildElement(requestMapElement, "security");
if (securityElement != null) {
this.securityHttps = "true".equals(securityElement.getAttribute("https"));
this.securityAuth = "true".equals(securityElement.getAttribute("auth"));
this.securityCert = "true".equals(securityElement.getAttribute("cert"));
this.securityExternalView = !"false".equals(securityElement.getAttribute("external-view"));
this.securityDirectRequest = !"false".equals(securityElement.getAttribute("direct-request"));
}
// Check for event
Element eventElement = UtilXml.firstChildElement(requestMapElement, "event");
if (eventElement != null) {
this.event = new Event(eventElement);
}
// Check for description
this.description = UtilXml.childElementValue(requestMapElement, "description");
// Get the response(s)
for (Element responseElement : UtilXml.childElementList(requestMapElement, "response")) {
RequestResponse response = new RequestResponse(responseElement);
requestResponseMap.put(response.name, response);
}
// Get metrics.
Element metricsElement = UtilXml.firstChildElement(requestMapElement, "metric");
if (metricsElement != null) {
this.metrics = MetricsFactory.getInstance(metricsElement);
}
}
示例14: processCreditResponse
import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
private static Map<String, Object> processCreditResponse(Document responseDocument) {
Element engineDocElement = UtilXml.firstChildElement(responseDocument.getDocumentElement(), "EngineDoc");
Element orderFormElement = UtilXml.firstChildElement(engineDocElement, "OrderFormDoc");
Element transactionElement = UtilXml.firstChildElement(orderFormElement, "Transaction");
Element procResponseElement = UtilXml.firstChildElement(transactionElement, "CardProcResp");
Map<String, Object> result = ServiceUtil.returnSuccess();
String errorCode = UtilXml.childElementValue(procResponseElement, "CcErrCode");
if ("1".equals(errorCode)) {
result.put("creditResult", Boolean.valueOf(true));
result.put("creditCode", UtilXml.childElementValue(transactionElement, "AuthCode"));
Element currentTotalsElement = UtilXml.firstChildElement(transactionElement, "CurrentTotals");
Element totalsElement = UtilXml.firstChildElement(currentTotalsElement, "Totals");
String creditAmountStr = UtilXml.childElementValue(totalsElement, "Total");
result.put("creditAmount", new BigDecimal(creditAmountStr).movePointLeft(2));
} else {
result.put("creditResult", Boolean.valueOf(false));
result.put("creditAmount", BigDecimal.ZERO);
}
result.put("creditRefNum", UtilXml.childElementValue(orderFormElement, "Id"));
result.put("creditFlag", UtilXml.childElementValue(procResponseElement, "Status"));
result.put("creditMessage", UtilXml.childElementValue(procResponseElement, "CcReturnMsg"));
List<String> messages = getMessageList(responseDocument);
if (UtilValidate.isNotEmpty(messages)) {
result.put("internalRespMsgs", messages);
}
return result;
}
示例15: processReleaseResponse
import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
private static Map<String, Object> processReleaseResponse(Document responseDocument) {
Element engineDocElement = UtilXml.firstChildElement(responseDocument.getDocumentElement(), "EngineDoc");
Element orderFormElement = UtilXml.firstChildElement(engineDocElement, "OrderFormDoc");
Element transactionElement = UtilXml.firstChildElement(orderFormElement, "Transaction");
Element procResponseElement = UtilXml.firstChildElement(transactionElement, "CardProcResp");
Map<String, Object> result = ServiceUtil.returnSuccess();
String errorCode = UtilXml.childElementValue(procResponseElement, "CcErrCode");
if ("1".equals(errorCode)) {
result.put("releaseResult", Boolean.valueOf(true));
result.put("releaseCode", UtilXml.childElementValue(transactionElement, "AuthCode"));
Element currentTotalsElement = UtilXml.firstChildElement(transactionElement, "CurrentTotals");
Element totalsElement = UtilXml.firstChildElement(currentTotalsElement, "Totals");
String releaseAmountStr = UtilXml.childElementValue(totalsElement, "Total");
result.put("releaseAmount", new BigDecimal(releaseAmountStr).movePointLeft(2));
} else {
result.put("releaseResult", Boolean.valueOf(false));
result.put("releaseAmount", BigDecimal.ZERO);
}
result.put("releaseRefNum", UtilXml.childElementValue(orderFormElement, "Id"));
result.put("releaseFlag", UtilXml.childElementValue(procResponseElement, "Status"));
result.put("releaseMessage", UtilXml.childElementValue(procResponseElement, "CcReturnMsg"));
List<String> messages = getMessageList(responseDocument);
if (UtilValidate.isNotEmpty(messages)) {
result.put("internalRespMsgs", messages);
}
return result;
}