public class XMLBasicHandler extends Object implements XMLHandlerInterface
| Constructor and Description |
|---|
XMLBasicHandler(Class<? extends XMLElementInterface> cls)
Cria um handler que mapeia todas as tags para um único tipo de objeto XML.
|
XMLBasicHandler(Map<String,Class<? extends XMLElementInterface>> tagToObjMap)
Cria um handler que usa um mapa para criar objetos XML a partir das tags.
|
XMLBasicHandler(XMLElementFactoryInterface xmlFactory)
Cria um handler que usa uma
fábrica para
criar objetos XML a partir das tags. |
| Modifier and Type | Method and Description |
|---|---|
void |
characters(char[] ch,
int start,
int length)
Evento de leitura de caracteres (CDATA).
|
void |
endDocument()
Callback executada ao final do processamento do documento.
|
void |
endDocument(XMLElementInterface rootElement)
Callback executada quando o elemento foi inteiramente lido.
|
void |
endElement(String uri,
String localName,
String qName)
Evento de tag de fechamento de um elemento.
|
void |
error(XMLException e)
Evento associado a um erro.
|
void |
fatalError(XMLException e)
Evento associado a um erro fatal.
|
String |
getDTD()
Retorna o DTD associado ao documento.
|
InputSource |
getInputSource()
Retorna o
InputSource associado a este handler. |
XMLElementInterface |
getRootElement()
Retorna o elemento-raiz do documento
|
org.xml.sax.helpers.DefaultHandler |
getSAXInternalHandler()
Retorna o handler interno (SAX) usado por este handler.
|
XMLElementFactoryInterface |
getXMLFactory()
Retorna a fábrica de elementos XML associada ao handler.
|
InputSource |
resolveEntity(String publicId,
String systemId)
Evento chamado quando uma external entity (p.ex.
|
void |
setDTD(String dtd)
Define o DTD associado ao documento.
|
void |
setInputSource(Reader reader)
Define o inputSource do handler a partir de um
Reader. |
void |
startElement(String uri,
String localName,
String qName,
List<XMLAttribute> attributes)
Evento de nova tag.
|
void |
warning(XMLException e)
Evento associado a um warning.
|
public XMLBasicHandler(XMLElementFactoryInterface xmlFactory)
fábrica para
criar objetos XML a partir das tags.xmlFactory - fabricapublic XMLBasicHandler(Map<String,Class<? extends XMLElementInterface>> tagToObjMap)
tagToObjMap - mapa relacionando tags a objetos XMLpublic XMLBasicHandler(Class<? extends XMLElementInterface> cls)
cls - classe do objeto XML que será mapeado a todas as tagspublic final XMLElementInterface getRootElement()
getRootElement in interface XMLHandlerInterfacepublic final org.xml.sax.helpers.DefaultHandler getSAXInternalHandler()
getSAXInternalHandler in interface XMLHandlerInterfacepublic final void characters(char[] ch,
int start,
int length)
throws XMLException
openedElements).characters in interface XMLHandlerInterfacech - - buffer onde foram lidos os caracteresstart - - posição no buffer do primeiro caracter lidolength - - quantidade de caracteres lidosXMLExceptionDefaultHandler.characters(char[], int, int)public final void startElement(String uri, String localName, String qName, List<XMLAttribute> attributes) throws XMLException
startElement in interface XMLHandlerInterfaceuri - - o identificador do namespace do elemento, ou a string vazia se
o elemento não possui namespace específico ou se o processamento de
namespaces não está habilitadolocalName - - o nome local (sem prefixo), ou a string vazia se o
processamento de namespaces não está habilitadoqName - - o nome qualificado da tagattributes - - lista de atributos associados à tagXMLExceptionDefaultHandler.startElement(String, String, String, Attributes)public final void endElement(String uri, String localName, String qName) throws XMLException
Esta callback executa o método endTag do elemento, passando
como parâmetro uma lista com os filhos deste (a lista estará vazia caso o
elemento não tenha filhos).
endElement in interface XMLHandlerInterfaceuri - - URL associada ao namespace do elemento. Caso o elemento não
tenha namespace ou o uso de namespaces esteja desabilitado, é uma
string vazialocalName - - o nome local ou uma string vazia caso o uso de
namespaces esteja desabilitadoqName - - o nome do elemento (tag)XMLExceptionpublic final void setInputSource(Reader reader)
Reader.setInputSource in interface XMLHandlerInterfacereader - Reader a ser usado para leitura do XMLpublic final InputSource getInputSource()
InputSource associado a este handler.getInputSource in interface XMLHandlerInterfaceInputSource associado ao handlerpublic InputSource resolveEntity(String publicId, String systemId) throws XMLException
Este método deve ser sobrescrito pelas classes que precisam redefinir a localização do DTD.
resolveEntity in interface XMLHandlerInterfacepublicId - FIXME entender do que se trata... na prática, raramente é
usadosystemId - para declarações do tipo
<!DOCTYPE xxx SYSTEM yyy>, o valor deste
parâmetro é yyy (a referência ao DTD)XMLExceptionDefaultHandler.resolveEntity(String, String)public final void setDTD(String dtd)
setDTD in interface XMLHandlerInterfacedtd - public final String getDTD()
getDTD in interface XMLHandlerInterfacepublic final XMLElementFactoryInterface getXMLFactory()
getXMLFactory in interface XMLHandlerInterfaceXMLElementFactoryInterfacepublic final void endDocument()
throws XMLException
endDocument in interface XMLHandlerInterfaceXMLExceptionpublic void endDocument(XMLElementInterface rootElement)
endDocument in interface XMLHandlerInterfacerootElement - raiz do XMLpublic void warning(XMLException e) throws XMLException
warning in interface XMLHandlerInterfacee - - exceção que gerou o warningXMLExceptionpublic void fatalError(XMLException e) throws XMLException
fatalError in interface XMLHandlerInterfacee - - exceção que gerou o erroXMLExceptionpublic void error(XMLException e) throws XMLException
error in interface XMLHandlerInterfacee - - exceção que gerou o erroXMLExceptionErrorHandler.error(org.xml.sax.SAXParseException)Copyright © 2016 Tecgraf/PUC-Rio. All rights reserved.