org.apache.cayenne.util.Util.encodeXmlAttribute()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(10.3k)|赞(0)|评价(0)|浏览(201)

本文整理了Java中org.apache.cayenne.util.Util.encodeXmlAttribute()方法的一些代码示例,展示了Util.encodeXmlAttribute()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.encodeXmlAttribute()方法的具体详情如下:
包路径:org.apache.cayenne.util.Util
类名称:Util
方法名:encodeXmlAttribute

Util.encodeXmlAttribute介绍

[英]Encodes a string so that it can be used as an attribute value in an XML document. Will do conversion of the greater/less signs, quotes and ampersands.
[中]对字符串进行编码,以便将其用作XML文档中的属性值。将进行大小号、引号和符号的转换。

代码示例

代码示例来源:origin: org.apache.cayenne/cayenne-server

private void printAttribute(String name, String value, boolean lineBreak) {
  if (value == null) {
    return;
  }
  value = value.trim();
  if (value.length() == 0) {
    return;
  }
  value = Util.encodeXmlAttribute(value);
  printIndent();
  out.print(' ');
  out.print(name);
  out.print("=\"");
  out.print(value);
  out.print("\"");
  if (lineBreak) {
    println();
  }
}

代码示例来源:origin: org.apache.cayenne/cayenne-nodeps

pw.print("\t<property name=\"" + Util.encodeXmlAttribute(name.trim()));
pw.println("\" value=\"" + Util.encodeXmlAttribute(value.trim()) + "\"/>");

代码示例来源:origin: org.apache.cayenne/cayenne-nodeps

