package votorola.g.web.gwt; // Copyright 2012, Michael Allan. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Votorola Software"), to deal in the Votorola Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Votorola Software, and to permit persons to whom the Votorola Software is furnished to do so, subject to the following conditions: The preceding copyright notice and this permission notice shall be included in all copies or substantial portions of the Votorola Software. THE VOTOROLA SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE VOTOROLA SOFTWARE OR THE USE OR OTHER DEALINGS IN THE VOTOROLA SOFTWARE. import java.util.regex.MatchResult; /** A partial implementation of match result that never sets an empty string for a group * value in lieu of a null value. This is intended to eliminate client variance in cases * where an empty string is not expected in the result. For example, {@linkplain * com.google.gwt.regexp.shared.MatchResult#getGroup(int) GWT's API} says, "If the given * group was optional and did not match, the behavior is browser-dependent". */ public final class MatchResultNE implements MatchResult { /** Constructs a MatchResultNE. */ public MatchResultNE( com.google.gwt.regexp.shared.MatchResult _m ) { m = _m; } // - M a t c h - R e s u l t ---------------------------------------------------------- public int end() { return start() + group().length(); } /** Throws {@linkplain UnsupportedOperationException UnsupportedOperationException}. */ public int end( int g ) { throw new UnsupportedOperationException(); } public String group() { return m.getGroup( 0 ); } public String group( int g ) { String s = m.getGroup( g ); if( g > 0 && s != null && s.length() == 0 ) s = null; return s; } public int groupCount() { return m.getGroupCount() - 1; } public int start() { return m.getIndex(); } /** Throws {@linkplain UnsupportedOperationException UnsupportedOperationException}. */ public int start( int g ) { throw new UnsupportedOperationException(); } //// P r i v a t e /////////////////////////////////////////////////////////////////////// private final com.google.gwt.regexp.shared.MatchResult m; }