/** * Resolve the reference, looking in the associated project. * @see Project#getReference * @return the dereferenced object. * @throws BuildException if the project is null or the reference cannot be dereferenced * @since Ant 1.6.3 */ public Object getReferencedObject() throws BuildException { if (project == null) { throw new BuildException("No project set on reference to " + refid); } return getReferencedObject(project); }
private ResourceCollection createResourceCollection(Reference ref) { Object o = ref.getReferencedObject(); if (!(o instanceof ResourceCollection)) { throw new BuildException("Only File based ResourceCollections are supported."); } ResourceCollection rc = (ResourceCollection) o; if (!rc.isFilesystemOnly()) { throw new BuildException("Only ResourceCollections from local file system are supported."); } return rc; }
/** Specify which path will be used. If the loader already exists * and is an AntClassLoader (or any other loader we can extend), * the path will be added to the loader. * @param pathRef a reference to a path. * @throws BuildException if there is a problem. */ public void setClasspathRef(Reference pathRef) throws BuildException { classpath = (Path) pathRef.getReferencedObject(getProject()); }
private ResourceCollection createResourceCollection(Reference ref) { Object o = ref.getReferencedObject(); if (!(o instanceof ResourceCollection)) { throw new BuildException("Only File based ResourceCollections are supported."); } ResourceCollection rc = (ResourceCollection) o; if (!rc.isFilesystemOnly()) { throw new BuildException("Only ResourceCollections from local file system are supported."); } return rc; }
/** * 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); }
/** * get whatever we are referencing to. This could be ourself. * @return the object that contains the assertion info */ private Assertions getFinalReference() { if (getRefid() == null) { return this; } Object o = getRefid().getReferencedObject(getProject()); if (!(o instanceof Assertions)) { throw new BuildException("reference is of wrong type"); } return (Assertions) o; }
/** * 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
/** * 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 check attributes for TarFileSet. * If there is a reference, and * it is a TarFileSet, the tar fileset attributes * cannot be used. */ private void checkTarFileSetAttributesAllowed() { if (getProject() == null || (isReference() && (getRefid().getReferencedObject( getProject()) instanceof TarFileSet))) { checkAttributesAllowed(); } }
/** * 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); }
Object o = refid.getReferencedObject(getProject()); if (!(o instanceof ResourceCollection)) { throw new BuildException(
dieOnCircularReference(); Reference r = getRefid(); Object o = r.getReferencedObject(getProject()); if (o instanceof FileNameMapper) { return (FileNameMapper) o;
/** * A check attributes for archiveFileSet. * If there is a reference, and * it is a ArchiveFileSet, the archive fileset attributes * cannot be used. * (Note, we can only see if the reference is an archive * fileset if the project has been set). */ private void checkArchiveAttributesAllowed() { if (getProject() == null || (isReference() && (getRefid().getReferencedObject( getProject()) instanceof ArchiveFileSet))) { checkAttributesAllowed(); } }
try { addProperty(name, ref.getReferencedObject(getProject()).toString()); } catch (BuildException be) { if (fallback != null) { addProperty(name, ref.getReferencedObject(fallback).toString()); } else { throw be;
return; Object o = ref.getReferencedObject(project);
ClassLoader cl = null; if (loader != null) { cl = (ClassLoader) loader.getReferencedObject();
/** * overrides FileSet's implementation which would throw an exception since * the referenced object isn't this type. */ @Override protected AbstractFileSet getRef(final Project p) { return (AbstractFileSet) this.ref.getReferencedObject(p); }
public void setClasspathRef( Reference classpathRef ) { if ( classpathRef != null && classpathRef.getReferencedObject() instanceof Path ) { createClasspath().add( ( Path ) classpathRef.getReferencedObject() ); } }
public File getComponentFile(Project project) throws BuildException { if (file != null) return file; if (ref != null) { try { Component referenced = (Component)ref.getReferencedObject(project); return referenced.getComponentFile(project); } catch (ClassCastException cce) { throw new BuildException("Referenced task is not a Component task"); } } throw new BuildException("One of ref or file attribute must be specified"); }