diff options
Diffstat (limited to 'rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/shells/OutputPattern.java')
-rw-r--r-- | rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/shells/OutputPattern.java | 100 |
1 files changed, 0 insertions, 100 deletions
diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/shells/OutputPattern.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/shells/OutputPattern.java deleted file mode 100644 index b07c0727a..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/shells/OutputPattern.java +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2001, 2007 IBM Corporation and International Business Machines Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - Moved from org.eclipse.rse.services.shells - ********************************************************************************/ - -package org.eclipse.rse.internal.services.shells; - -import java.util.ArrayList; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.eclipse.rse.services.shells.ParsedOutput; - -public class OutputPattern -{ - - - private Pattern _pattern; - private String _objType; - private ArrayList _matchOrder; - - public OutputPattern(String objType, String matchOrder, Pattern thePattern) - { - _objType = objType; - _pattern = thePattern; - - _matchOrder = new ArrayList(); - //Here we add a dummy first element to the ArrayList, to mimick how the PatternMatcher stores it's - //matches (starting with group 1). - _matchOrder.add(null); - - int index = 0; - int nextSpace = 0; - //Walk the matchOrder string parsing out words and adding them to _matchOrder...Could use StringTokenizer - //but this seem much simpler. - while ((nextSpace = matchOrder.indexOf(" ", index)) > 0) //$NON-NLS-1$ - { - _matchOrder.add(matchOrder.substring(index, nextSpace).toLowerCase()); - index = nextSpace; - while ((index < matchOrder.length()) && (matchOrder.charAt(index) == ' ')) - index++; - } - _matchOrder.add(matchOrder.substring(index, matchOrder.length()).toLowerCase()); - - } - - public ParsedOutput matchLine(String theLine) - { - Matcher matcher = null; - try - { - matcher = _pattern.matcher(theLine); - if (!matcher.matches()) - return null; - } - catch (StringIndexOutOfBoundsException e) - { - //Getting an exception here, when theLine is an empty line for some patterns..should probably investigate, - //but for now we'll just handle it... - return null; - } - - String fileString = ""; //$NON-NLS-1$ - String lineString = ""; //$NON-NLS-1$ - //Groups start at 1 (group 0 is the entire match). - for (int i = 1; i < _matchOrder.size(); i++) - { - String mStr = (String)_matchOrder.get(i); - if (mStr.equals("file")) //$NON-NLS-1$ - fileString = matcher.group(i); - else if (mStr.equals("line")) //$NON-NLS-1$ - lineString = matcher.group(i); - } - int line = 1; - if (lineString.length() > 0) - { - try - { - line = Integer.parseInt(lineString); - } - catch (NumberFormatException e) - { - } - } - - return new ParsedOutput(_objType, theLine, fileString, line, 1); - } - -}
\ No newline at end of file |