[jboss-cvs] jbosside/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util ...
Robert Stryker
rawblem at gmail.com
Thu Nov 9 19:26:26 EST 2006
User: rawb
Date: 06/11/09 19:26:26
Modified: as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util
FileUtil.java
Added: as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util
SimpleTreeItem.java ArgsUtil.java
Log:
Rewrote Core entirley. It's clean and spiffy now.
Revision Changes Path
1.2 +4 -6 jbosside/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/FileUtil.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: FileUtil.java
===================================================================
RCS file: /cvsroot/jboss/jbosside/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/FileUtil.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- FileUtil.java 13 Jul 2006 04:02:39 -0000 1.1
+++ FileUtil.java 10 Nov 2006 00:26:26 -0000 1.2
@@ -1,10 +1,10 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
- * This is free software; you can redistribute it and/or modify it
+* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
@@ -24,8 +24,6 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
1.1 date: 2006/11/10 00:26:26; author: rawb; state: Exp;jbosside/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/SimpleTreeItem.java
Index: SimpleTreeItem.java
===================================================================
/**
* JBoss, a Division of Red Hat
* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.ide.eclipse.as.core.util;
import java.util.ArrayList;
import java.util.HashMap;
public class SimpleTreeItem {
protected ArrayList children;
protected HashMap properties;
protected SimpleTreeItem parent;
protected Object data;
public SimpleTreeItem(SimpleTreeItem parent, Object data) {
children = new ArrayList();
properties = new HashMap();
this.data = data;
this.parent = parent;
if( parent != null ) parent.addChild(this);
}
public SimpleTreeItem[] getChildren2() {
SimpleTreeItem[] arr = new SimpleTreeItem[children.size()];
children.toArray(arr);
return arr;
}
public SimpleTreeItem getParent() {
return parent;
}
public void addChild(SimpleTreeItem item) {
if( !children.contains(item)) {
children.add(item);
item.setParent(this);
}
}
public void addChild(int loc, SimpleTreeItem item) {
children.add(loc, item);
}
public void deleteChildren() {
children.clear();
}
public void deleteChild(SimpleTreeItem o) {
children.remove(o);
}
public void setProperty( Object key, Object val ) {
properties.put(key, val);
}
public Object getProperty(Object key) {
return properties.get(key);
}
public HashMap getProperties() {
return properties;
}
public void setParent(SimpleTreeItem parent) {
this.parent = parent;
}
public Object getData() {
return this.data;
}
public void setData(Object data) {
this.data = data;
}
public void addChildren(SimpleTreeItem[] kids) {
for( int i = 0; i < kids.length; i++ ) {
addChild(kids[i]);
}
}
}
1.1 date: 2006/11/10 00:26:26; author: rawb; state: Exp;jbosside/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ArgsUtil.java
Index: ArgsUtil.java
===================================================================
/**
* JBoss, a Division of Red Hat
* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.ide.eclipse.as.core.util;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
public class ArgsUtil {
public static final Integer NO_VALUE = new Integer(-1);
// public static String getCommandArgument(String args,
// String primaryPrefix, String secondaryPrefix) {
//
// String[] argArray = parse(args);
//
// // system property is different. Do them first.
// if( primaryPrefix.startsWith("-D")) {
// for( int i = 0; i < argArray.length; i++ ) {
// if( argArray[i].startsWith(primaryPrefix)) {
// int eqIndex = argArray[i].indexOf('=');
// if( eqIndex != -1 ) {
// return argArray[i].substring(eqIndex+1);
// } else if( argArray[i].equals(primaryPrefix)){
// // no value
// return "";
// }
// }
// }
// }
//
// for( int i = 0; i < argArray.length; i++ ) {
//
// // -c config
// if( argArray[i].equals(primaryPrefix)) {
// if( i+1 < argArray.length) {
// return argArray[i+1];
// } else {
// return "";
// }
// }
//
// if( argArray[i].startsWith(secondaryPrefix )) {
// int eqIndex = argArray[i].indexOf('=');
// if( eqIndex != -1 ) {
// return argArray[i].substring(eqIndex+1);
// }
// return "";
// }
// }
// return null;
// }
//
// public static String createCommandArguments(String haystack, String primaryPrefix,
// String secondaryPrefix, String newValue) {
//
// String[] asArray = parse(haystack);
// String retval = "";
// boolean found = false;
//
// for( int i = 0; i < asArray.length; i++ ) {
// if( primaryPrefix.startsWith("-D") && asArray[i].startsWith(primaryPrefix + "=")) {
// retval += primaryPrefix + "=" + newValue + " ";
// found = true;
// } else if( asArray[i].equals(primaryPrefix)) {
// retval += primaryPrefix + " " + newValue + " ";
// found = true;
// i++; // we're consuming two tokens, or should be
// } else if( asArray[i].startsWith(secondaryPrefix + '=')) {
// retval += secondaryPrefix + "=" + newValue + " ";
// found = true;
// } else {
// retval += asArray[i] + " ";
// }
// }
//
// if( !found ) {
// retval += primaryPrefix + " " + newValue + " ";
// }
//
// return retval;
// }
public static Map getSystemProperties(String s) {
String[] args = parse(s);
HashMap map = new HashMap();
for( int i = 0; i < args.length; i++ ) {
if( args[i].startsWith("-D")) {
int eq = args[i].indexOf('=');
if( eq != -1 ) {
map.put(args[i].substring(2, eq),
args[i].substring(eq+1));
} else {
map.put(args[i], NO_VALUE);
}
}
}
return map;
}
public static String[] parse(String s) {
try {
ArrayList l = new ArrayList();
int length = s.length();
int start = 0;
int current = 0;
boolean inQuotes = false;
boolean escaped = false;
boolean done = false;
String tmp = "";
StringBuffer buf = new StringBuffer();
while( !done ) {
switch(s.charAt(current)) {
// case '\\':
// if( inQuotes ) {
// current++;
// buf.append(s.charAt(current));
// break;
// }
case '"':
inQuotes = !inQuotes;
break;
case '\n':
case ' ':
if( !inQuotes ) {
tmp = buf.toString();
l.add(tmp);
start = current+1;
buf = new StringBuffer();
} else {
buf.append(' ');
}
break;
default:
buf.append(s.charAt(current));
break;
}
current++;
if( current == length ) done = true;
}
l.add(buf.toString());
Object[] lArr = l.toArray();
String[] retVal = new String[lArr.length];
for( int i = 0; i < lArr.length; i++ ) {
retVal[i] = (String)lArr[i];
}
return retVal;
} catch( Exception e ) {
return new String[] { };
}
}
}
More information about the jboss-cvs-commits
mailing list