本文整理汇总了Java中org.cybergarage.xml.ParserException类的典型用法代码示例。如果您正苦于以下问题:Java ParserException类的具体用法?Java ParserException怎么用?Java ParserException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ParserException类属于org.cybergarage.xml包,在下文中一共展示了ParserException类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addDevice
import org.cybergarage.xml.ParserException; //导入依赖的package包/类
private synchronized void addDevice(SSDPPacket ssdpPacket) {
if (ssdpPacket.isRootDevice()) {
Device dev = getDevice(USN.getUDN(ssdpPacket.getUSN()));
if (dev != null) {
dev.setSSDPPacket(ssdpPacket);
} else {
try {
Node rootNode = UPnP.getXMLParser().parse(new URL(ssdpPacket.getLocation()));
Device rootDev = getDevice(rootNode);
if (rootDev != null) {
rootDev.setSSDPPacket(ssdpPacket);
addDevice(rootNode);
performAddDeviceListener(rootDev);
}
} catch (MalformedURLException me) {
Debug.warning(ssdpPacket.toString());
Debug.warning(me);
} catch (ParserException pe) {
Debug.warning(ssdpPacket.toString());
Debug.warning(pe);
}
}
}
}
示例2: loadDescription
import org.cybergarage.xml.ParserException; //导入依赖的package包/类
/**
* @since 1.8.0
*/
public boolean loadDescription(InputStream input) throws InvalidDescriptionException
{
try {
Parser parser = UPnP.getXMLParser();
rootNode = parser.parse(input);
if (rootNode == null)
throw new InvalidDescriptionException(Description.NOROOT_EXCEPTION);
deviceNode = rootNode.getNode(Device.ELEM_NAME);
if (deviceNode == null)
throw new InvalidDescriptionException(Description.NOROOTDEVICE_EXCEPTION);
}
catch (ParserException e) {
throw new InvalidDescriptionException(e);
}
if (initializeLoadedDescription() == false)
return false;
setDescriptionFile(null);
return true;
}
示例3: getRootNode
import org.cybergarage.xml.ParserException; //导入依赖的package包/类
private synchronized Node getRootNode()
{
if (rootNode != null)
return rootNode;
try {
byte content[] = getContent();
ByteArrayInputStream contentIn = new ByteArrayInputStream(content);
Parser parser = SOAP.getXMLParser();
rootNode = parser.parse(contentIn);
}
catch (ParserException e) {
Debug.warning(e);
}
return rootNode;
}
示例4: loadDescription
import org.cybergarage.xml.ParserException; //导入依赖的package包/类
/**
* @since 1.8.0
*/
public boolean loadDescription(InputStream input)
throws InvalidDescriptionException {
try {
Parser parser = UPnP.getXMLParser();
rootNode = parser.parse(input);
if (rootNode == null)
throw new InvalidDescriptionException(
Description.NOROOT_EXCEPTION);
deviceNode = rootNode.getNode(Device.ELEM_NAME);
if (deviceNode == null)
throw new InvalidDescriptionException(
Description.NOROOTDEVICE_EXCEPTION);
} catch (ParserException e) {
throw new InvalidDescriptionException(e);
}
if (initializeLoadedDescription() == false)
return false;
setDescriptionFile(null);
return true;
}
示例5: loadSCPD
import org.cybergarage.xml.ParserException; //导入依赖的package包/类
public boolean loadSCPD(String scpdStr) throws InvalidDescriptionException
{
try {
Parser parser = UPnP.getXMLParser();
Node scpdNode = parser.parse(scpdStr);
if (scpdNode == null)
return false;
ServiceData data = getServiceData();
data.setSCPDNode(scpdNode);
}
catch (ParserException e) {
throw new InvalidDescriptionException(e);
}
return true;
}
示例6: loadSCPD
import org.cybergarage.xml.ParserException; //导入依赖的package包/类
public boolean loadSCPD(String scpdStr) throws InvalidDescriptionException
{
try {
Parser parser = UPnP.getXMLParser();
Node scpdNode = parser.parse(scpdStr);
if (scpdNode == null)
return false;
ServiceData data = getServiceData();
data.setSCPDNode(scpdNode);
}
catch (ParserException e) {
throw new InvalidDescriptionException(e);
}
return true;
}
示例7: parse
import org.cybergarage.xml.ParserException; //导入依赖的package包/类
public Node parse(InputStream inStream) throws ParserException
{
org.cybergarage.xml.Node root = null;
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
InputSource inSrc = new InputSource(new NullFilterInputStream(inStream));
Document doc = builder.parse(inSrc);
org.w3c.dom.Element docElem = doc.getDocumentElement();
if (docElem != null)
root = parse(root, docElem);
/*
NodeList rootList = doc.getElementsByTagName("root");
Debug.message("rootList = " + rootList.getLength());
if (0 < rootList.getLength())
root = parse(root, rootList.item(0));
*/
}
catch (Exception e) {
throw new ParserException(e);
}
return root;
}
示例8: parse
import org.cybergarage.xml.ParserException; //导入依赖的package包/类
/**
* Process the XML input stream.
*
* @param in XML content only. Any su3 or gunzip handling must have
* already happened.
* @throws IOException on any parse error
*/
public void parse(InputStream in) throws IOException {
_entries = null;
_metadata = null;
XMLParser parser = new XMLParser(_context);
try {
Node root = parser.parse(in);
extract(root);
} catch (ParserException pe) {
throw new I2PParserException(pe);
}
}
示例9: addDevice
import org.cybergarage.xml.ParserException; //导入依赖的package包/类
private synchronized void addDevice(SSDPPacket ssdpPacket)
{
if (ssdpPacket.isRootDevice() == false)
return;
String usn = ssdpPacket.getUSN();
String udn = USN.getUDN(usn);
Device dev = getDevice(udn);
if (dev != null) {
dev.setSSDPPacket(ssdpPacket);
return;
}
String location = ssdpPacket.getLocation();
try {
URL locationUrl = new URL(location);
Parser parser = UPnP.getXMLParser();
Node rootNode = parser.parse(locationUrl);
Device rootDev = getDevice(rootNode);
if (rootDev == null)
return;
rootDev.setSSDPPacket(ssdpPacket);
addDevice(rootNode);
// Thanks for Oliver Newell (2004/10/16)
// After node is added, invoke the AddDeviceListener to notify high-level
// control point application that a new device has been added. (The
// control point application must implement the DeviceChangeListener interface
// to receive the notifications)
performAddDeviceListener( rootDev );
}
catch (MalformedURLException me) {
Debug.warning(ssdpPacket.toString());
Debug.warning(me);
}
catch (ParserException pe) {
Debug.warning(ssdpPacket.toString());
Debug.warning(pe);
}
}
示例10: parse
import org.cybergarage.xml.ParserException; //导入依赖的package包/类
public Node parse(InputStream inStream) throws ParserException
{
org.cybergarage.xml.Node root = null;
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
InputSource inSrc = new InputSource(inStream);
Document doc = builder.parse(inSrc);
org.w3c.dom.Element docElem = doc.getDocumentElement();
if (docElem != null)
root = parse(root, docElem);
/*
NodeList rootList = doc.getElementsByTagName("root");
Debug.message("rootList = " + rootList.getLength());
if (0 < rootList.getLength())
root = parse(root, rootList.item(0));
*/
}
catch (Exception e) {
throw new ParserException(e);
}
return root;
}
示例11: browse
import org.cybergarage.xml.ParserException; //导入依赖的package包/类
public Node browse(Device dev, String objectID, String browseFlag, String filter, int startIndex, int requestedCount, String sortCaiteria) {
System.out.println("browse " + objectID + ", " + browseFlag + ", " + startIndex + ", " + requestedCount);
if (dev == null) {
return null;
}
Service conDir = dev.getService(ContentDirectory.SERVICE_TYPE);
if (conDir == null) {
return null;
}
Action action = conDir.getAction(ContentDirectory.BROWSE);
if (action == null) {
return null;
}
BrowseAction browseAction = new BrowseAction(action);
browseAction.setObjectID(objectID);
browseAction.setBrowseFlag(browseFlag);
browseAction.setStartingIndex(startIndex);
browseAction.setRequestedCount(requestedCount);
browseAction.setFilter(filter);
browseAction.setSortCriteria(sortCaiteria);
if (!browseAction.postControlAction()) {
return null;
}
if (requestedCount == 0) {
int numberReturned = browseAction.getNumberReturned();
int totalMatches = browseAction.getTotalMatches();
if (numberReturned == 0) {
if (totalMatches > 0) {
browseAction.setRequestedCount(totalMatches);
if (!browseAction.postControlAction()) {
return null;
}
}
browseAction.setRequestedCount(9999);
if (!browseAction.postControlAction()) {
return null;
}
}
}
Argument resultArg = browseAction.getArgument("Result");
if (resultArg == null) {
return null;
}
String resultStr = resultArg.getValue();
if (resultStr == null) {
return null;
}
try {
return UPnP.getXMLParser().parse(resultStr);
} catch (ParserException pe) {
Debug.warning(pe);
return null;
}
}
示例12: getSCPDNode
import org.cybergarage.xml.ParserException; //导入依赖的package包/类
private Node getSCPDNode(URL scpdUrl) throws ParserException
{
Parser parser = UPnP.getXMLParser();
return parser.parse(scpdUrl);
}
示例13: addDevice
import org.cybergarage.xml.ParserException; //导入依赖的package包/类
private synchronized void addDevice(SSDPPacket ssdpPacket)
{
if (ssdpPacket.isRootDevice() == false)
return;
String usn = ssdpPacket.getUSN();
String udn = USN.getUDN(usn);
Device dev = getDevice(udn);
if (dev != null) {
dev.setSSDPPacket(ssdpPacket);
return;
}
String location = ssdpPacket.getLocation();
try {
URL locationUrl = new URL(location);
Parser parser = UPnP.getXMLParser();
Node rootNode = parser.parse(locationUrl);
Device rootDev = getDevice(rootNode);
if (rootDev == null)
return;
rootDev.setSSDPPacket(ssdpPacket);
Debug.warning("Add root device", new Exception("received on " + ssdpPacket.getLocalAddress()));
addDevice(rootNode);
// Thanks for Oliver Newell (2004/10/16)
// After node is added, invoke the AddDeviceListener to notify high-level
// control point application that a new device has been added. (The
// control point application must implement the DeviceChangeListener interface
// to receive the notifications)
performAddDeviceListener( rootDev );
}
catch (MalformedURLException me) {
Debug.warning(ssdpPacket.toString());
Debug.warning(me);
}
catch (ParserException pe) {
Debug.warning(ssdpPacket.toString());
Debug.warning(pe);
}
}