String encoded = Util.encodeXmlAttribute(info.getDataSourceUrl());
out.println("\t<url value=\"" + encoded + "\"/>");
out.print("\t<login");
if (info.getUserName() != null) {
  String encoded = Util.encodeXmlAttribute(info.getUserName());
  out.print(" userName=\"" + encoded + "\"");
  String encoded = Util.encodeXmlAttribute(info.getPassword());
  out.print(" password=\"" + encoded + "\"");

代码示例来源:origin: org.apache.cayenne/cayenne-nodeps

/**
 * Prints itself as XML to the provided XMLEncoder.
 * 
 * @since 1.1
 */
public void encodeAsXML(XMLEncoder encoder) {
  encoder.print("<db-entity name=\"" + Util.encodeXmlAttribute(getName()));
  if (getSchema() != null && getSchema().trim().length() > 0) {
    encoder.print("\" schema=\"");
    encoder.print(Util.encodeXmlAttribute(getSchema().trim()));
  }
  if (getCatalog() != null && getCatalog().trim().length() > 0) {
    encoder.print("\" catalog=\"");
    encoder.print(Util.encodeXmlAttribute(getCatalog().trim()));
  }
  encoder.print("\" parentName=\"");
  encoder.print(Util.encodeXmlAttribute(getParentEntityName()));
  encoder.println("\">");
  encoder.indent(1);
  encoder.print(getAttributeMap());
  encoder.indent(-1);
  encoder.println("</db-entity>");
}

代码示例来源:origin: org.apache.cayenne/cayenne-nodeps

/**
 * Prints itself as XML to the provided XMLEncoder.
 * 
 * @since 1.1
 */
public void encodeAsXML(XMLEncoder encoder) {
  encoder.print("<db-entity name=\"");
  encoder.print(Util.encodeXmlAttribute(getName()));
  encoder.print('\"');
  if (getSchema() != null && getSchema().trim().length() > 0) {
    encoder.print(" schema=\"");
    encoder.print(Util.encodeXmlAttribute(getSchema().trim()));
    encoder.print('\"');
  }
  if (getCatalog() != null && getCatalog().trim().length() > 0) {
    encoder.print(" catalog=\"");
    encoder.print(Util.encodeXmlAttribute(getCatalog().trim()));
    encoder.print('\"');
  }
  encoder.println('>');
  encoder.indent(1);
  encoder.print(getAttributeMap());
  if (getPrimaryKeyGenerator() != null) {
    getPrimaryKeyGenerator().encodeAsXML(encoder);
  }
  encoder.indent(-1);
  encoder.println("</db-entity>");
}

代码示例来源:origin: org.apache.cayenne/cayenne-server

public void encodeAsXML(XMLEncoder encoder) {
  encoder.print("<db-entity name=\"");
  encoder.print(Util.encodeXmlAttribute(getName()));
  encoder.print('\"');
    encoder.print(Util.encodeXmlAttribute(getSchema().trim()));
    encoder.print('\"');
    encoder.print(Util.encodeXmlAttribute(getCatalog().trim()));
    encoder.print('\"');

代码示例来源:origin: org.apache.cayenne/cayenne-nodeps

/**
 * Prints itself as XML to the provided XMLEncoder.
 * 
 * @since 1.1
 */
public void encodeAsXML(XMLEncoder encoder) {
  encoder.print("<procedure name=\"");
  encoder.print(Util.encodeXmlAttribute(getName()));
  encoder.print('\"');
  if (getSchema() != null && getSchema().trim().length() > 0) {
    encoder.print(" schema=\"");
    encoder.print(getSchema().trim());
    encoder.print('\"');
  }
  if (getCatalog() != null && getCatalog().trim().length() > 0) {
    encoder.print(" catalog=\"");
    encoder.print(getCatalog().trim());
    encoder.print('\"');
  }
  if (isReturningValue()) {
    encoder.print(" returningValue=\"true\"");
  }
  encoder.println('>');
  encoder.indent(1);
  encoder.print(getCallParameters());
  encoder.indent(-1);
  encoder.println("</procedure>");
}

代码示例来源:origin: org.apache.cayenne/cayenne-server

/**
 * Prints itself as XML to the provided XMLEncoder.
 * 
 * @since 1.1
 */
public void encodeAsXML(XMLEncoder encoder) {
  encoder.print("<procedure name=\"");
  encoder.print(Util.encodeXmlAttribute(getName()));
  encoder.print('\"');
  if (getSchema() != null && getSchema().trim().length() > 0) {
    encoder.print(" schema=\"");
    encoder.print(getSchema().trim());
    encoder.print('\"');
  }
  if (getCatalog() != null && getCatalog().trim().length() > 0) {
    encoder.print(" catalog=\"");
    encoder.print(getCatalog().trim());
    encoder.print('\"');
  }
  if (isReturningValue()) {
    encoder.print(" returningValue=\"true\"");
  }
  encoder.println('>');
  encoder.indent(1);
  encoder.print(getCallParameters());
  encoder.indent(-1);
  encoder.println("</procedure>");
}

代码示例来源:origin: org.apache.cayenne/cayenne-server

/**
 * Prints itself as XML to the provided XMLEncoder.
 * 
 * @since 1.1
 */
public void encodeAsXML(XMLEncoder encoder) {
  encoder.print("<db-relationship name=\"");
  encoder.print(Util.encodeXmlAttribute(getName()));
  encoder.print("\" source=\"");
  encoder.print(Util.encodeXmlAttribute(getSourceEntity().getName()));
  if (getTargetEntityName() != null && getTargetEntity() != null) {
    encoder.print("\" target=\"");
    encoder.print(Util.encodeXmlAttribute(getTargetEntityName()));
  }
  if (isToDependentPK() && isValidForDepPk()) {
    encoder.print("\" toDependentPK=\"true");
  }
  encoder.print("\" toMany=\"");
  encoder.print(isToMany());
  encoder.println("\">");
  encoder.indent(1);
  encoder.print(getJoins());
  encoder.indent(-1);
  encoder.println("</db-relationship>");
}

代码示例来源:origin: org.apache.cayenne/cayenne-server

/**
 * Prints itself as XML to the provided XMLEncoder.
 * 
 * @since 1.1
 */
@Override
public void encodeAsXML(XMLEncoder encoder) {
  encoder.print("<obj-attribute name=\"" + getName() + '\"');
  if (getType() != null) {
    encoder.print(" type=\"");
    encoder.print(Util.encodeXmlAttribute(getType()));
    encoder.print('\"');
  }
  if (isUsedForLocking()) {
    encoder.print(" lock=\"true\"");
  }
  // If this obj attribute is mapped to db attribute
  if (/*getDbAttribute() != null
      || (((ObjEntity) getEntity()).isAbstract() && */!Util.isEmptyString(getDbAttributePath())) {
    encoder.print(" db-attribute-path=\"");
    encoder.print(Util.encodeXmlAttribute(getDbAttributePath()));
    encoder.print('\"');
  }
  encoder.println("/>");
}

代码示例来源:origin: org.apache.cayenne/cayenne-server

public void encodeAsXML(XMLEncoder encoder) {
  encoder.print("<embeddable-attribute name=\"" + getName() + '\"');
  if (getType() != null) {
    encoder.print(" type=\"");
    encoder.print(getType());
    encoder.print('\"');
  }
  // If this obj attribute is mapped to db attribute
  if (dbAttributeName != null) {
    encoder.print(" db-attribute-name=\"");
    encoder.print(Util.encodeXmlAttribute(dbAttributeName));
    encoder.print('\"');
  }
  encoder.println("/>");
}

代码示例来源:origin: org.apache.cayenne/cayenne-nodeps

+ Util.encodeXmlAttribute(getName())
+ '\"');
DbAttribute ref = (DbAttribute) refs.next();
encoder.println("<db-attribute-ref name=\""
    + Util.encodeXmlAttribute(ref.getName())
    + "\"/>");

代码示例来源:origin: org.apache.cayenne/cayenne-nodeps

/**
 * Prints itself as XML to the provided XMLEncoder.
 * 
 * @since 1.1
 */
public void encodeAsXML(XMLEncoder encoder) {
  encoder.print("<obj-attribute name=\"" + getName() + '\"');
  if (getType() != null) {
    encoder.print(" type=\"");
    encoder.print(getType());
    encoder.print('\"');
  }
  if (isUsedForLocking()) {
    encoder.print(" lock=\"true\"");
  }
  // If this obj attribute is mapped to db attribute
  if (getDbAttribute() != null) {
    encoder.print(" db-attribute-path=\"");
    encoder.print(Util.encodeXmlAttribute(getDbAttributePath()));
    encoder.print('\"');
  }
  encoder.println("/>");
}

代码示例来源:origin: org.apache.cayenne/cayenne-nodeps

+ Util.encodeXmlAttribute(getName())
+ '\"');

