|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecttecgraf.javautils.xml.XMLElement
public abstract class XMLElement
Classe-base para todos os elementos XML, cuja visibilidade está restrita ao
pacote; classes da aplicação que modelam elementos XML devem extender
XMLElement ou XMLLeafElement.
| Constructor Summary | |
|---|---|
protected |
XMLElement()
Inicializa a tabela de conversão de XML para texto, usada na conversão de < para <, p.ex. |
protected |
XMLElement(String tagName)
Constrói um elemento recebendo sua tag como parâmetro. |
| Method Summary | |
|---|---|
XMLElementInterface |
appendValue(String text,
boolean newLine)
Adiciona um valor ao elemento (append). |
String |
convertTextToXML(String text)
Deprecated. |
void |
convertValueFromXML()
Converte o valor associado ao elemento para texto (converte sequências de caracteres XML para seus correspondentes ASCII). |
Object |
getAppContextObject()
Retorna o contexto da aplicação associado ao elemento XML. |
Object |
getAppObject()
Retorna o objeto da aplicação associado ao elemento XML. |
boolean |
getAttributeBooleanValue(String name)
Retorna o valor de um atributo como boolean. |
double |
getAttributeDoubleValue(String name)
Retorna o valor de um atributo como double. |
int |
getAttributeIntValue(String name)
Retorna o valor de um atributo como int. |
List<? extends XMLAttribute> |
getAttributes()
Retorna uma cópia read-only da lista de atributos. |
String |
getAttributeStrValue(String name)
Consulta ao valor de um atributo. |
double |
getDoubleValue()
Retorna o valor do elemento como um double. |
float |
getFloatValue()
Retorna o valor do elemento como um float. |
int |
getIntValue()
Retorna o valor do elemento como um int. |
long |
getLongValue()
Retorna o valor do elemento como um long. |
String |
getStrValue()
Retorna o valor do elemento como texto. |
String |
getStrValue(boolean escapeChars)
Retorna o valor associado ao elemento, com a opção de ser feito escape dos caracteres problemáticos (<, >, & etc.). |
String |
getTag()
Retorna a tag associada ao elemento. |
boolean |
hasAttribute(String name)
Consulta da existencia de um atributo. |
boolean |
hasValue()
Consulta da existencia de valor. |
boolean |
isEmpty()
Indica se o elemento não possui valor ( hasValue() == false) ou se
o valor é constituído apenas por espaços ou terminadores de linha. |
XMLElementInterface |
newAttribute(String name,
boolean boolValue)
Define um novo atributo com valor booleano para o elemento. |
XMLElementInterface |
newAttribute(String name,
double doubleValue)
Define um novo atributo com valor double para o elemento. |
XMLElementInterface |
newAttribute(String name,
Enum<?> enumValue)
Instancia um novo atributo que tem como valor uma constante de um Enum. |
XMLElementInterface |
newAttribute(String name,
int intValue)
Define um novo atributo com valor inteiro para o elemento. |
XMLElementInterface |
newAttribute(String name,
long longValue)
Define um novo atributo com valor inteiro (long) para o elemento. |
XMLElementInterface |
newAttribute(String name,
String strValue)
Define um novo atributo para o elemento. |
XMLElementInterface |
newAttributeList(List<XMLAttribute> newAttrs)
Redefine os atributos do elemento a partir de uma lista externa. |
void |
newCharsEvent(char[] charArray,
int start,
int length)
Evento SAX associado à leitura de caracteres associados ao valor do elemento XML. |
void |
resetAttributeList()
Reinicializa a lista de atributos do elemento. |
XMLElementInterface |
resetValue()
Define o valor "vazio" para o elemento (na verdade, remove o valor) |
XMLElementInterface |
setAppContextObject(Object contextObject)
Associa um contexto da aplicação ao elemento XML. |
XMLElementInterface |
setAppObject(Object appObject)
Define o objeto da aplicação associado ao elemento. |
XMLElementInterface |
setTag(String tag)
Define a tag do elemento. |
XMLElementInterface |
setValue(double value)
Define um valor double para o elemento, convertendo-o para texto. |
XMLElementInterface |
setValue(String value)
Define o valor do elemento. |
void |
startTag()
Implementação default (vazia) para a callback de início do processamento de um elemento. |
void |
writeAttributes(Writer stream)
Escreve os atributos do elemento na forma nome="valor", na ordem em que estes foram armazenados. |
static void |
writeAttributes(Writer writer,
List<? extends XMLAttribute> attributes)
Escreve uma lista de atributos no stream corrente, na forma nome="valor". |
void |
writeEndTag(Writer stream)
Escreve a tag de fechamento do elemento, sem identação. |
void |
writeEndTag(Writer stream,
String ident)
Escreve a tag de fechamento do elemento. |
void |
writeStartTag(Writer stream,
String ident)
Escreve a tag de abertura do elemento com seus respectivos atributos, sem anexar fim-de-linha. |
void |
writeStartTagln(Writer stream,
String ident)
Escreve a tag de abertura do elemento com seus respectivos atributos, anexando um fim-de-linha ao final da mesma. |
void |
writeValue(Writer stream)
Escreve o valor do elemento. |
static String |
xmlEncode(String text)
Deprecated. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface tecgraf.javautils.xml.XMLElementInterface |
|---|
endTag, write |
| Constructor Detail |
|---|
protected XMLElement()
protected XMLElement(String tagName)
tagName - tag| Method Detail |
|---|
public void newCharsEvent(char[] charArray,
int start,
int length)
newCharsEvent in interface XMLElementInterfacecharArray - array de caracteres contendo os chars lidosstart - início dos dados no arraylength - quantidade de caracteres lidosXMLElementInterface.newCharsEvent(char[],int,int),
XMLBasicHandler.characters(char[], int, int)public final void convertValueFromXML()
convertValueFromXML in interface XMLElementInterfaceXMLElementInterface.convertValueFromXML(),
XMLBasicHandler.endElement(String, String, String),
getStrValue(),
hasValue(),
isEmpty()@Deprecated public String convertTextToXML(String text)
convertTextToXML in interface XMLElementInterfacetext - texto.
XMLElementInterface.convertTextToXML(java.lang.String)@Deprecated public static String xmlEncode(String text)
text - - texto a ser convertido
public final XMLElementInterface appendValue(String text,
boolean newLine)
appendValue in interface XMLElementInterfacetext - valor textual a ser acrescido. Se for null não é
consideradonewLine - flag indicativo de quebra de linha após a acréscimo.
XMLElementInterface.appendValue(java.lang.String,boolean)public final XMLElementInterface resetValue()
resetValue in interface XMLElementInterfaceXMLElementInterface.resetValue()public final XMLElementInterface setValue(String value)
setValue in interface XMLElementInterfacevalue - o valor a ser usado.
XMLElementInterface.setValue(java.lang.String)public final XMLElementInterface setValue(double value)
setValue in interface XMLElementInterfacevalue - o valor double a ser ajustado.
XMLElementInterface.setValue(double)public final XMLElementInterface setTag(String tag)
setTag in interface XMLElementInterfacetag - tag associada ao elemento
XMLElementInterface.setTag(java.lang.String)public final String getTag()
getTag in interface XMLElementInterfaceXMLElementInterface.getTag()public String getStrValue(boolean escapeChars)
escapeChars - se igual a true, os caracteres problemáticos serão
tratados
IllegalStateException - se o elemento ainda está sendo processadopublic String getStrValue()
getStrValue in interface XMLElementInterfaceIllegalStateException - se o elemento ainda está sendo processadoXMLElementInterface.getStrValue()public final float getFloatValue()
float. Caso a conversão
para texto não seja possível, lança XMLParseException.
getFloatValue in interface XMLElementInterfacefloat.
IllegalStateException - se o elemento ainda está sendo processadoXMLElementInterface.getFloatValue()public final double getDoubleValue()
double. Caso a conversão
para texto não seja possível, lança XMLParseException.
getDoubleValue in interface XMLElementInterfacedouble.
IllegalStateException - se o elemento ainda está sendo processadoXMLElementInterface.getDoubleValue()public final int getIntValue()
int. Caso a conversão para
texto não seja possível, lança XMLParseException.
getIntValue in interface XMLElementInterfaceint.
IllegalStateException - se o elemento ainda está sendo processadoXMLElementInterface.getIntValue()public final long getLongValue()
long. Caso a conversão
para texto não seja possível, lança XMLParseException.
getLongValue in interface XMLElementInterfacelong.
IllegalStateException - se o elemento ainda está sendo processadoXMLElementInterface.getLongValue()
public final XMLElementInterface newAttribute(String name,
String strValue)
newAttribute in interface XMLElementInterfacename - o nome do atributo.strValue - o valor do atributo (string).
XMLElementInterface.newAttribute(java.lang.String,java.lang.String)
public XMLElementInterface newAttribute(String name,
Enum<?> enumValue)
Enum. O método Enum.toString() é usado para obter o valor a
ser associado ao atributo.
newAttribute in interface XMLElementInterfacename - - nome do atributoenumValue - - valor de enumeração
public final XMLElementInterface newAttribute(String name,
int intValue)
newAttribute in interface XMLElementInterfacename - o nome do atributo.intValue - o valor do atributo (inteiro).
XMLElementInterface.newAttribute(java.lang.String,int)
public final XMLElementInterface newAttribute(String name,
long longValue)
newAttribute in interface XMLElementInterfacename - o nome do atributo.longValue - o valor do atributo (inteiro long).
XMLElementInterface.newAttribute(java.lang.String,int)
public XMLElementInterface newAttribute(String name,
boolean boolValue)
true será gravado como "TRUE", e false como
"FALSE".
newAttribute in interface XMLElementInterfacename - o nome do atributo.boolValue - o valor do atributo (booleano).
XMLElementInterface.newAttribute(java.lang.String,boolean)
public final XMLElementInterface newAttribute(String name,
double doubleValue)
double para o elemento.
newAttribute in interface XMLElementInterfacename - o nome do atributo.doubleValue - o valor do atributo (double).
XMLElementInterface.newAttribute(java.lang.String,double)public final XMLElementInterface newAttributeList(List<XMLAttribute> newAttrs)
XMLAttribute.
newAttributeList in interface XMLElementInterfacenewAttrs - lista de novos atributos.
XMLElementInterface.newAttributeList(java.util.List)public final void resetAttributeList()
resetAttributeList in interface XMLElementInterfaceXMLElementInterface.resetAttributeList()public final boolean hasAttribute(String name)
hasAttribute in interface XMLElementInterfacename - nome do atributo.
XMLElementInterface.hasAttribute(java.lang.String)public final boolean hasValue()
hasValue in interface XMLElementInterfaceIllegalStateException - se o elemento ainda está sendo processadoXMLElementInterface.hasValue(),
isEmpty()public final boolean isEmpty()
hasValue() == false) ou se
o valor é constituído apenas por espaços ou terminadores de linha.
isEmpty in interface XMLElementInterfaceIllegalStateException - se o elemento ainda está sendo processadohasValue()public String getAttributeStrValue(String name)
getAttributeStrValue in interface XMLElementInterfacename - nome do atributo.
StringXMLElementInterface.getAttributeStrValue(java.lang.String)public boolean getAttributeBooleanValue(String name)
boolean.
getAttributeBooleanValue in interface XMLElementInterfacename - nome do atributo.
XMLElementInterface.getAttributeBooleanValue(java.lang.String)public final int getAttributeIntValue(String name)
int.
getAttributeIntValue in interface XMLElementInterfacename - nome do atributo.
XMLParseExceptionXMLElementInterface.getAttributeIntValue(java.lang.String)public double getAttributeDoubleValue(String name)
double.
getAttributeDoubleValue in interface XMLElementInterfacename - nome do atributo.
double associado ao valor. Se a conversão não for
possível, lança XMLParseExceptionXMLElementInterface.getAttributeIntValue(java.lang.String)public List<? extends XMLAttribute> getAttributes()
getAttributes in interface XMLElementInterfaceXMLElementInterface.getAttributes()
public void writeStartTag(Writer stream,
String ident)
throws IOException
writeStartTag in interface XMLElementInterfacestream - stream de saídaident - identação
IOException - se houver algum erro de escrita
public void writeStartTagln(Writer stream,
String ident)
throws IOException
writeStartTagln in interface XMLElementInterfacestream - stream de saídaident - identação
IOException - se houver algum erro de escrita
public void writeAttributes(Writer stream)
throws IOException
writeAttributes in interface XMLElementInterfacestream - de saída
IOException - se houver algum erro de escrita
public static void writeAttributes(Writer writer,
List<? extends XMLAttribute> attributes)
throws IOException
writer - stream de saídaattributes - lista de XMLAttribute
IOException - se houver algum erro de escrita
public void writeValue(Writer stream)
throws IOException
writeValue in interface XMLElementInterfacestream - stream de saída
IOException - se houver algum erro de escrita
public void writeEndTag(Writer stream,
String ident)
throws IOException
writeEndTag in interface XMLElementInterfacestream - stream de saídaident - identação
IOException - se houver algum erro de escrita
public final void writeEndTag(Writer stream)
throws IOException
writeEndTag in interface XMLElementInterfacestream - stream de saída
IOException - se houver algum erro de escritapublic void startTag()
startTag in interface XMLElementInterfaceXMLElementInterface.startTag()public final XMLElementInterface setAppObject(Object appObject)
setAppObject in interface XMLElementInterfaceappObject - objeto da aplicação associado ao elemento XML
public final Object getAppObject()
getAppObject in interface XMLElementInterfacepublic final XMLElementInterface setAppContextObject(Object contextObject)
setAppContextObject in interface XMLElementInterfacecontextObject - objeto representativo de contexto da aplicacao.
public final Object getAppContextObject()
getAppContextObject in interface XMLElementInterface
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||