FileDocCategorySizeDatePackage
Reference.javaAPI DocApache Ant 1.704066Wed Dec 13 06:16:24 GMT 2006org.apache.tools.ant.types

Reference

public class Reference extends Object
Class to hold a reference to another object in the project.

Fields Summary
private String
refid
private org.apache.tools.ant.Project
project
Constructors Summary
public Reference()
Create a reference.

deprecated
since 1.7. Please use {@link Reference#Reference(Project,String)} instead.

    
public Reference(String id)
Create a reference to a named ID.

param
id the name of this reference
deprecated
since 1.7. Please use {@link Reference#Reference(Project,String)} instead.

        setRefId(id);
    
public Reference(org.apache.tools.ant.Project p, String id)
Create a reference to a named ID in a particular project.

param
p the project this reference is associated with
param
id the name of this reference
since
Ant 1.6.3

        setRefId(id);
        setProject(p);
    
Methods Summary
public org.apache.tools.ant.ProjectgetProject()
Get the associated project, if any; may be null.

return
the associated project
since
Ant 1.6.3

        return project;
    
public java.lang.StringgetRefId()
Get the reference id of this reference.

return
the reference id

        return refid;
    
public java.lang.ObjectgetReferencedObject(org.apache.tools.ant.Project fallback)
Resolve the reference, using the associated project if it set, otherwise use the passed in project.

param
fallback the fallback project to use if the project attribute of reference is not set.
return
the dereferenced object.
throws
BuildException if the reference cannot be dereferenced.

        if (refid == null) {
            throw new BuildException("No reference specified");
        }

        Object o = project == null ? fallback.getReference(refid) : project.getReference(refid);
        if (o == null) {
            throw new BuildException("Reference " + refid + " not found.");
        }
        return o;
    
public java.lang.ObjectgetReferencedObject()
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

        if (project == null) {
            throw new BuildException("No project set on reference to " + refid);
        }
        return getReferencedObject(project);
    
public voidsetProject(org.apache.tools.ant.Project p)
Set the associated project. Should not normally be necessary; use {@link Reference#Reference(Project,String)}.

param
p the project to use
since
Ant 1.6.3

        this.project = p;
    
public voidsetRefId(java.lang.String id)
Set the reference id. Should not normally be necessary; use {@link Reference#Reference(Project, String)}.

param
id the reference id to use

        refid = id;