001: /***************************************************************
002: * This file is part of the [fleXive](R) project.
003: *
004: * Copyright (c) 1999-2008
005: * UCS - unique computing solutions gmbh (http://www.ucs.at)
006: * All rights reserved
007: *
008: * The [fleXive](R) project is free software; you can redistribute
009: * it and/or modify it under the terms of the GNU General Public
010: * License as published by the Free Software Foundation;
011: * either version 2 of the License, or (at your option) any
012: * later version.
013: *
014: * The GNU General Public License can be found at
015: * http://www.gnu.org/copyleft/gpl.html.
016: * A copy is found in the textfile GPL.txt and important notices to the
017: * license from the author are found in LICENSE.txt distributed with
018: * these libraries.
019: *
020: * This library is distributed in the hope that it will be useful,
021: * but WITHOUT ANY WARRANTY; without even the implied warranty of
022: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
023: * GNU General Public License for more details.
024: *
025: * For further information about UCS - unique computing solutions gmbh,
026: * please see the company website: http://www.ucs.at
027: *
028: * For further information about [fleXive](R), please see the
029: * project website: http://www.flexive.org
030: *
031: *
032: * This copyright notice MUST APPEAR in all copies of the file!
033: ***************************************************************/package com.flexive.shared.structure;
034:
035: import com.flexive.shared.FxSharedUtils;
036: import com.flexive.shared.ObjectWithLabel;
037: import com.flexive.shared.exceptions.FxNotFoundException;
038: import com.flexive.shared.value.FxString;
039:
040: import java.io.Serializable;
041:
042: /**
043: * Mode of a FxType (Content or Relation)
044: *
045: * @author Markus Plesser (markus.plesser@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
046: */
047: public enum TypeMode implements Serializable, ObjectWithLabel {
048:
049: /**
050: * FxType is a (regular) Content
051: */
052: Content(0),
053:
054: /**
055: * FxType is a relation
056: */
057: Relation(1),
058:
059: /**
060: * Dummy type used during bootstrap loading, DONT USE THIS!!!
061: */
062: Preload(-1);
063:
064: private int id;
065:
066: /**
067: * Ctor
068: *
069: * @param id id
070: */
071: TypeMode(int id) {
072: this .id = id;
073: }
074:
075: /**
076: * Getter for the internal id
077: *
078: * @return internal id
079: */
080: public int getId() {
081: return id;
082: }
083:
084: /**
085: * Get a TypeMode by its id
086: *
087: * @param id id
088: * @return TypeMode
089: * @throws FxNotFoundException if not found
090: */
091: public static TypeMode getById(int id) throws FxNotFoundException {
092: for (TypeMode mode : TypeMode.values())
093: if (mode.id == id)
094: return mode;
095: throw new FxNotFoundException(
096: "ex.structure.typeMode.notFound.id", id);
097: }
098:
099: /**
100: * {@inheritDoc}
101: */
102: public FxString getLabel() {
103: return FxSharedUtils.getEnumLabel(this);
104: }
105: }
|