001// 002// Name 003// $RCSfile: KeyFieldValueRangeList.java,v $ 004// 005// Copyright 006// Confidential Property of Kabira Technologies, Inc. 007// Copyright 2009, 2010 by Kabira Technologies, Inc. 008// All rights reserved. 009// 010// History 011// $Revision: 1.1.2.3 $ $Date: 2010/05/11 23:50:43 $ 012// 013package com.kabira.platform; 014 015import java.util.ArrayList; 016 017/** 018 * Class used to manage field values with ranges. 019 */ 020public class KeyFieldValueRangeList 021{ 022 /** 023 * Creates a KeyFieldValueRangeList instance. 024 */ 025 public KeyFieldValueRangeList() 026 { 027 m_entries = new ArrayList<FieldEntry>(); 028 } 029 030 /** 031 * Adds a field that is part of a range query. 032 * 033 * @param fieldName The field name. 034 * @param value The value to use. 035 * 036 * @exception KeyNullValueError 037 * The given value is null. 038 * <p> 039 * When executed, this forms one element of a range query. Multiple 040 * add() calls are and'd together to compose a complete query. 041 */ 042 public void add( 043 String fieldName, Object value, 044 KeyComparisonOperator comparisonOperator) 045 throws KeyNullValueError 046 { 047 if (value == null) 048 { 049 throw new KeyNullValueError( 050 "Null value for field " + fieldName + 051 ", keys cannot have null values"); 052 } 053 FieldEntry f = new FieldEntry(); 054 055 f.m_name = fieldName; 056 f.m_value = value; 057 f.m_op = comparisonOperator; 058 059 m_entries.add(f); 060 } 061 062 /** 063 * Removes all fields from the list. 064 */ 065 public void clear() 066 { 067 m_entries.clear(); 068 } 069 070 ArrayList<FieldEntry> getEntries() 071 { 072 return new ArrayList<FieldEntry>(m_entries); 073 } 074 075 ArrayList<FieldEntry> m_entries; 076}