01: /*
02: (c) Copyright 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP, all rights reserved.
03: [See end of file]
04: $Id: SimpleGenerator.java,v 1.12 2008/01/02 12:06:04 andy_seaborne Exp $
05: */
06:
07: package com.hp.hpl.jena.graph.query.regexptrees;
08:
09: import java.util.List;
10:
11: /**
12: The base implementation of <code>RegexpTreeGenerator</code>
13: @author hedgehog
14: */
15: public class SimpleGenerator implements RegexpTreeGenerator {
16: public RegexpTree getAnySingle() {
17: return RegexpTree.ANY;
18: }
19:
20: public RegexpTree getStartOfLine() {
21: return RegexpTree.SOL;
22: }
23:
24: public RegexpTree getEndOfLine() {
25: return RegexpTree.EOL;
26: }
27:
28: public RegexpTree getNothing() {
29: return RegexpTree.NON;
30: }
31:
32: public RegexpTree getText(char ch) {
33: return Text.create(ch);
34: }
35:
36: public RegexpTree getZeroOrMore(RegexpTree d) {
37: return new ZeroOrMore(d);
38: }
39:
40: public RegexpTree getOneOrMore(RegexpTree d) {
41: return new OneOrMore(d);
42: }
43:
44: public RegexpTree getOptional(RegexpTree d) {
45: return new Optional(d);
46: }
47:
48: public RegexpTree getSequence(List operands) {
49: return Sequence.create(operands);
50: }
51:
52: public RegexpTree getAlternatives(List operands) {
53: return Alternatives.create(operands);
54: }
55:
56: public RegexpTree getBackReference(int n) {
57: return new BackReference(n);
58: }
59:
60: public RegexpTree getClass(String chars, boolean reject) {
61: return reject ? (RegexpTree) new NoneOf(chars) : new AnyOf(
62: chars);
63: }
64:
65: public RegexpTree getParen(RegexpTree operand, int index) {
66: return new Paren(operand, index);
67: }
68: }
69:
70: /*
71: (c) Copyright 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
72: All rights reserved.
73:
74: Redistribution and use in source and binary forms, with or without
75: modification, are permitted provided that the following conditions
76: are met:
77:
78: 1. Redistributions of source code must retain the above copyright
79: notice, this list of conditions and the following disclaimer.
80:
81: 2. Redistributions in binary form must reproduce the above copyright
82: notice, this list of conditions and the following disclaimer in the
83: documentation and/or other materials provided with the distribution.
84:
85: 3. The name of the author may not be used to endorse or promote products
86: derived from this software without specific prior written permission.
87:
88: THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
89: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
90: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
91: IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
92: INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
93: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
94: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
95: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
96: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
97: THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
98: */
|