01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 1997-2006.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.query.parser.serql.ast;
07:
08: public class ASTLiteral extends ASTValue {
09:
10: private String label;
11:
12: private String lang;
13:
14: public ASTLiteral(int id) {
15: super (id);
16: }
17:
18: public ASTLiteral(SyntaxTreeBuilder p, int id) {
19: super (p, id);
20: }
21:
22: @Override
23: public Object jjtAccept(SyntaxTreeBuilderVisitor visitor,
24: Object data) throws VisitorException {
25: return visitor.visit(this , data);
26: }
27:
28: public String getLabel() {
29: return label;
30: }
31:
32: public void setLabel(String label) {
33: this .label = label;
34: }
35:
36: public String getLang() {
37: return lang;
38: }
39:
40: public boolean hasLang() {
41: return lang != null;
42: }
43:
44: public void setLang(String lang) {
45: this .lang = lang;
46: }
47:
48: public ASTValueExpr getDatatypeNode() {
49: if (children.size() >= 1) {
50: return (ASTValueExpr) children.get(0);
51: }
52:
53: return null;
54: }
55:
56: @Override
57: public String toString() {
58: StringBuilder sb = new StringBuilder();
59:
60: sb.append(super .toString());
61:
62: sb.append(" (\"").append(label).append("\"");
63:
64: if (lang != null) {
65: sb.append('@').append(lang);
66: }
67:
68: sb.append(")");
69:
70: return sb.toString();
71: }
72: }
|