Klaus Scherbach: Add handleStringList web service operation
git-svn-id: https://brutex.net/svn/xservices/trunk@195 e7e49efb-446e-492e-b9ec-fcafc1997a86master
parent
4895c0b265
commit
7ee16eb26c
|
@ -16,8 +16,6 @@
|
|||
|
||||
package net.brutex.xservices.ws;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.jws.WebMethod;
|
||||
import javax.jws.WebParam;
|
||||
import javax.jws.WebService;
|
||||
|
@ -81,4 +79,13 @@ public abstract interface StringService
|
|||
@WebParam(name="string") @XmlElement(required=true) String paramString)
|
||||
throws XServicesFault;
|
||||
|
||||
@WebMethod(operationName="handleStringLists")
|
||||
@WSDLDocumentation("Tokenizes all strings and then adds/removes tokens to/ from basestring")
|
||||
public abstract String handleStringLists(
|
||||
@WebParam(name="basestring") @XmlElement(required=true) String paramBaseString,
|
||||
@WebParam(name="addstring") @XmlElement(required=true) String paramAddString,
|
||||
@WebParam(name="removestring") @XmlElement(required=true) String paramRemoveString,
|
||||
@WebParam(name="delimiter") @XmlElement(required=true) String delimiter)
|
||||
throws XServicesFault;
|
||||
|
||||
}
|
|
@ -16,7 +16,8 @@
|
|||
|
||||
package net.brutex.xservices.ws.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -106,6 +107,30 @@ public class StringServiceImpl
|
|||
return value;
|
||||
}
|
||||
|
||||
public String handleStringLists(String basestring, String addstring, String removestring, String delimiter) throws XServicesFault {
|
||||
StringTokenizer base = new StringTokenizer(basestring, delimiter);
|
||||
StringTokenizer add = new StringTokenizer(addstring, delimiter);
|
||||
StringTokenizer remove = new StringTokenizer(removestring, delimiter);
|
||||
HashSet<String> hset = new HashSet<String>();
|
||||
String result = new String();
|
||||
|
||||
while(base.hasMoreTokens()) {
|
||||
hset.add(base.nextToken().toString() );
|
||||
}
|
||||
while(add.hasMoreTokens()) {
|
||||
hset.add(add.nextToken().toString() );
|
||||
}
|
||||
while(remove.hasMoreTokens()) {
|
||||
hset.remove(remove.nextToken().toString() );
|
||||
}
|
||||
Iterator<String> hsetit = hset.iterator();
|
||||
while(hsetit.hasNext()) {
|
||||
result = result.concat(hsetit.next().toString() + delimiter);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private int getFlags(String flags) {
|
||||
int allflags = 0;
|
||||
if (flags.contains("i")) {
|
||||
|
|
Loading…
Reference in New Issue