Subversion Repositories XServices

Compare Revisions

No changes between revisions

Ignore whitespace Rev 85 → Rev 86

/xservices/trunk/src/java/net/brutex/xservices/types/StringReplaceType.java
0,0 → 1,37
/*
* Copyright 2012 Brian Rosenberger (Brutex Network)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
 
package net.brutex.xservices.types;
 
import javax.xml.bind.annotation.XmlType;
 
 
 
/**
*
* @author Brian Rosenberger, bru@brutex.de
*/
@XmlType
public class StringReplaceType {
public String string;
public int count;
public StringReplaceType() {}
public StringReplaceType(String string, int count) {
this();
this.string = string;
this.count = count;
}
}
Property changes:
Added: svn:mime-type
+text/plain
\ No newline at end of property
/xservices/trunk/src/java/net/brutex/xservices/ws/impl/StringServiceImpl.java
0,0 → 1,61
/*
* Copyright 2012 Brian Rosenberger (Brutex Network)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.brutex.xservices.ws.impl;
 
 
 
import java.util.regex.Matcher;
import java.util.regex.Pattern;
 
import javax.jws.WebService;
 
import net.brutex.xservices.types.StringReplaceType;
import net.brutex.xservices.util.BrutexNamespaces;
import net.brutex.xservices.ws.StringService;
import net.brutex.xservices.ws.XServicesFault;
 
/**
* @author Brian Rosenberger
* @since 0.5.0
*
*/
@WebService(targetNamespace = BrutexNamespaces.WS_XSERVICES, endpointInterface = "net.brutex.xservices.ws.StringService", serviceName = StringService.SERVICE_NAME)
public class StringServiceImpl implements StringService {
 
public StringReplaceType replaceRegEx(String res, String search, String replace,
String flags) throws XServicesFault {
int allflags = 0;
if(flags.contains("i")) {
allflags = allflags + Pattern.CASE_INSENSITIVE;
}
Pattern pattern = Pattern.compile(search, allflags);
Matcher matcher = pattern.matcher(res);
int count = 0;
while( matcher.find()) {
count++;
}
if(flags.contains("g")) {
return new StringReplaceType(matcher.replaceAll(replace), count);
} else {
if(count>1) count = 1;
return new StringReplaceType(matcher.replaceFirst(replace), count);
}
}
 
}
Property changes:
Added: svn:mime-type
+text/plain
\ No newline at end of property
/xservices/trunk/src/java/net/brutex/xservices/ws/StringService.java
0,0 → 1,71
/*
* Copyright 2012 Brian Rosenberger (Brutex Network)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
 
package net.brutex.xservices.ws;
 
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
 
import net.brutex.xservices.types.ReturnCode;
import net.brutex.xservices.types.StringReplaceType;
import net.brutex.xservices.types.TargetNodeType;
import net.brutex.xservices.types.ant.AttachmentType;
import net.brutex.xservices.types.ant.CollectionType;
import net.brutex.xservices.types.ant.FileResource;
import net.brutex.xservices.util.BrutexNamespaces;
 
import org.apache.cxf.annotations.WSDLDocumentation;
 
/**
* String operation services.
* @author Brian Rosenberger
* @since 0.5.0
*
*/
@WebService(targetNamespace = BrutexNamespaces.WS_XSERVICES)
public interface StringService {
public static final String SERVICE_NAME = "StringService";
final String OPERATION_REPLACEREGEX = "replaceRegEx";
 
 
final static String PARAM_STRING = "string";
final static String PARAM_SEARCH = "search";
final static String PARAM_REPLACE = "replace";
final static String PARAM_FLAGS = "regexflags";
;
/**
* String replace using regular expression.
* @param res String
* @param search regex search pattern
* @param replace string replacement
* @param flags regex flags
*
* @return replacement
* @throws XServicesFault
*/
@WebMethod(operationName=OPERATION_REPLACEREGEX)
@WSDLDocumentation(value="Store text based data")
public abstract StringReplaceType replaceRegEx(
@WebParam(name = PARAM_STRING) String res,
@WebParam(name = PARAM_SEARCH) String search,
@WebParam(name = PARAM_REPLACE) String replace,
@WebParam(name = PARAM_FLAGS) String flags) throws XServicesFault;
}
Property changes:
Added: svn:mime-type
+text/plain
\ No newline at end of property
/xservices/trunk/web/WEB-INF/cxf-beans.xml
55,6 → 55,10
implementor="net.brutex.xservices.ws.impl.MiscServiceImpl" address="/MiscService">
</jaxws:endpoint>
 
<jaxws:endpoint id="stringservice"
implementor="net.brutex.xservices.ws.impl.StringServiceImpl" address="/StringService">
</jaxws:endpoint>
<jaxws:endpoint id="storageservice"
implementor="net.brutex.xservices.ws.impl.StorageServiceImpl" address="/StorageService">
</jaxws:endpoint>