代码示例来源:origin: org.apache.cayenne/cayenne-server

+ Util.encodeXmlAttribute(getName())
+ '\"');

代码示例来源:origin: org.apache.cayenne/cayenne-nodeps

/**
 * Prints itself as XML to the provided XMLEncoder.
 * 
 * @since 1.1
 */
public void encodeAsXML(XMLEncoder encoder) {
  encoder.print("<db-relationship name=\"");
  encoder.print(Util.encodeXmlAttribute(getName()));
  encoder.print("\" source=\"");
  encoder.print(getSourceEntity().getName());
  if (getTargetEntityName() != null && getTargetEntity() != null) {
    encoder.print("\" target=\"");
    encoder.print(getTargetEntityName());
  }
  if (isToDependentPK() && isValidForDepPk()) {
    encoder.print("\" toDependentPK=\"true");
  }
  encoder.print("\" toMany=\"");
  encoder.print(isToMany());
  encoder.println("\">");
  encoder.indent(1);
  encoder.print(getJoins());
  encoder.indent(-1);
  encoder.println("</db-relationship>");
}

代码示例来源:origin: org.apache.cayenne/cayenne-server

encoder.print(Util.encodeXmlAttribute(getDbEntityName()));
encoder.print("<attribute-override name=\"" + override.getKey() + '\"');
encoder.print(" db-attribute-path=\"");
encoder.print(Util.encodeXmlAttribute(override.getValue()));
encoder.print('\"');
encoder.println("/>");

代码示例来源:origin: org.apache.cayenne/cayenne-nodeps

encoder.print(Util.encodeXmlAttribute(getName()));
encoder.print('\"');

代码示例来源:origin: org.apache.cayenne/cayenne-server

encoder.print(Util.encodeXmlAttribute(getName()));
encoder.print('\"');

代码示例来源:origin: org.apache.cayenne/cayenne-nodeps

encoder.print(Util.encodeXmlAttribute(getDbEntityName()));

相关文章