1 /* 2 * Copyright 1999-2004 The Apache Software Foundation 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package org.apache.commons.jxpath; 17 18 /** 19 * The {@link JXPathContext#createPath JXPathContext.createPath()} method of 20 * JXPathContext can create missing objects as it traverses an XPath; it 21 * utilizes an AbstractFactory for that purpose. Install a factory on 22 * JXPathContext by calling {@link JXPathContext#setFactory JXPathContext. 23 * setFactory()}. 24 * <p> 25 * All methods of this class return false. Override any of them to return true 26 * to indicate that the factory has successfully created the described object. 27 * 28 * @author Dmitri Plotnikov 29 * @version $Revision: 1.8 $ $Date: 2004/02/29 14:17:42 $ 30 */ 31 public abstract class AbstractFactory { 32 33 /** 34 * The parameters may describe a collection element or an individual 35 * object. It is up to the factory to infer which one it is. If it is a 36 * collection, the factory should check if the collection exists. If not, 37 * it should create the collection. Then it should create the index'th 38 * element of the collection and return true. 39 * <p> 40 * 41 * @param context can be used to evaluate other XPaths, get to variables 42 * etc. 43 * @param pointer describes the location of the node to be created 44 * @param parent is the object that will server as a parent of the new 45 * object 46 * @param name is the name of the child of the parent that needs to be 47 * created. In the case of DOM may be qualified. 48 * @param index is used if the pointer represents a collection element. You 49 * may need to expand or even create the collection to accomodate the new 50 * element. 51 * 52 * @return true if the object was successfully created 53 */ 54 public boolean createObject(JXPathContext context, Pointer pointer, 55 Object parent, String name, int index) 56 { 57 return false; 58 } 59 60 /** 61 * Declare the specified variable 62 * 63 * @param context hosts variable pools. See 64 * {@link JXPathContext#getVariables() JXPathContext.getVariables()} 65 * @param name is the name of the variable without the "$" sign 66 * 67 * @return true if the variable was successfully defined 68 */ 69 public boolean declareVariable(JXPathContext context, String name) { 70 return false; 71 } 72 }