001: /*
002: * Copyright Aduna (http://www.aduna-software.com/) (c) 2008.
003: *
004: * Licensed under the Aduna BSD-style license.
005: */
006: package org.openrdf.sail.rdbms.schema;
007:
008: /**
009: * A bit array of the possible value types that have been stored in an object
010: * column.
011: *
012: * @author James Leigh
013: *
014: */
015: public class ValueTypes implements Cloneable {
016: public static ValueTypes UNKNOWN = new ValueTypes();
017: static {
018: UNKNOWN.bnodes = true;
019: UNKNOWN.uris = true;
020: UNKNOWN.literals = true;
021: UNKNOWN.typed = true;
022: UNKNOWN.numeric = true;
023: UNKNOWN.calendar = true;
024: UNKNOWN.languages = true;
025: UNKNOWN.longValues = true;
026: }
027: public static ValueTypes RESOURCE = new ValueTypes();
028: static {
029: RESOURCE.bnodes = true;
030: RESOURCE.uris = true;
031: RESOURCE.longValues = true;
032: }
033: public static ValueTypes URI = new ValueTypes();
034: static {
035: URI.uris = true;
036: URI.longValues = true;
037: }
038: private boolean bnodes;
039: private boolean uris;
040: private boolean literals;
041: private boolean typed;
042: private boolean numeric;
043: private boolean calendar;
044: private boolean languages;
045: private boolean longValues;
046:
047: public boolean isBNodes() {
048: return bnodes;
049: }
050:
051: public boolean isURIs() {
052: return uris;
053: }
054:
055: public boolean isLiterals() {
056: return literals;
057: }
058:
059: public boolean isTyped() {
060: return typed;
061: }
062:
063: public boolean isNumeric() {
064: return numeric;
065: }
066:
067: public boolean isCalendar() {
068: return calendar;
069: }
070:
071: public boolean isLanguages() {
072: return languages;
073: }
074:
075: public boolean isLong() {
076: return longValues;
077: }
078:
079: public void reset() {
080: bnodes = false;
081: uris = false;
082: literals = false;
083: typed = false;
084: numeric = false;
085: calendar = false;
086: languages = false;
087: longValues = false;
088: }
089:
090: public void add(ValueType code) {
091: bnodes |= code.isBNode();
092: uris |= code.isURI();
093: literals |= code.isLiteral();
094: typed |= code.isTypedLiteral();
095: numeric |= code.isNumericLiteral();
096: calendar |= code.isCalendarLiteral();
097: languages |= code.isLanguageLiteral();
098: longValues |= code.isLong();
099: }
100:
101: public ValueTypes merge(ValueTypes valueTypes) {
102: bnodes |= valueTypes.bnodes;
103: uris |= valueTypes.uris;
104: literals |= valueTypes.literals;
105: typed |= valueTypes.typed;
106: numeric |= valueTypes.numeric;
107: calendar |= valueTypes.calendar;
108: languages |= valueTypes.languages;
109: longValues |= valueTypes.longValues;
110: return this ;
111: }
112:
113: @Override
114: public ValueTypes clone() {
115: try {
116: return (ValueTypes) super .clone();
117: } catch (CloneNotSupportedException e) {
118: throw new AssertionError();
119: }
120: }
121: }
|