NpsSDK.SimpleElement Maven / Gradle / Ivy
package NpsSDK;
import java.util.ArrayList;
import java.util.List;
public class SimpleElement extends BaseElement
{
private String value;
private String escapeSpecialCharacters(String value){
value = value.replace("&", "&");
value = value.replace("<", "<");
value = value.replace(">", ">");
return value;
}
@Override
public String serialize() {
return String.format("<%1$s>%2$s%1$s>", this.getName(), this.escapeSpecialCharacters(value));
}
void trim(int maxLength){
if (value.length() > maxLength){
value = value.substring(0, maxLength);
}
}
private static List emptyChildren = new ArrayList();
@Override
List getChildren() {
return emptyChildren;
}
@Override
String getConcatenatedValues() {
return this.value;
}
public SimpleElement(String name, String value) {
this.setName(name);
this.value = value;
}
}