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