| Class | Line # | Actions | |||
|---|---|---|---|---|---|
| Start | 13 | 11 | 11 |
| 1 | // | |
| 2 | // This software is now distributed according to | |
| 3 | // the Lesser Gnu Public License. Please see | |
| 4 | // http://www.gnu.org/copyleft/lesser.txt for | |
| 5 | // the details. | |
| 6 | // -- Happy Computing! | |
| 7 | // | |
| 8 | package com.stevesoft.pat; | |
| 9 | ||
| 10 | import java.util.Hashtable; | |
| 11 | ||
| 12 | /** The '^' or the '\A' Pattern, matches the start of a string. */ | |
| 13 | class Start extends Pattern | |
| 14 | { | |
| 15 | boolean retIsStart; | |
| 16 | ||
| 17 | 0 | Start(boolean b) |
| 18 | { | |
| 19 | 0 | retIsStart = b; |
| 20 | } | |
| 21 | ||
| 22 | 0 | public int matchInternal(int pos, Pthings pt) |
| 23 | { | |
| 24 | 0 | if (retIsStart && pt.mFlag && pos > 0 && pt.src.charAt(pos - 1) == '\n') |
| 25 | { | |
| 26 | 0 | return nextMatch(pos, pt); |
| 27 | } | |
| 28 | 0 | if (pos == 0) |
| 29 | { | |
| 30 | 0 | return nextMatch(pos, pt); |
| 31 | } | |
| 32 | 0 | return -1; |
| 33 | } | |
| 34 | ||
| 35 | 0 | public String toString() |
| 36 | { | |
| 37 | 0 | if (retIsStart) |
| 38 | { | |
| 39 | 0 | return "^" + nextString(); |
| 40 | } | |
| 41 | else | |
| 42 | { | |
| 43 | 0 | return "\\A" + nextString(); |
| 44 | } | |
| 45 | } | |
| 46 | ||
| 47 | 0 | public patInt maxChars() |
| 48 | { | |
| 49 | 0 | return new patInt(0); |
| 50 | } | |
| 51 | ||
| 52 | 0 | Pattern clone1(Hashtable h) |
| 53 | { | |
| 54 | 0 | return new Start(retIsStart); |
| 55 | } | |
| 56 | }; |