public Object getImmediateNode() { throw new JXPathException( "Undefined variable: " + name); } };
LOG.warn("Unable to get value for {}: {}", object.getXpath(), ex.getMessage());
LOG.warn("Unable to get value for {}: {}", object.getXpath(), ex.getMessage());
/** * 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"); } } }
/** * Maps a model type to a parser. * @param model input model type * @return XMLParser */ private static XMLParser getParser(String model) { XMLParser parser = (XMLParser) parsers.get(model); if (parser == null) { String className = (String) parserClasses.get(model); if (className == null) { throw new JXPathException("Unsupported XML model: " + model); } try { Class clazz = Class.forName(className); parser = (XMLParser) clazz.newInstance(); } catch (Exception ex) { throw new JXPathException( "Cannot allocate XMLParser: " + className, ex); } parsers.put(model, parser); } return parser; } }
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); } }
/** * Checks if existenceCheckClass exists on the class path. If so, allocates * an instance of the specified class, otherwise returns null. * @param className to instantiate * @param existenceCheckClassName guard class * @return className instance */ public static Object allocateConditionally(String className, String existenceCheckClassName) { try { try { Class.forName(existenceCheckClassName); } catch (ClassNotFoundException ex) { return null; } Class cls = Class.forName(className); return cls.newInstance(); } catch (Exception ex) { throw new JXPathException("Cannot allocate " + className, 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); } }
/** * Returns a shared instance of the dynamic property handler class * returned by <code>getDynamicPropertyHandlerClass()</code>. * @param clazz to handle * @return DynamicPropertyHandler */ public static DynamicPropertyHandler getDynamicPropertyHandler(Class clazz) { DynamicPropertyHandler handler = (DynamicPropertyHandler) dynamicPropertyHandlerMap.get(clazz); if (handler == null) { try { handler = (DynamicPropertyHandler) clazz.newInstance(); } catch (Exception ex) { throw new JXPathException( "Cannot allocate dynamic property handler of class " + clazz.getName(), ex); } dynamicPropertyHandlerMap.put(clazz, handler); } return handler; }
/** * 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"); }
/** * Create the given path setting its value to value. * @param xpath String * @param expr compiled Expression * @param value Object * @return resulting Pointer */ public Pointer createPathAndSetValue(String xpath, Expression expr, Object value) { try { return setValue(xpath, expr, value, true); } catch (Throwable ex) { throw new JXPathException( "Exception trying to create xpath " + xpath, ex); } }
/** * Convert value to type. * @param value Object * @param type destination * @return conversion result */ 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); } }
/** * Called by a child pointer if that child needs to assign the value * supplied in the createPath(context, value) call to a non-existent * node. This method may have to expand the collection in order to assign * the element. * @param context the owning JXPathCOntext * @param name the QName at which a child should be created * @param index child index. * @param value node value to set * @return created NodePointer */ public NodePointer createChild( JXPathContext context, QName name, int index, Object value) { throw new JXPathException("Cannot create an object for path " + asPath() + "/" + name + "[" + (index + 1) + "]" + ", operation is not allowed for this type of node"); }
/** * Returns the value of the bean's property represented by * the supplied property descriptor. * @param bean to read * @param propertyDescriptor indicating what to read * @return Object value */ public static Object getValue(Object bean, PropertyDescriptor propertyDescriptor) { Object value; try { Method method = getAccessibleMethod(propertyDescriptor.getReadMethod()); if (method == null) { throw new JXPathException("No read method"); } value = method.invoke(bean, new Object[0]); } catch (Exception ex) { throw new JXPathException( "Cannot access property: " + (bean == null ? "null" : bean.getClass().getName()) + "." + propertyDescriptor.getName(), ex); } return value; }
public void remove() { Element parent = nodeParent(node); if (parent == null) { throw new JXPathException("Cannot remove root JDOM node"); } parent.getContent().remove(node); }