PageRenderTime 28ms CodeModel.GetById 19ms app.highlight 8ms RepoModel.GetById 0ms app.codeStats 0ms

/libformula-1.1.3/source/org/pentaho/reporting/libraries/formula/typing/DefaultType.java

#
Java | 94 lines | 61 code | 10 blank | 23 comment | 10 complexity | 7049699f896f0dfbea41a8c261761b09 MD5 | raw file
Possible License(s): LGPL-2.1
 1/*
 2 * This program is free software; you can redistribute it and/or modify it under the
 3 * terms of the GNU Lesser General Public License, version 2.1 as published by the Free Software
 4 * Foundation.
 5 *
 6 * You should have received a copy of the GNU Lesser General Public License along with this
 7 * program; if not, you can obtain a copy at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
 8 * or from the Free Software Foundation, Inc.,
 9 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU Lesser General Public License for more details.
14 *
15 * Copyright (c) 2006 - 2009 Pentaho Corporation and Contributors.  All rights reserved.
16 */
17
18package org.pentaho.reporting.libraries.formula.typing;
19
20import java.util.HashMap;
21import java.util.HashSet;
22
23/**
24 * Creation-Date: 02.11.2006, 09:37:54
25 *
26 * @author Thomas Morgner
27 */
28public abstract class DefaultType implements Type
29{
30  private HashSet flags;
31  private HashMap properties;
32  private boolean locked;
33  private static final long serialVersionUID = -8206983276033867416L;
34
35  protected DefaultType()
36  {
37  }
38
39  public boolean isLocked()
40  {
41    return locked;
42  }
43
44  public void lock()
45  {
46    this.locked = true;
47  }
48
49  public void addFlag(final String name)
50  {
51    if (locked)
52    {
53      throw new IllegalStateException();
54    }
55    if (flags == null)
56    {
57      flags = new HashSet();
58    }
59    flags.add(name);
60  }
61
62  public boolean isFlagSet(final String name)
63  {
64    if (flags == null)
65    {
66      return false;
67    }
68    return flags.contains(name);
69  }
70
71  public void setProperty(final String name, final Object value)
72  {
73    if (locked)
74    {
75      throw new IllegalStateException();
76    }
77    if (properties == null)
78    {
79      properties = new HashMap();
80    }
81    properties.put(name, value);
82  }
83
84  public Object getProperty(final String name)
85  {
86    // The type system has no properties yet. This is done later, when we
87    // deal with real meta-data
88    if (properties == null)
89    {
90      return null;
91    }
92    return properties.get(name);
93  }
94}