FileDocCategorySizeDatePackage
UniqueKeyConstraint.javaAPI DocGlassfish v2 API4188Tue May 22 16:54:54 BST 2007oracle.toplink.essentials.tools.schemaframework

UniqueKeyConstraint

public class UniqueKeyConstraint extends Object implements Serializable

Purpose: Define a unique key constraint for a table.

Fields Summary
protected String
name
protected Vector
sourceFields
Constructors Summary
public UniqueKeyConstraint()

        this.name = "";
        this.sourceFields = new Vector<String>();
    
public UniqueKeyConstraint(String name, String sourceField)

        this();
        this.name = name;
        sourceFields.addElement(sourceField);
    
public UniqueKeyConstraint(String name, String[] sourceFields)

        this();
        this.name = name;
        for(String sourceField : sourceFields) {
            this.sourceFields.addElement(sourceField);
        }
    
Methods Summary
public voidaddSourceField(java.lang.String sourceField)
PUBLIC:

        getSourceFields().addElement(sourceField);
    
public voidappendDBString(java.io.Writer writer, oracle.toplink.essentials.internal.sessions.AbstractSession session)
INTERNAL: Append the database field definition string to the table creation statement.

        try {
            writer.write("UNIQUE (");
            for (Enumeration sourceEnum = getSourceFields().elements();
                     sourceEnum.hasMoreElements();) {
                writer.write((String)sourceEnum.nextElement());
                if (sourceEnum.hasMoreElements()) {
                    writer.write(", ");
                }
            }
            writer.write(")");
        } catch (IOException ioException) {
            throw ValidationException.fileError(ioException);
        }
    
public java.lang.StringgetName()
PUBLIC:

        return name;
    
public java.util.VectorgetSourceFields()
PUBLIC:

        return sourceFields;
    
public voidsetName(java.lang.String name)
PUBLIC:

        this.name = name;
    
public voidsetSourceFields(java.util.Vector sourceFields)
PUBLIC:

        this.sourceFields = sourceFields;