All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sun.jsftemplating.component.dataprovider.IndexFieldKey Maven / Gradle / Ivy

/*
 * The contents of this file are subject to the terms 
 * of the Common Development and Distribution License 
 * (the License).  You may not use this file except in
 * compliance with the License.
 * 
 * You can obtain a copy of the license at 
 * https://glassfish.dev.java.net/public/CDDLv1.0.html or
 * glassfish/bootstrap/legal/CDDLv1.0.txt.
 * See the License for the specific language governing 
 * permissions and limitations under the License.
 * 
 * When distributing Covered Code, include this CDDL 
 * Header Notice in each file and include the License file 
 * at glassfish/bootstrap/legal/CDDLv1.0.txt.  
 * If applicable, add the following below the CDDL Header, 
 * with the fields enclosed by brackets [] replaced by
 * you own identifying information: 
 * "Portions Copyrighted [year] [name of copyright owner]"
 * 
 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
 */
package com.sun.jsftemplating.component.dataprovider;

import com.sun.data.provider.FieldKey;


/**
 *  

This implementation of FieldKey provides a way to * associate an index along with the fieldId. One use case for this is * when a DataProvider acts as a facade for multiple data sources, the * index can be used to indicate to which underlying source the key * pertains.

* *

Keey in mind that a single FieldKey is meant to represent * all rows, so it would not be useful to store row information in a * FieldKey. Therefor the index in this IndexFieldKey is * not intended to specify a row!

* * @author Ken Paulsen ([email protected]) */ public class IndexFieldKey extends FieldKey { private static final long serialVersionUID = 1L; /** *

Constructs a new IndexFieldKey with the specified * fieldId and index.

* * @param fieldId The desired cannonical ID String. * @param index The index for this IndexFieldKey. */ public IndexFieldKey(String fieldId, int index) { super(fieldId); setIndex(index); } /** *

Constructs a new IndexFieldKey with the specified * fieldId, displayName, and * index.

* * @param fieldId The desired cannonical ID String for this field. * @param displayName The desired display name String. * @param index The index for this IndexFieldKey. */ public IndexFieldKey(String fieldId, String displayName, int index) { super(fieldId, displayName); setIndex(index); } /** *

Constructs a new IndexFieldKey with the specified * fieldId, displayName, and * index.

* * @param fk The FieldKey. * @param index The index for this IndexFieldKey. */ public IndexFieldKey(FieldKey fk, int index) { super(fk.getFieldId(), fk.getDisplayName()); setIndex(index); } /** *

This method retreives the index associated with this object.

*/ public int getIndex() { return _index; } /** *

This method retreives the index associated with this object.

*/ public void setIndex(int idx) { _index = idx; } /** *

Standard equals implementation. This method compares the * IndexFieldKey fieldId and * index values for equality.

* * @param obj The Object to check equality. * * @return true if equal, false if not. */ public boolean equals(Object obj) { boolean val = super.equals(obj); if (val && (obj instanceof IndexFieldKey)) { val = ((IndexFieldKey) obj).getIndex() == getIndex(); } return val; } /** *

This provides a hash for instances of this class.

*/ public int hashCode() { if (_hash == -1) { // Use the hashCode() of the String (id + index) _hash = (getFieldId() + getIndex()).hashCode(); } return _hash; } /** *

The toString() implementation. This implementation prints out * the index and fieldId:

* *

IndexFieldKey[<index>][<id>] *

*/ public String toString() { return "IndexFieldKey[" + getIndex() + "][" + getFieldId() + "]"; // NOI18N } /** *

Storate for the index.

*/ private int _index = -1; private transient int _hash = -1; }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy