001 /* 002 // This software is subject to the terms of the Common Public License 003 // Agreement, available at the following URL: 004 // http://www.opensource.org/licenses/cpl.html. 005 // Copyright (C) 2007-2008 Julian Hyde 006 // All Rights Reserved. 007 // You must accept the terms of that agreement to use this software. 008 */ 009 package mondrian.calc; 010 011 import java.util.List; 012 import java.util.Arrays; 013 014 /** 015 * Enumeration of ways that a compiled expression can return its result to 016 * its caller. 017 * 018 * @version $Id: //open/mondrian/src/main/mondrian/calc/ResultStyle.java#3 $ 019 * @author jhyde 020 */ 021 public enum ResultStyle { 022 /** 023 * Indicates that caller will accept any applicable style. 024 */ 025 ANY, 026 027 /** 028 * Indicates that the expression returns its result as a list which may 029 * safely be modified by the caller. 030 */ 031 MUTABLE_LIST, 032 033 /** 034 * Indicates that the expression returns its result as a list which must 035 * not be modified by the caller. 036 */ 037 LIST, 038 039 /** 040 * Indicates that the expression returns its result as an Iterable 041 * which must not be modified by the caller. 042 */ 043 ITERABLE, 044 045 /** 046 * Indicates that the expression results its result as an immutable 047 * value. This is typical for expressions which return string, datetime and 048 * numeric values. 049 */ 050 VALUE, 051 052 /** 053 * Indicates that the expression results its result as an immutable 054 * value which will never be null. This is typical for expressions which 055 * return string, datetime and numeric values. 056 */ 057 VALUE_NOT_NULL; 058 059 // --------------------------------------------------------------- 060 // There follow a set of convenience constants for commonly-used 061 // collections of result styles. 062 063 public static final List<ResultStyle> ANY_LIST = 064 Arrays.asList( 065 ANY); 066 067 public static final List<ResultStyle> ITERABLE_ONLY = 068 Arrays.asList( 069 ITERABLE); 070 071 public static final List<ResultStyle> MUTABLELIST_ONLY = 072 Arrays.asList( 073 MUTABLE_LIST); 074 075 public static final List<ResultStyle> LIST_ONLY = 076 Arrays.asList( 077 LIST); 078 079 public static final List<ResultStyle> ITERABLE_ANY = 080 Arrays.asList( 081 ITERABLE, 082 ANY); 083 084 public static final List<ResultStyle> ITERABLE_LIST = 085 Arrays.asList( 086 ITERABLE, 087 LIST); 088 089 public static final List<ResultStyle> ITERABLE_MUTABLELIST = 090 Arrays.asList( 091 ITERABLE, 092 MUTABLE_LIST); 093 094 public static final List<ResultStyle> ITERABLE_LIST_MUTABLELIST = 095 Arrays.asList( 096 ITERABLE, 097 LIST, 098 MUTABLE_LIST); 099 100 public static final List<ResultStyle> LIST_MUTABLELIST = 101 Arrays.asList( 102 LIST, 103 MUTABLE_LIST); 104 105 public static final List<ResultStyle> MUTABLELIST_LIST = 106 Arrays.asList( 107 MUTABLE_LIST, 108 LIST); 109 110 public static final List<ResultStyle> ITERABLE_LIST_MUTABLELIST_ANY = 111 Arrays.asList( 112 ITERABLE, 113 LIST, 114 MUTABLE_LIST, 115 ANY); 116 117 public static final List<ResultStyle> ITERABLE_MUTABLELIST_LIST = 118 Arrays.asList( 119 ITERABLE, 120 MUTABLE_LIST, 121 LIST); 122 } 123 124 // End ResultStyle.java