OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [classpath/] [gnu/] [java/] [util/] [regex/] [REException.java] - Blame information for rev 769

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 769 jeremybenn
/* gnu/regexp/REException.java
2
   Copyright (C) 1998-2001, 2004 Free Software Foundation, Inc.
3
 
4
This file is part of GNU Classpath.
5
 
6
GNU Classpath is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2, or (at your option)
9
any later version.
10
 
11
GNU Classpath is distributed in the hope that it will be useful, but
12
WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with GNU Classpath; see the file COPYING.  If not, write to the
18
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
02110-1301 USA.
20
 
21
Linking this library statically or dynamically with other modules is
22
making a combined work based on this library.  Thus, the terms and
23
conditions of the GNU General Public License cover the whole
24
combination.
25
 
26
As a special exception, the copyright holders of this library give you
27
permission to link this library with independent modules to produce an
28
executable, regardless of the license terms of these independent
29
modules, and to copy and distribute the resulting executable under
30
terms of your choice, provided that you also meet, for each linked
31
independent module, the terms and conditions of the license of that
32
module.  An independent module is a module which is not derived from
33
or based on this library.  If you modify this library, you may extend
34
this exception to your version of the library, but you are not
35
obligated to do so.  If you do not wish to do so, delete this
36
exception statement from your version. */
37
 
38
package gnu.java.util.regex;
39
 
40
import gnu.java.lang.CPStringBuilder;
41
 
42
import java.text.MessageFormat;
43
 
44
/**
45
 * This is the regular expression exception class.  An exception of this type
46
 * defines the three attributes:
47
 * <OL>
48
 * <LI> A descriptive message of the error.
49
 * <LI> An integral type code equivalent to one of the statically
50
 *      defined symbols listed below.
51
 * <LI> The approximate position in the input string where the error
52
 *      occurred.
53
 * </OL>
54
 *
55
 * @author <A HREF="mailto:wes@cacas.org">Wes Biggs</A>
56
 */
57
 
58
public class REException extends Exception
59
{
60
  private int type;
61
  private int pos;
62
 
63
  // Error conditions from GNU regcomp(3) manual
64
 
65
  /**
66
   * Error flag.
67
   * Invalid use of repetition operators such  as  using
68
   * `*' as the first character.
69
   */
70
  public static final int REG_BADRPT = 1;
71
 
72
  /**
73
   * Error flag.
74
   * Invalid use of back reference operator.
75
   */
76
  public static final int REG_BADBR = 2;
77
 
78
  /**
79
   * Error flag.
80
   * Un-matched brace interval operators.
81
   */
82
  public static final int REG_EBRACE = 3;
83
 
84
  /**
85
   * Error flag.
86
   * Un-matched bracket list operators.
87
   */
88
  public static final int REG_EBRACK = 4;
89
 
90
  /**
91
   * Error flag.
92
   * Invalid  use  of the range operator, eg. the ending
93
   * point of the range occurs  prior  to  the  starting
94
   * point.
95
   */
96
  public static final int REG_ERANGE = 5;
97
 
98
  /**
99
   * Error flag.
100
   * Unknown character class name. <B>Not implemented</B>.
101
   */
102
  public static final int REG_ECTYPE = 6;
103
 
104
  /**
105
   * Error flag.
106
   * Un-matched parenthesis group operators.
107
   */
108
  public static final int REG_EPAREN = 7;
109
 
110
  /**
111
   * Error flag.
112
   * Invalid back reference to a subexpression.
113
   */
114
  public static final int REG_ESUBREG = 8;
115
 
116
  /**
117
   * Error flag.
118
   * Non specific error. <B>Not implemented</B>.
119
   */
120
  public static final int REG_EEND = 9;
121
 
122
  /**
123
   * Error flag.
124
   * Invalid escape sequence. <B>Not implemented</B>.
125
   */
126
  public static final int REG_ESCAPE = 10;
127
 
128
  /**
129
   * Error flag.
130
   * Invalid  use  of pattern operators such as group or list.
131
   */
132
  public static final int REG_BADPAT = 11;
133
 
134
  /**
135
   * Error flag.
136
   * Compiled  regular  expression  requires  a  pattern
137
   * buffer larger than 64Kb. <B>Not implemented</B>.
138
   */
139
  public static final int REG_ESIZE = 12;
140
 
141
  /**
142
   * Error flag.
143
   * The regex routines ran out of memory. <B>Not implemented</B>.
144
   */
145
  public static final int REG_ESPACE = 13;
146
 
147
    REException (String msg, int type, int position)
148
  {
149
    super (msg);
150
    this.type = type;
151
    this.pos = position;
152
  }
153
 
154
  REException (String msg, Throwable cause, int type, int position)
155
  {
156
    super (msg, cause);
157
    this.type = type;
158
    this.pos = position;
159
  }
160
 
161
  /**
162
   * Returns the type of the exception, one of the constants listed above.
163
   */
164
 
165
  public int getType ()
166
  {
167
    return type;
168
  }
169
 
170
  /**
171
   * Returns the position, relative to the string or character array being
172
   * compiled, where the error occurred.  This position is generally the point
173
   * where the error was detected, not necessarily the starting index of
174
   * a bad subexpression.
175
   */
176
  public int getPosition ()
177
  {
178
    return pos;
179
  }
180
 
181
  /**
182
   * Reports the descriptive message associated with this exception
183
   * as well as its index position in the string or character array
184
   * being compiled.
185
   */
186
  public String getMessage ()
187
  {
188
    Object[]args =
189
    {
190
    new Integer (pos)};
191
    CPStringBuilder sb = new CPStringBuilder ();
192
    String prefix = RE.getLocalizedMessage ("error.prefix");
193
    sb.append (MessageFormat.format (prefix, args));
194
    sb.append ('\n');
195
    sb.append (super.getMessage ());
196
    return sb.toString ();
197
  }
198
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.