LinkedList<String>
Publicado por afrika (112 intervenciones) el 04/02/2007 14:29:28
Buenos dias....
Y tomando en cuenta el LinkedList, me gustaria saber porque cuando voy a guardar en la lista, solo me guarda el primer string y los demas (los 5 restantes) los imprime null....??.. (Los metodos que ven alli son de DefaultHandler, para analizar un xml...)
Codigo:
LinkedList lista = new LinkedList();
public void characters (char[] ch, int start, int length) throws SAXException
{
if(booOx) stringOx = sbOx.copyValueOf(ch,start,length);
else if(booOy) stringOy = sbOy.copyValueOf(ch,start,length);
else if(booOz) stringOz = sbOz.copyValueOf(ch,start,length);
...........
}
public void endElement (String namespaceURI, String localName,String rawName)throws SAXException
{
if (localName.equals("verticeox")) lista.add(stringOx);
else if (localName.equals("verticeoy"))lista.add(stringOy);
else if (localName.equals("verticeoz"))lista.add(stringOz);
else if (localName.equals("verticedx"))lista.add(stringDx);
else if (localName.equals("verticedy"))lista.add(stringDy);
else if (localName.equals("verticedz"))lista.add(stringDz);
}
public void endDocument()
{
Iterator itr=lista.iterator();
while (itr.hasNext())
{
String imp = (String)itr.next();
System.out.print(imp);
}
System.out.println("Finished processing the document");
}
POR FAVOR Y GRACIAS!
Y tomando en cuenta el LinkedList, me gustaria saber porque cuando voy a guardar en la lista, solo me guarda el primer string y los demas (los 5 restantes) los imprime null....??.. (Los metodos que ven alli son de DefaultHandler, para analizar un xml...)
Codigo:
LinkedList lista = new LinkedList();
public void characters (char[] ch, int start, int length) throws SAXException
{
if(booOx) stringOx = sbOx.copyValueOf(ch,start,length);
else if(booOy) stringOy = sbOy.copyValueOf(ch,start,length);
else if(booOz) stringOz = sbOz.copyValueOf(ch,start,length);
...........
}
public void endElement (String namespaceURI, String localName,String rawName)throws SAXException
{
if (localName.equals("verticeox")) lista.add(stringOx);
else if (localName.equals("verticeoy"))lista.add(stringOy);
else if (localName.equals("verticeoz"))lista.add(stringOz);
else if (localName.equals("verticedx"))lista.add(stringDx);
else if (localName.equals("verticedy"))lista.add(stringDy);
else if (localName.equals("verticedz"))lista.add(stringDz);
}
public void endDocument()
{
Iterator itr=lista.iterator();
while (itr.hasNext())
{
String imp = (String)itr.next();
System.out.print(imp);
}
System.out.println("Finished processing the document");
}
POR FAVOR Y GRACIAS!
Valora esta pregunta


0