/** * Sets the loaderRef. * @param r the reference to the loader. */ public void setLoaderRef(Reference r) { this.loaderId = r.getRefId(); }
/** * Set the ResourceCollection reference. * @param r the Reference. */ public void setRefid(Reference r) { Object o = r.getReferencedObject(); if (!(o instanceof ResourceCollection)) { throw new BuildException("%s doesn\'t denote a ResourceCollection", r.getRefId()); } add((ResourceCollection) o); }
/** * Delegate method handling the @classpathref attribute. * * <p>This attribute can add a referenced path-like structure to the * classpath.</p> * * @param r the reference to the classpath. */ public void setClasspathref(Reference r) { this.classpathId = r.getRefId(); createClasspath().setRefid(r); }
/** * Convenience overloaded version of {@link #getClassLoaderForPath(Project, Path, * String, boolean)}. * * <p>Delegates to the other one after extracting the referenced * Path from the Project. This checks also that the passed * Reference is pointing to a Path all right.</p> * @param p current Ant project * @param ref Reference to Path structure * @param reverseLoader if set to true this new loader will take * precedence over its parent (which is contra the regular * classloader behaviour) * @return The class loader */ public static ClassLoader getClassLoaderForPath( Project p, Reference ref, boolean reverseLoader) { String pathId = ref.getRefId(); Object path = p.getReference(pathId); if (!(path instanceof Path)) { throw new BuildException( "The specified classpathref %s does not reference a Path.", pathId); } String loaderId = MagicNames.REFID_CLASSPATH_LOADER_PREFIX + pathId; return getClassLoaderForPath(p, (Path) path, loaderId, reverseLoader); }
/** * Performs the check for circular references and returns the * referenced object. This version allows the fallback Project instance to be specified. * @param <T> required reference type * @param requiredClass the class that this reference should be a subclass of. * @param dataTypeName the name of the datatype that the reference should be * (error message use only). * @param project the fallback Project instance for dereferencing. * @return the dereferenced object. * @throws BuildException if the reference is invalid (circular ref, wrong class, etc), * or if <code>project</code> is <code>null</code>. * @since Ant 1.7 */ @SuppressWarnings("unchecked") protected <T> T getCheckedRef(final Class<T> requiredClass, final String dataTypeName, final Project project) { if (project == null) { throw new BuildException("No Project specified"); } dieOnCircularReference(project); Object o = ref.getReferencedObject(project); if (requiredClass.isAssignableFrom(o.getClass())) { return (T) o; } log("Class " + displayName(o.getClass()) + " is not a subclass of " + displayName(requiredClass), Project.MSG_VERBOSE); throw new BuildException(ref.getRefId() + " doesn\'t denote a " + dataTypeName); }
/** * If this is a reference, this method will add the referenced resource * collection to the collection of paths. * * @throws BuildException if the reference is not to a resource collection */ private void dealWithReferences() throws BuildException { if (isReference()) { final Object o = refId.getReferencedObject(getProject()); if (!(o instanceof ResourceCollection)) { throw new BuildException("refId '" + refId.getRefId() + "' does not refer to a resource collection."); } getPath().add((ResourceCollection) o); } } // END COPY from org.apache.tools.ant.taskdefs
/** * @return true if the reference exists and if type is set, if * the reference is the same type * @exception BuildException if an error occurs */ @Override public boolean eval() throws BuildException { if (ref == null) { throw new BuildException( "No reference specified for isreference condition"); } String key = ref.getRefId(); if (!getProject().hasReference(key)) { return false; } if (type == null) { return true; } Class<?> typeClass = getProject().getDataTypeDefinitions().get(type); if (typeClass == null) { typeClass = getProject().getTaskDefinitions().get(type); } // if the type is unknown, throw exception instead? return typeClass != null && typeClass.isAssignableFrom(getProject().getReference(key).getClass()); }
/** * A TarFileset accepts another TarFileSet or a FileSet as reference * FileSets are often used by the war task for the lib attribute * @param p the project to use * @return the abstract fileset instance */ @Override protected AbstractFileSet getRef(Project p) { dieOnCircularReference(p); Object o = getRefid().getReferencedObject(p); if (o instanceof TarFileSet) { return (AbstractFileSet) o; } if (o instanceof FileSet) { TarFileSet zfs = new TarFileSet((FileSet) o); configureFileSet(zfs); return zfs; } String msg = getRefid().getRefId() + " doesn\'t denote a tarfileset or a fileset"; throw new BuildException(msg); }
/** * A ZipFileset accepts another ZipFileSet or a FileSet as reference * FileSets are often used by the war task for the lib attribute * @param p the project to use * @return the abstract fileset instance */ @Override protected AbstractFileSet getRef(Project p) { dieOnCircularReference(p); Object o = getRefid().getReferencedObject(p); if (o instanceof ZipFileSet) { return (AbstractFileSet) o; } if (o instanceof FileSet) { ZipFileSet zfs = new ZipFileSet((FileSet) o); configureFileSet(zfs); return zfs; } String msg = getRefid().getRefId() + " doesn\'t denote a zipfileset or a fileset"; throw new BuildException(msg); }
+ r.getRefId() + "' is not a valid mapper reference.");
throw new BuildException( "refid '%s' does not refer to a resource collection.", refid.getRefId());
getProject().addReference(loader.getRefId(), cl);
/** * Gets the ProcessorDef specified by the extends attribute * * @return Base ProcessorDef, null if extends is not specified * @throws BuildException * if reference is not same type object */ public ProcessorDef getExtends() throws BuildException { if (this.extendsRef != null) { final Object obj = this.extendsRef.getReferencedObject(getProject()); if (!getClass().isInstance(obj)) { throw new BuildException("Referenced object " + this.extendsRef.getRefId() + " not correct type, is " + obj.getClass().getName() + " should be " + getClass().getName()); } return (ProcessorDef) obj; } return null; }
protected Ivy getIvyInstance() { Object antIvyEngine; if (antIvyEngineRef != null) { antIvyEngine = antIvyEngineRef.getReferencedObject(getProject()); if (!antIvyEngine.getClass().getName().equals(IvyAntSettings.class.getName())) { throw new BuildException(antIvyEngineRef.getRefId() + " doesn't reference an ivy:settings", getLocation()); } if (!(antIvyEngine instanceof IvyAntSettings)) { throw new BuildException(antIvyEngineRef.getRefId() + " has been defined in a different classloader. " + "Please use the same loader when defining your task, or " + "redeclare your ivy:settings in this classloader", getLocation()); } } else { antIvyEngine = IvyAntSettings.getDefaultInstance(this); } Ivy ivy = ((IvyAntSettings) antIvyEngine).getConfiguredIvyInstance(this); AntMessageLogger.register(this, ivy); return ivy; }
/** * A CommonsCompressFileSet accepts another FileSet as reference * @param p the project to use * @return the abstract fileset instance */ protected AbstractFileSet getRef(Project p) { dieOnCircularReference(p); Object o = getRefid().getReferencedObject(p); if (o.getClass().equals(getClass())) { return (AbstractFileSet) o; } else if (o instanceof FileSet) { CommonsCompressFileSet zfs = newFileSet((FileSet) o); configureFileSet(zfs); return zfs; } else { String msg = getRefid().getRefId() + " doesn\'t denote a fileset"; throw new BuildException(msg); } }
/** * @return the container object refId */ private Object getContainerReference() { Object o; try { o = getRefid().getReferencedObject(getProject()); } catch (BuildException e) { throw new BuildException("The [" + getRefid().getRefId() + "] reference does not " + "exist. You must first define a Cargo container reference.", e); } return o; }
/** * @return the container object refId */ private Object getContainerReference() { Object o; try { o = getRefid().getReferencedObject(getProject()); } catch (BuildException e) { throw new BuildException("The [" + getRefid().getRefId() + "] reference does not " + "exist. You must first define a Cargo container reference.", e); } return o; }
/** * If this is a reference, this method will add the referenced resource * collection to the collection of paths. * * @throws BuildException if the reference is not to a resource collection */ private void dealWithReferences() throws BuildException { if (isReference()) { final Object o = refId.getReferencedObject(getProject()); if (!(o instanceof ResourceCollection)) { throw new BuildException("refId '" + refId.getRefId() + "' does not refer to a resource collection."); } getPath().add((ResourceCollection) o); } } // END COPY from org.apache.tools.ant.taskdefs
currentRef = current.getExtends(); } else { throw new BuildException("Referenced element " + currentRef.getRefId() + " is not a versioninfo.");