public Object getImmediateNode() { throw new JXPathException( "Undefined variable: " + name); } };
/** * Construct a new DocumentContainer. * @param xmlURL is a URL for an XML file. Use getClass().getResource * (resourceName) to load XML from a resource file. * * @param model is one of the MODEL_* constants defined in this class. It * determines which parser should be used to load the XML. */ public DocumentContainer(URL xmlURL, String model) { this.xmlURL = xmlURL; if (xmlURL == null) { throw new JXPathException("XML URL is null"); } this.model = model; }
public void remove() { Node parent = node.getParentNode(); if (parent == null) { throw new JXPathException("Cannot remove root DOM node"); } parent.removeChild(node); }
/** * Called to create a non-existing attribute * @param context the owning JXPathCOntext * @param name the QName at which an attribute should be created * @return created NodePointer */ public NodePointer createAttribute(JXPathContext context, QName name) { throw new JXPathException("Cannot create an attribute for path " + asPath() + "/@" + name + ", operation is not allowed for this type of node"); }
private String getMandatoryData( JXPathContext ctx, String ctxFieldName ) { String value = (String)ctx.getValue( ctxFieldName ); if ( value != null && value.length() == 0 ) { throw new JXPathException( "Mandatory field " + ctxFieldName + " not provided, uncompliant UPNP device !!" ); } return value; }
public void setProperty(Object bean, String property, Object value) { HttpSessionAndServletContext handle = (HttpSessionAndServletContext) bean; HttpSession session = handle.getSession(); if (session != null) { session.setAttribute(property, value); } else { throw new JXPathException("Cannot set session attribute: " + "there is no session"); } } }
private static Object convert(Object value, Class<?> type) { try { return TypeUtils.convert(value, type); } catch (Exception ex) { throw new JXPathException( "Cannot convert value of class " + (value == null ? "null" : value.getClass().getName()) + " to type " + type, ex); } }
private static Object convert(Object value, Class<?> type) { try { return TypeUtils.convert(value, type); } catch (Exception ex) { throw new JXPathException( "Cannot convert value of class " + (value == null ? "null" : value.getClass().getName()) + " to type " + type, ex); } }
/** * Set the value of xpath to value. * @param xpath path * @param expr compiled Expression * @param value Object */ public void setValue(String xpath, Expression expr, Object value) { try { setValue(xpath, expr, value, false); } catch (Throwable ex) { throw new JXPathException( "Exception trying to set value with xpath " + xpath, ex); } }
/** * Called by a child pointer when it needs to create a parent object for a * non-existent collection element. It may have to expand the collection, * then create an element object and return a new pointer describing the * newly created element. * @param context the owning JXPathCOntext * @param name the QName at which a child should be created * @param index child index. * @return created NodePointer */ public NodePointer createChild(JXPathContext context, QName name, int index) { throw new JXPathException("Cannot create an object for path " + asPath() + "/" + name + "[" + (index + 1) + "]" + ", operation is not allowed for this type of node"); }
public void remove() { Element parent = nodeParent(node); if (parent == null) { throw new JXPathException("Cannot remove root JDOM node"); } parent.getContent().remove(node); }
public Object getBaseValue() { if (!actual) { throw new JXPathException("Undefined variable: " + name); } return variables.getVariable(name.toString()); }
public JXPathContext getRelativeContext(Pointer pointer) { Object contextBean = pointer.getNode(); if (contextBean == null) { throw new JXPathException( "Cannot create a relative context for a non-existent node: " + pointer); } return new JXPathContextReferenceImpl(this, contextBean, pointer); }
/** * Get the AbstractFactory associated with the specified JXPathContext. * @param context JXPathContext * @return AbstractFactory */ protected AbstractFactory getAbstractFactory(JXPathContext context) { AbstractFactory factory = context.getFactory(); if (factory == null) { throw new JXPathException( "Factory is not set on the JXPathContext - cannot create path: " + asPath()); } return factory; }
/** * Locates a Node by its ID. * * @param id is the ID of the sought node. * @return Pointer */ public Pointer getPointerByID(String id) { IdentityManager manager = getIdentityManager(); if (manager != null) { return manager.getPointerByID(this, id); } throw new JXPathException( "Cannot find an element by ID - " + "no IdentityManager has been specified"); }
/** * Locates a Node by a key value. * @param key string * @param value string * @return Pointer found */ public Pointer getPointerByKey(String key, String value) { KeyManager manager = getKeyManager(); if (manager != null) { return manager.getPointerByKey(this, key, value); } throw new JXPathException( "Cannot find an element by key - " + "no KeyManager has been specified"); }
/** * Remove the specified path. * @param xpath expression * @param expr compiled Expression */ public void removePath(String xpath, Expression expr) { try { NodePointer pointer = (NodePointer) getPointer(xpath, expr); if (pointer != null) { ((NodePointer) pointer).remove(); } } catch (Throwable ex) { throw new JXPathException( "Exception trying to remove xpath " + xpath, ex); } }
public Object parseXML(InputStream stream) { if (!isNamespaceAware()) { throw new JXPathException("JDOM parser configuration error. JDOM " + "does not support the namespaceAware=false setting."); } try { SAXBuilder builder = new SAXBuilder(); builder.setExpandEntities(isExpandEntityReferences()); builder.setIgnoringElementContentWhitespace( isIgnoringElementContentWhitespace()); builder.setValidation(isValidating()); return builder.build(stream); } catch (Exception ex) { throw new JXPathException("JDOM parser error", ex); } } }
/** * Locates a NodeSet by key/value. * @param key string * @param value object * @return NodeSet found */ public NodeSet getNodeSetByKey(String key, Object value) { KeyManager manager = getKeyManager(); if (manager != null) { return KeyManagerUtils.getExtendedKeyManager(manager) .getNodeSetByKey(this, key, value); } throw new JXPathException("Cannot find an element by key - " + "no KeyManager has been specified"); }
public void setValue(Object value) { if (!actual) { throw new JXPathException("Cannot set undefined variable: " + name); } valuePointer = null; if (index != WHOLE_COLLECTION) { Object collection = getBaseValue(); ValueUtils.setValue(collection, index, value); } else { variables.declareVariable(name.toString(), value); } }