Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
package com.openshift.internal.client;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.util.ArrayList;
Expand All @@ -23,21 +21,14 @@
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Properties;
import java.util.StringTokenizer;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;

import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

import com.jcraft.jsch.Channel;
import com.jcraft.jsch.ChannelExec;
Expand Down Expand Up @@ -921,82 +912,4 @@ protected ListGearsRequest() {
super(LINK_LIST_GEARS);
}
}

private class CartridgeSAXParser extends DefaultHandler {

Properties props = new Properties();
boolean inProperty = false;
boolean inName = false;
boolean inDescription = false;
String tmpName = null;
String tmpDescription = null;

public CartridgeSAXParser(){
props = new Properties();
}

public Properties getProperties() {
return props;
}

public void parseDocument(String xml) {

//get a factory
SAXParserFactory spf = SAXParserFactory.newInstance();
InputStream is = null;
try {

//get a new instance of parser
SAXParser sp = spf.newSAXParser();

is = new ByteArrayInputStream(xml.getBytes());
sp.parse(is, this);

} catch(SAXException se) {
se.printStackTrace();
} catch(ParserConfigurationException pce) {
pce.printStackTrace();
} catch (IOException ie) {
ie.printStackTrace();
} finally {
if (is != null)
try { is.close(); } catch (IOException e){}
}
}

public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
if (qName.equalsIgnoreCase("property")) {
inProperty = true;
} else if (inProperty) {
if (qName.equalsIgnoreCase("name")) {
inName = true;
} else if (qName.equalsIgnoreCase("description")) {
inDescription = true;
}
}
}


public void characters(char[] ch, int start, int length) throws SAXException {
if (inName)
tmpName = new String(ch,start,length);
else if (inDescription)
tmpDescription = new String(ch,start,length);
}

public void endElement(String uri, String localName, String qName) throws SAXException {

if (inProperty){
if (qName.equalsIgnoreCase("property")) {
inProperty = false;
} else if (qName.equalsIgnoreCase("name")) {
inName = false;
} else if (qName.equalsIgnoreCase("description")) {
inDescription = false;
props.put(tmpName, tmpDescription);
}
}
}

}
}