id stringlengths 7 14 | text stringlengths 1 106k |
|---|---|
1381874_5 | public <T> T get(String path, ResponseCallback<T> callback) {
HttpResponse hr = client.get(path);
return handleResponse(callback, hr);
} |
1381874_6 | public <T> T get(String path, ResponseCallback<T> callback) {
HttpResponse hr = client.get(path);
return handleResponse(callback, hr);
} |
1381874_7 | public <T> T get(String path, ResponseCallback<T> callback) {
HttpResponse hr = client.get(path);
return handleResponse(callback, hr);
} |
1381874_8 | public <T> T get(String path, ResponseCallback<T> callback) {
HttpResponse hr = client.get(path);
return handleResponse(callback, hr);
} |
1381874_9 | public void put(String path) {
handleVoidResponse(client.put(path));
} |
1382471_0 | public static boolean isProductized() {
return productized;
} |
1382471_1 | public List<String> getAllExtensions() {
final List<String> extensions = new LinkedList<>();
extensions.add(defaultExtension);
extensions.addAll(Arrays.asList(otherExtensions));
return Collections.unmodifiableList(extensions);
} |
1387581_0 | public static String getElementJavaType(QName element, String location, ResourceLocator locator) {
String ret=null;
try {
java.net.URI uri=locator.getResourceURI(location);
DocumentBuilderFactory fact=DocumentBuilderFactory.newInstance();
fact.setNamespaceAware(true);
DocumentBuilder builder=fact.newDocumentBuilder();
java.io.InputStream is=uri.toURL().openStream();
org.w3c.dom.Document doc=builder.parse(is);
is.close();
org.w3c.dom.NodeList elemList=
doc.getDocumentElement().getElementsByTagNameNS(
"http://www.w3.org/2001/XMLSchema", "element");
for (int i=0; i < elemList.getLength(); i++) {
org.w3c.dom.Element elem=(org.w3c.dom.Element)elemList.item(i);
String name=elem.getAttribute("name");
String elemType=elem.getAttribute("type");
if (!elem.hasAttribute("type")) {
// Assume element has an inline type definition, so use element name
elemType = name;
if (elemType.length() > 0) {
elemType = Character.toUpperCase(elemType.charAt(0))+elemType.substring(1);
}
}
if (name.equals(element.getLocalPart())) {
String prefix=org.savara.common.util.XMLUtils.getPrefix(elemType);
String ns=null;
if (prefix != null && prefix.trim().length() > 0) {
ns = elem.lookupNamespaceURI(prefix);
} else {
ns = elem.getOwnerDocument().getDocumentElement().getAttribute("targetNamespace");
}
ret = getJavaPackage(ns);
ret += "."+JavaGeneratorUtil.getJavaClassName(
org.savara.common.util.XMLUtils.getLocalname(elemType));
}
}
if (ret == null) {
org.w3c.dom.NodeList includeList=
doc.getDocumentElement().getElementsByTagNameNS(
"http://www.w3.org/2001/XMLSchema", "include");
for (int i=0; ret == null && i < includeList.getLength(); i++) {
org.w3c.dom.Element elem=(org.w3c.dom.Element)includeList.item(i);
String schemaLocation=elem.getAttribute("schemaLocation");
java.io.File f=new java.io.File(location);
if (f.getParentFile() != null) {
schemaLocation = f.getParentFile().getPath()+java.io.File.separator+schemaLocation;
}
ret = getElementJavaType(element, schemaLocation, locator);
}
}
} catch(Exception e) {
LOG.log(Level.SEVERE, "Failed to obtain XSD schema '"+location+"'", e);
}
return (ret);
} |
1387581_1 | public static String getElementJavaType(QName element, String location, ResourceLocator locator) {
String ret=null;
try {
java.net.URI uri=locator.getResourceURI(location);
DocumentBuilderFactory fact=DocumentBuilderFactory.newInstance();
fact.setNamespaceAware(true);
DocumentBuilder builder=fact.newDocumentBuilder();
java.io.InputStream is=uri.toURL().openStream();
org.w3c.dom.Document doc=builder.parse(is);
is.close();
org.w3c.dom.NodeList elemList=
doc.getDocumentElement().getElementsByTagNameNS(
"http://www.w3.org/2001/XMLSchema", "element");
for (int i=0; i < elemList.getLength(); i++) {
org.w3c.dom.Element elem=(org.w3c.dom.Element)elemList.item(i);
String name=elem.getAttribute("name");
String elemType=elem.getAttribute("type");
if (!elem.hasAttribute("type")) {
// Assume element has an inline type definition, so use element name
elemType = name;
if (elemType.length() > 0) {
elemType = Character.toUpperCase(elemType.charAt(0))+elemType.substring(1);
}
}
if (name.equals(element.getLocalPart())) {
String prefix=org.savara.common.util.XMLUtils.getPrefix(elemType);
String ns=null;
if (prefix != null && prefix.trim().length() > 0) {
ns = elem.lookupNamespaceURI(prefix);
} else {
ns = elem.getOwnerDocument().getDocumentElement().getAttribute("targetNamespace");
}
ret = getJavaPackage(ns);
ret += "."+JavaGeneratorUtil.getJavaClassName(
org.savara.common.util.XMLUtils.getLocalname(elemType));
}
}
if (ret == null) {
org.w3c.dom.NodeList includeList=
doc.getDocumentElement().getElementsByTagNameNS(
"http://www.w3.org/2001/XMLSchema", "include");
for (int i=0; ret == null && i < includeList.getLength(); i++) {
org.w3c.dom.Element elem=(org.w3c.dom.Element)includeList.item(i);
String schemaLocation=elem.getAttribute("schemaLocation");
java.io.File f=new java.io.File(location);
if (f.getParentFile() != null) {
schemaLocation = f.getParentFile().getPath()+java.io.File.separator+schemaLocation;
}
ret = getElementJavaType(element, schemaLocation, locator);
}
}
} catch(Exception e) {
LOG.log(Level.SEVERE, "Failed to obtain XSD schema '"+location+"'", e);
}
return (ret);
} |
1387581_2 | public void createServiceInterfaceFromWSDL(String wsdlPath, String wsdlLocation, String srcFolder) throws Exception {
String filePath=getXJCBindingFilePath();
String[] cxfargs=new String[]{
"-d", srcFolder,
"-wsdlLocation", wsdlLocation,
"-b", filePath,
wsdlPath
};
org.apache.cxf.tools.wsdlto.WSDLToJava wsdlToJava=new org.apache.cxf.tools.wsdlto.WSDLToJava(cxfargs);
try {
wsdlToJava.run(new ToolContext());
} catch(Exception e) {
logger.log(Level.SEVERE, "Failed to generate Java interfaces", e);
throw e;
}
} |
1387581_3 | public java.io.Serializable create(ProtocolId pid, ConversationId cid, Serializable session) {
if (pid == null) {
throw new IllegalArgumentException("Protocol id not specified");
} else if (cid == null) {
throw new IllegalArgumentException("Conversation instance id not specified");
}
addSession(pid, cid, session);
return(session);
} |
1387581_4 | public java.io.Serializable create(ProtocolId pid, ConversationId cid, Serializable session) {
if (pid == null) {
throw new IllegalArgumentException("Protocol id not specified");
} else if (cid == null) {
throw new IllegalArgumentException("Conversation instance id not specified");
}
addSession(pid, cid, session);
return(session);
} |
1387581_5 | public java.io.Serializable create(ProtocolId pid, ConversationId cid, Serializable session) {
if (pid == null) {
throw new IllegalArgumentException("Protocol id not specified");
} else if (cid == null) {
throw new IllegalArgumentException("Conversation instance id not specified");
}
addSession(pid, cid, session);
return(session);
} |
1387581_6 | public java.io.Serializable create(ProtocolId pid, ConversationId cid, Serializable session) {
if (pid == null) {
throw new IllegalArgumentException("Protocol id not specified");
} else if (cid == null) {
throw new IllegalArgumentException("Conversation instance id not specified");
}
addSession(pid, cid, session);
return(session);
} |
1387581_7 | public static void localizeRoleIntroductions(ProtocolModel pm) {
final java.util.List<Role> unused=new java.util.ArrayList<Role>();
pm.visit(new DefaultVisitor() {
public boolean start(Protocol p) {
java.util.Iterator<Activity> iter=p.getBlock().getContents().iterator();
while (iter.hasNext()) {
Activity act=iter.next();
if (act instanceof Introduces) {
Introduces rl=(Introduces)act;
for (int i=rl.getIntroducedRoles().size()-1; i >= 0; i--) {
Role r=rl.getIntroducedRoles().get(i);
Block b=RoleUtil.getEnclosingBlock(p, r, false);
if (b == null) {
// Report unused role
unused.add(r);
} else if (b != p.getBlock()) {
Introduces innerrl=null;
if (b.size() > 0 && b.get(0) instanceof Introduces &&
((Introduces)b.get(0)).getIntroducer().equals(rl.getIntroducer())) {
innerrl = (Introduces)b.get(0);
} else {
innerrl = new Introduces();
innerrl.setIntroducer(rl.getIntroducer());
b.getContents().add(0, innerrl);
}
rl.getIntroducedRoles().remove(r);
innerrl.getIntroducedRoles().add(r);
}
}
if (rl.getIntroducedRoles().size() == 0) {
iter.remove();
}
} else {
break;
}
}
return (true);
}
});
for (Role role : unused) {
if (role.getParent() instanceof Introduces) {
// Locate introduces
Introduces introduces=(Introduces)role.getParent();
Protocol protocol=introduces.getEnclosingProtocol();
locateRoleIntroductionWithinRun(protocol, role, introduces.getIntroducer());
introduces.getIntroducedRoles().remove(role);
if (introduces.getIntroducedRoles().size() == 0) {
((Block)introduces.getParent()).remove(introduces);
}
}
}
} |
1387581_8 | protected void mergePaths(java.util.List<Block> sourcePaths, Block targetPath,
FeedbackHandler handler) {
if (sourcePaths.size() == 0) {
return;
} else if (sourcePaths.size() == 1) {
targetPath.getContents().addAll(sourcePaths.get(0).getContents());
return;
}
while (transferCommonComponent(targetPath, targetPath.size(), sourcePaths, 0,
handler));
if (sourcePaths.size() > 0) {
Choice choice=new Choice();
targetPath.add(choice);
int pos=targetPath.indexOf(choice);
while (transferCommonComponent(targetPath, pos+1, sourcePaths, -1,
handler));
// Group into paths with common first interaction
boolean optional=false;
boolean content=false;
while (sourcePaths.size() > 0) {
Block path=sourcePaths.get(0);
if (path.size() == 0) {
optional = true;
} else {
content = true;
Object component=path.get(0);
java.util.List<Block> sps=new java.util.Vector<Block>();
sps.add(path);
// Check if other paths have the same initial component
for (int i=1; i < sourcePaths.size(); i++) {
Block path2=sourcePaths.get(i);
if (path2.size() > 0 && path2.get(0).equals(component)) {
sps.add(path2);
sourcePaths.remove(i);
i--; // Decrement due to removed element
}
}
if (sps.size() == 1) {
choice.getPaths().add(sps.get(0));
} else {
// Merge paths
Block tp=new Block();
choice.getPaths().add(tp);
mergePaths(sps, tp, handler);
}
}
sourcePaths.remove(0);
}
// If no content, then remove the choice construct
if (!content) {
targetPath.remove(choice);
} else {
if (optional) {
// Add empty path
choice.getPaths().add(new Block());
}
// Check for located role
Role role=null;
for (Block b : choice.getPaths()) {
if (b.size() > 0 && b.get(0) instanceof Interaction) {
Interaction in=(Interaction)b.get(0);
if (in.getFromRole() == null) {
role = in.getEnclosingProtocol().getLocatedRole();
break;
} else {
role = in.getFromRole();
break;
}
}
}
choice.setRole(new Role(role));
}
}
} |
1387581_9 | protected void mergePaths(java.util.List<Block> sourcePaths, Block targetPath,
FeedbackHandler handler) {
if (sourcePaths.size() == 0) {
return;
} else if (sourcePaths.size() == 1) {
targetPath.getContents().addAll(sourcePaths.get(0).getContents());
return;
}
while (transferCommonComponent(targetPath, targetPath.size(), sourcePaths, 0,
handler));
if (sourcePaths.size() > 0) {
Choice choice=new Choice();
targetPath.add(choice);
int pos=targetPath.indexOf(choice);
while (transferCommonComponent(targetPath, pos+1, sourcePaths, -1,
handler));
// Group into paths with common first interaction
boolean optional=false;
boolean content=false;
while (sourcePaths.size() > 0) {
Block path=sourcePaths.get(0);
if (path.size() == 0) {
optional = true;
} else {
content = true;
Object component=path.get(0);
java.util.List<Block> sps=new java.util.Vector<Block>();
sps.add(path);
// Check if other paths have the same initial component
for (int i=1; i < sourcePaths.size(); i++) {
Block path2=sourcePaths.get(i);
if (path2.size() > 0 && path2.get(0).equals(component)) {
sps.add(path2);
sourcePaths.remove(i);
i--; // Decrement due to removed element
}
}
if (sps.size() == 1) {
choice.getPaths().add(sps.get(0));
} else {
// Merge paths
Block tp=new Block();
choice.getPaths().add(tp);
mergePaths(sps, tp, handler);
}
}
sourcePaths.remove(0);
}
// If no content, then remove the choice construct
if (!content) {
targetPath.remove(choice);
} else {
if (optional) {
// Add empty path
choice.getPaths().add(new Block());
}
// Check for located role
Role role=null;
for (Block b : choice.getPaths()) {
if (b.size() > 0 && b.get(0) instanceof Interaction) {
Interaction in=(Interaction)b.get(0);
if (in.getFromRole() == null) {
role = in.getEnclosingProtocol().getLocatedRole();
break;
} else {
role = in.getFromRole();
break;
}
}
}
choice.setRole(new Role(role));
}
}
} |
1390520_0 | public void registerObserver(Context context, Object instance, Method method, Class event) {
if (!isEnabled()) return;
if( context instanceof Application )
throw new RuntimeException("You may not register event handlers on the Application context");
Map<Class<?>, Set<ObserverReference<?>>> methods = registrations.get(context);
if (methods == null) {
methods = new HashMap<Class<?>, Set<ObserverReference<?>>>();
registrations.put(context, methods);
}
Set<ObserverReference<?>> observers = methods.get(event);
if (observers == null) {
observers = new HashSet<ObserverReference<?>>();
methods.put(event, observers);
}
/*
final Returns returns = (Returns) event.getAnnotation(Returns.class);
if( returns!=null ) {
if( !returns.value().isAssignableFrom(method.getReturnType()) )
throw new RuntimeException( String.format("Method %s.%s does not return a value that is assignable to %s",method.getDeclaringClass().getName(),method.getName(),returns.value().getName()) );
if( !observers.isEmpty() ) {
final ObserverReference observer = observers.iterator().next();
throw new RuntimeException( String.format("Only one observer allowed for event types that return a value annotation. Previously registered observer is %s.%s", observer.method.getDeclaringClass().getName(), observer.method.getName()));
}
}
*/
observers.add(new ObserverReference(instance, method));
} |
1390800_0 | public Boolean transform(File pomFile) throws IOException {
this.pomFile = pomFile;
if (!pomFile.exists()) {
throw new IllegalArgumentException("Couldn't find pom file: " + pomFile);
}
SAXBuilder saxBuilder = createSaxBuilder();
Document document;
EolDetectingInputStream eolDetectingStream = null;
InputStreamReader inputStreamReader = null;
try {
eolDetectingStream = new EolDetectingInputStream(new FileInputStream(pomFile));
inputStreamReader = new InputStreamReader(eolDetectingStream, "UTF-8");
document = saxBuilder.build(inputStreamReader);
} catch (JDOMException e) {
throw new IOException("Failed to parse pom: " + pomFile.getAbsolutePath(), e);
} finally {
IOUtils.closeQuietly(inputStreamReader);
IOUtils.closeQuietly(eolDetectingStream);
}
Element rootElement = document.getRootElement();
Namespace ns = rootElement.getNamespace();
getProperties(rootElement, ns);
changeParentVersion(rootElement, ns);
changeCurrentModuleVersion(rootElement, ns);
//changePropertiesVersion(rootElement, ns);
changeDependencyManagementVersions(rootElement, ns);
changeDependencyVersions(rootElement, ns);
if (scmUrl != null) {
changeScm(rootElement, ns);
}
if (modified && !dryRun) {
FileOutputStream fileOutputStream = new FileOutputStream(pomFile);
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream, "UTF-8");
try {
XMLOutputter outputter = new XMLOutputter();
String eol = eolDetectingStream.getEol();
if (!"".equals(eol)) {
Format format = outputter.getFormat();
format.setLineSeparator(eol);
format.setTextMode(Format.TextMode.PRESERVE);
outputter.setFormat(format);
}
outputter.output(document, outputStreamWriter);
} finally {
IOUtils.closeQuietly(outputStreamWriter);
IOUtils.closeQuietly(fileOutputStream);
}
}
return modified;
} |
1390800_1 | public Boolean transform(File pomFile) throws IOException {
this.pomFile = pomFile;
if (!pomFile.exists()) {
throw new IllegalArgumentException("Couldn't find pom file: " + pomFile);
}
SAXBuilder saxBuilder = createSaxBuilder();
Document document;
EolDetectingInputStream eolDetectingStream = null;
InputStreamReader inputStreamReader = null;
try {
eolDetectingStream = new EolDetectingInputStream(new FileInputStream(pomFile));
inputStreamReader = new InputStreamReader(eolDetectingStream, "UTF-8");
document = saxBuilder.build(inputStreamReader);
} catch (JDOMException e) {
throw new IOException("Failed to parse pom: " + pomFile.getAbsolutePath(), e);
} finally {
IOUtils.closeQuietly(inputStreamReader);
IOUtils.closeQuietly(eolDetectingStream);
}
Element rootElement = document.getRootElement();
Namespace ns = rootElement.getNamespace();
getProperties(rootElement, ns);
changeParentVersion(rootElement, ns);
changeCurrentModuleVersion(rootElement, ns);
//changePropertiesVersion(rootElement, ns);
changeDependencyManagementVersions(rootElement, ns);
changeDependencyVersions(rootElement, ns);
if (scmUrl != null) {
changeScm(rootElement, ns);
}
if (modified && !dryRun) {
FileOutputStream fileOutputStream = new FileOutputStream(pomFile);
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream, "UTF-8");
try {
XMLOutputter outputter = new XMLOutputter();
String eol = eolDetectingStream.getEol();
if (!"".equals(eol)) {
Format format = outputter.getFormat();
format.setLineSeparator(eol);
format.setTextMode(Format.TextMode.PRESERVE);
outputter.setFormat(format);
}
outputter.output(document, outputStreamWriter);
} finally {
IOUtils.closeQuietly(outputStreamWriter);
IOUtils.closeQuietly(fileOutputStream);
}
}
return modified;
} |
1390800_2 | public Boolean transform(File pomFile) throws IOException {
this.pomFile = pomFile;
if (!pomFile.exists()) {
throw new IllegalArgumentException("Couldn't find pom file: " + pomFile);
}
SAXBuilder saxBuilder = createSaxBuilder();
Document document;
EolDetectingInputStream eolDetectingStream = null;
InputStreamReader inputStreamReader = null;
try {
eolDetectingStream = new EolDetectingInputStream(new FileInputStream(pomFile));
inputStreamReader = new InputStreamReader(eolDetectingStream, "UTF-8");
document = saxBuilder.build(inputStreamReader);
} catch (JDOMException e) {
throw new IOException("Failed to parse pom: " + pomFile.getAbsolutePath(), e);
} finally {
IOUtils.closeQuietly(inputStreamReader);
IOUtils.closeQuietly(eolDetectingStream);
}
Element rootElement = document.getRootElement();
Namespace ns = rootElement.getNamespace();
getProperties(rootElement, ns);
changeParentVersion(rootElement, ns);
changeCurrentModuleVersion(rootElement, ns);
//changePropertiesVersion(rootElement, ns);
changeDependencyManagementVersions(rootElement, ns);
changeDependencyVersions(rootElement, ns);
if (scmUrl != null) {
changeScm(rootElement, ns);
}
if (modified && !dryRun) {
FileOutputStream fileOutputStream = new FileOutputStream(pomFile);
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream, "UTF-8");
try {
XMLOutputter outputter = new XMLOutputter();
String eol = eolDetectingStream.getEol();
if (!"".equals(eol)) {
Format format = outputter.getFormat();
format.setLineSeparator(eol);
format.setTextMode(Format.TextMode.PRESERVE);
outputter.setFormat(format);
}
outputter.output(document, outputStreamWriter);
} finally {
IOUtils.closeQuietly(outputStreamWriter);
IOUtils.closeQuietly(fileOutputStream);
}
}
return modified;
} |
1390800_3 | public Boolean transform(File pomFile) throws IOException {
this.pomFile = pomFile;
if (!pomFile.exists()) {
throw new IllegalArgumentException("Couldn't find pom file: " + pomFile);
}
SAXBuilder saxBuilder = createSaxBuilder();
Document document;
EolDetectingInputStream eolDetectingStream = null;
InputStreamReader inputStreamReader = null;
try {
eolDetectingStream = new EolDetectingInputStream(new FileInputStream(pomFile));
inputStreamReader = new InputStreamReader(eolDetectingStream, "UTF-8");
document = saxBuilder.build(inputStreamReader);
} catch (JDOMException e) {
throw new IOException("Failed to parse pom: " + pomFile.getAbsolutePath(), e);
} finally {
IOUtils.closeQuietly(inputStreamReader);
IOUtils.closeQuietly(eolDetectingStream);
}
Element rootElement = document.getRootElement();
Namespace ns = rootElement.getNamespace();
getProperties(rootElement, ns);
changeParentVersion(rootElement, ns);
changeCurrentModuleVersion(rootElement, ns);
//changePropertiesVersion(rootElement, ns);
changeDependencyManagementVersions(rootElement, ns);
changeDependencyVersions(rootElement, ns);
if (scmUrl != null) {
changeScm(rootElement, ns);
}
if (modified && !dryRun) {
FileOutputStream fileOutputStream = new FileOutputStream(pomFile);
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream, "UTF-8");
try {
XMLOutputter outputter = new XMLOutputter();
String eol = eolDetectingStream.getEol();
if (!"".equals(eol)) {
Format format = outputter.getFormat();
format.setLineSeparator(eol);
format.setTextMode(Format.TextMode.PRESERVE);
outputter.setFormat(format);
}
outputter.output(document, outputStreamWriter);
} finally {
IOUtils.closeQuietly(outputStreamWriter);
IOUtils.closeQuietly(fileOutputStream);
}
}
return modified;
} |
1390800_4 | public Boolean transform(File pomFile) throws IOException {
this.pomFile = pomFile;
if (!pomFile.exists()) {
throw new IllegalArgumentException("Couldn't find pom file: " + pomFile);
}
SAXBuilder saxBuilder = createSaxBuilder();
Document document;
EolDetectingInputStream eolDetectingStream = null;
InputStreamReader inputStreamReader = null;
try {
eolDetectingStream = new EolDetectingInputStream(new FileInputStream(pomFile));
inputStreamReader = new InputStreamReader(eolDetectingStream, "UTF-8");
document = saxBuilder.build(inputStreamReader);
} catch (JDOMException e) {
throw new IOException("Failed to parse pom: " + pomFile.getAbsolutePath(), e);
} finally {
IOUtils.closeQuietly(inputStreamReader);
IOUtils.closeQuietly(eolDetectingStream);
}
Element rootElement = document.getRootElement();
Namespace ns = rootElement.getNamespace();
getProperties(rootElement, ns);
changeParentVersion(rootElement, ns);
changeCurrentModuleVersion(rootElement, ns);
//changePropertiesVersion(rootElement, ns);
changeDependencyManagementVersions(rootElement, ns);
changeDependencyVersions(rootElement, ns);
if (scmUrl != null) {
changeScm(rootElement, ns);
}
if (modified && !dryRun) {
FileOutputStream fileOutputStream = new FileOutputStream(pomFile);
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream, "UTF-8");
try {
XMLOutputter outputter = new XMLOutputter();
String eol = eolDetectingStream.getEol();
if (!"".equals(eol)) {
Format format = outputter.getFormat();
format.setLineSeparator(eol);
format.setTextMode(Format.TextMode.PRESERVE);
outputter.setFormat(format);
}
outputter.output(document, outputStreamWriter);
} finally {
IOUtils.closeQuietly(outputStreamWriter);
IOUtils.closeQuietly(fileOutputStream);
}
}
return modified;
} |
1390800_5 | public Boolean transform(File pomFile) throws IOException {
this.pomFile = pomFile;
if (!pomFile.exists()) {
throw new IllegalArgumentException("Couldn't find pom file: " + pomFile);
}
SAXBuilder saxBuilder = createSaxBuilder();
Document document;
EolDetectingInputStream eolDetectingStream = null;
InputStreamReader inputStreamReader = null;
try {
eolDetectingStream = new EolDetectingInputStream(new FileInputStream(pomFile));
inputStreamReader = new InputStreamReader(eolDetectingStream, "UTF-8");
document = saxBuilder.build(inputStreamReader);
} catch (JDOMException e) {
throw new IOException("Failed to parse pom: " + pomFile.getAbsolutePath(), e);
} finally {
IOUtils.closeQuietly(inputStreamReader);
IOUtils.closeQuietly(eolDetectingStream);
}
Element rootElement = document.getRootElement();
Namespace ns = rootElement.getNamespace();
getProperties(rootElement, ns);
changeParentVersion(rootElement, ns);
changeCurrentModuleVersion(rootElement, ns);
//changePropertiesVersion(rootElement, ns);
changeDependencyManagementVersions(rootElement, ns);
changeDependencyVersions(rootElement, ns);
if (scmUrl != null) {
changeScm(rootElement, ns);
}
if (modified && !dryRun) {
FileOutputStream fileOutputStream = new FileOutputStream(pomFile);
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream, "UTF-8");
try {
XMLOutputter outputter = new XMLOutputter();
String eol = eolDetectingStream.getEol();
if (!"".equals(eol)) {
Format format = outputter.getFormat();
format.setLineSeparator(eol);
format.setTextMode(Format.TextMode.PRESERVE);
outputter.setFormat(format);
}
outputter.output(document, outputStreamWriter);
} finally {
IOUtils.closeQuietly(outputStreamWriter);
IOUtils.closeQuietly(fileOutputStream);
}
}
return modified;
} |
1390800_6 | public Boolean transform(File pomFile) throws IOException {
this.pomFile = pomFile;
if (!pomFile.exists()) {
throw new IllegalArgumentException("Couldn't find pom file: " + pomFile);
}
SAXBuilder saxBuilder = createSaxBuilder();
Document document;
EolDetectingInputStream eolDetectingStream = null;
InputStreamReader inputStreamReader = null;
try {
eolDetectingStream = new EolDetectingInputStream(new FileInputStream(pomFile));
inputStreamReader = new InputStreamReader(eolDetectingStream, "UTF-8");
document = saxBuilder.build(inputStreamReader);
} catch (JDOMException e) {
throw new IOException("Failed to parse pom: " + pomFile.getAbsolutePath(), e);
} finally {
IOUtils.closeQuietly(inputStreamReader);
IOUtils.closeQuietly(eolDetectingStream);
}
Element rootElement = document.getRootElement();
Namespace ns = rootElement.getNamespace();
getProperties(rootElement, ns);
changeParentVersion(rootElement, ns);
changeCurrentModuleVersion(rootElement, ns);
//changePropertiesVersion(rootElement, ns);
changeDependencyManagementVersions(rootElement, ns);
changeDependencyVersions(rootElement, ns);
if (scmUrl != null) {
changeScm(rootElement, ns);
}
if (modified && !dryRun) {
FileOutputStream fileOutputStream = new FileOutputStream(pomFile);
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream, "UTF-8");
try {
XMLOutputter outputter = new XMLOutputter();
String eol = eolDetectingStream.getEol();
if (!"".equals(eol)) {
Format format = outputter.getFormat();
format.setLineSeparator(eol);
format.setTextMode(Format.TextMode.PRESERVE);
outputter.setFormat(format);
}
outputter.output(document, outputStreamWriter);
} finally {
IOUtils.closeQuietly(outputStreamWriter);
IOUtils.closeQuietly(fileOutputStream);
}
}
return modified;
} |
1390800_7 | static Map<String, String> parse(String installationLog, Log logger) {
Map<String, String> downloadedDependencies = new HashMap<>();
String[] lines = installationLog.split("\\R");
MutableBoolean expectingPackageFilePath = new MutableBoolean(false);
String packageName = "";
for (String line : lines) {
// Extract downloaded package name.
Matcher matcher = COLLECTING_PACKAGE_PATTERN.matcher(line);
if (matcher.find()) {
packageName = extractPackageName(downloadedDependencies, matcher, packageName, expectingPackageFilePath, logger);
continue;
}
// Extract downloaded file, stored in Artifactory.
matcher = DOWNLOADED_FILE_PATTERN.matcher(line);
if (matcher.find()) {
extractDownloadedFileName(downloadedDependencies, matcher, packageName, expectingPackageFilePath, logger);
continue;
}
// Extract already installed package name.
matcher = INSTALLED_PACKAGE_PATTERN.matcher(line);
if (matcher.find()) {
extractAlreadyInstalledPackage(downloadedDependencies, matcher, logger);
}
}
// If there is a package we are still waiting for its path, save it with empty path.
if (expectingPackageFilePath.isTrue()) {
downloadedDependencies.put(StringUtils.lowerCase(packageName), "");
}
return downloadedDependencies;
} |
1390800_8 | static String extractPackageName(Map<String, String> downloadedDependencies, Matcher matcher, String packageName, MutableBoolean expectingPackageFilePath, Log logger) {
if (expectingPackageFilePath.isTrue()) {
// This may occur when a package-installation file is saved in pip-cache-dir, thus not being downloaded during the installation.
// Re-running pip-install with 'no-cache-dir' fixes this issue.
logger.debug(String.format("Could not resolve download path for package: %s, continuing...", packageName));
// Save package with empty file path.
downloadedDependencies.put(StringUtils.lowerCase(packageName), "");
}
// Save dependency info.
expectingPackageFilePath.setTrue();
return matcher.group(1);
} |
1390800_9 | static void extractDownloadedFileName(Map<String, String> downloadedDependencies, Matcher matcher, String packageName, MutableBoolean expectingPackageFilePath, Log logger) {
// If this pattern matched before package-name was found, do not collect this path.
if (expectingPackageFilePath.isFalse()) {
logger.debug(String.format("Could not determine package-name for path: %s, continuing...", matcher.group(1)));
return;
}
// Save dependency information.
String filePath = matcher.group(1);
downloadedDependencies.put(StringUtils.lowerCase(packageName), filePath);
expectingPackageFilePath.setFalse();
logger.debug(String.format("Found package: %s installed with: %s", packageName, filePath));
} |
1391650_0 | public static void nonNull(Object... values) {
int i = 0;
for (Object value : values) {
++i;
if (value == null) {
String message = String.format("%s Value %d/%d is null.", PREFIX, i, values.length);
throw new IllegalArgumentException(message);
}
}
} |
1391650_1 | public static void nonNull(Object... values) {
int i = 0;
for (Object value : values) {
++i;
if (value == null) {
String message = String.format("%s Value %d/%d is null.", PREFIX, i, values.length);
throw new IllegalArgumentException(message);
}
}
} |
1391650_2 | public static void check(boolean... values) {
int i = 0;
for (boolean value : values) {
++i;
if (!value) {
String msg = String.format("%s Check %d/%d failed!", PREFIX, i, values.length);
throw new IllegalArgumentException(msg);
}
}
} |
1391650_3 | public static void check(boolean... values) {
int i = 0;
for (boolean value : values) {
++i;
if (!value) {
String msg = String.format("%s Check %d/%d failed!", PREFIX, i, values.length);
throw new IllegalArgumentException(msg);
}
}
} |
1391650_4 | public static void unreachable() {
String message = String.format("%s Code should be unreachable!\n", PREFIX);
throw new IllegalStateException(message);
} |
1391650_5 | public static void unreachable() {
String message = String.format("%s Code should be unreachable!\n", PREFIX);
throw new IllegalStateException(message);
} |
1391650_6 | public static String maybeConsume(final InputStream stream, final Charset encoding, final int limit)
throws IOException {
Assert.nonNull(stream, encoding);
return consume(new InputStreamReader(stream, encoding), limit);
} |
1391650_7 | public static String consume(final InputStream stream, final Charset encoding)
throws IOException {
return maybeConsume(stream, encoding, 0);
} |
1397974_0 | public static int[] mergesort(int start, int length, IntBinaryOperator comparator) {
final int[] src = createOrderArray(start, length);
if (length > 1) {
final int[] dst = (int[]) src.clone();
topDownMergeSort(src, dst, 0, length, comparator);
return dst;
}
return src;
} |
1397974_1 | public static int[] mergesort(int start, int length, IntBinaryOperator comparator) {
final int[] src = createOrderArray(start, length);
if (length > 1) {
final int[] dst = (int[]) src.clone();
topDownMergeSort(src, dst, 0, length, comparator);
return dst;
}
return src;
} |
1397974_2 | public static int[] mergesort(int start, int length, IntBinaryOperator comparator) {
final int[] src = createOrderArray(start, length);
if (length > 1) {
final int[] dst = (int[]) src.clone();
topDownMergeSort(src, dst, 0, length, comparator);
return dst;
}
return src;
} |
1397974_3 | public static int[] mergesort(int start, int length, IntBinaryOperator comparator) {
final int[] src = createOrderArray(start, length);
if (length > 1) {
final int[] dst = (int[]) src.clone();
topDownMergeSort(src, dst, 0, length, comparator);
return dst;
}
return src;
} |
1397974_4 | public static int[] mergesort(int start, int length, IntBinaryOperator comparator) {
final int[] src = createOrderArray(start, length);
if (length > 1) {
final int[] dst = (int[]) src.clone();
topDownMergeSort(src, dst, 0, length, comparator);
return dst;
}
return src;
} |
1397974_5 | @SuppressForbidden
public static long randomSeed64() {
if (testsSeedProperty == null) {
try {
testsSeedProperty =
java.security.AccessController.doPrivileged(
new PrivilegedAction<String>() {
@Override
public String run() {
return System.getProperty("tests.seed", NOT_AVAILABLE);
}
});
} catch (SecurityException e) {
// If failed on security exception, don't panic.
testsSeedProperty = NOT_AVAILABLE;
Logger.getLogger(Containers.class.getName())
.log(Level.INFO, "Failed to read 'tests.seed' property for initial random seed.", e);
}
}
long initialSeed;
if (testsSeedProperty != NOT_AVAILABLE) {
initialSeed = testsSeedProperty.hashCode();
} else {
// Mix something that is changing over time (nanoTime)
// ... with something that is thread-local and relatively unique
// even for very short time-spans (new Object's address from a TLAB).
initialSeed = System.nanoTime() ^ System.identityHashCode(new Object());
}
return BitMixer.mix64(initialSeed);
} |
1397974_6 | @SuppressForbidden
public static long randomSeed64() {
if (testsSeedProperty == null) {
try {
testsSeedProperty =
java.security.AccessController.doPrivileged(
new PrivilegedAction<String>() {
@Override
public String run() {
return System.getProperty("tests.seed", NOT_AVAILABLE);
}
});
} catch (SecurityException e) {
// If failed on security exception, don't panic.
testsSeedProperty = NOT_AVAILABLE;
Logger.getLogger(Containers.class.getName())
.log(Level.INFO, "Failed to read 'tests.seed' property for initial random seed.", e);
}
}
long initialSeed;
if (testsSeedProperty != NOT_AVAILABLE) {
initialSeed = testsSeedProperty.hashCode();
} else {
// Mix something that is changing over time (nanoTime)
// ... with something that is thread-local and relatively unique
// even for very short time-spans (new Object's address from a TLAB).
initialSeed = System.nanoTime() ^ System.identityHashCode(new Object());
}
return BitMixer.mix64(initialSeed);
} |
1397974_7 | public int grow(int currentBufferLength, int elementsCount, int expectedAdditions) {
long growBy = (long) ((long) currentBufferLength * growRatio);
growBy = Math.max(growBy, minGrowCount);
growBy = Math.min(growBy, maxGrowCount);
long growTo = Math.min(MAX_ARRAY_LENGTH, growBy + currentBufferLength);
long newSize = Math.max((long) elementsCount + expectedAdditions, growTo);
if (newSize > MAX_ARRAY_LENGTH) {
throw new BufferAllocationException(
"Java array size exceeded (current length: %d, elements: %d, expected additions: %d)",
currentBufferLength, elementsCount, expectedAdditions);
}
return (int) newSize;
} |
1397974_8 | public int grow(int currentBufferLength, int elementsCount, int expectedAdditions) {
long growBy = (long) ((long) currentBufferLength * growRatio);
growBy = Math.max(growBy, minGrowCount);
growBy = Math.min(growBy, maxGrowCount);
long growTo = Math.min(MAX_ARRAY_LENGTH, growBy + currentBufferLength);
long newSize = Math.max((long) elementsCount + expectedAdditions, growTo);
if (newSize > MAX_ARRAY_LENGTH) {
throw new BufferAllocationException(
"Java array size exceeded (current length: %d, elements: %d, expected additions: %d)",
currentBufferLength, elementsCount, expectedAdditions);
}
return (int) newSize;
} |
1397974_9 | @Override
public String toString() {
long bit = nextSetBit(0);
if (bit < 0) {
return "{}";
}
final StringBuilder builder = new StringBuilder();
builder.append("{");
builder.append(Long.toString(bit));
while ((bit = nextSetBit(bit + 1)) >= 0) {
builder.append(", ");
builder.append(Long.toString(bit));
}
builder.append("}");
return builder.toString();
} |
1404216_0 | @Override
public Path createDaemonDir(Path jumiHome) {
try {
return UniqueDirectories.createUniqueDir(jumiHome.resolve(DAEMONS_DIR), System.currentTimeMillis());
} catch (IOException e) {
throw new RuntimeException("Unable to create daemon directory", e);
}
} |
1404216_1 | @Override
public Path createDaemonDir(Path jumiHome) {
try {
return UniqueDirectories.createUniqueDir(jumiHome.resolve(DAEMONS_DIR), System.currentTimeMillis());
} catch (IOException e) {
throw new RuntimeException("Unable to create daemon directory", e);
}
} |
1404216_2 | @Override
public Path createDaemonDir(Path jumiHome) {
try {
return UniqueDirectories.createUniqueDir(jumiHome.resolve(DAEMONS_DIR), System.currentTimeMillis());
} catch (IOException e) {
throw new RuntimeException("Unable to create daemon directory", e);
}
} |
1404216_3 | @Override
public Path getDaemonJar(Path jumiHome) {
Path extractedJar = jumiHome.resolve("lib/" + daemonJar.getDaemonJarName());
createIfDoesNotExist(extractedJar);
return extractedJar;
} |
1404216_4 | @Override
public Path getDaemonJar(Path jumiHome) {
Path extractedJar = jumiHome.resolve("lib/" + daemonJar.getDaemonJarName());
createIfDoesNotExist(extractedJar);
return extractedJar;
} |
1404216_5 | @Override
public Path getDaemonJar(Path jumiHome) {
Path extractedJar = jumiHome.resolve("lib/" + daemonJar.getDaemonJarName());
createIfDoesNotExist(extractedJar);
return extractedJar;
} |
1404216_6 | public static List<Path> getClasspathElements(String classpath, String pathSeparator) {
List<Path> results = new ArrayList<>();
for (String path : classpath.split(Pattern.quote(pathSeparator))) {
results.add(new File(path).toPath());
}
return results;
} |
1404216_7 | public static List<Path> getClasspathElements(String classpath, String pathSeparator) {
List<Path> results = new ArrayList<>();
for (String path : classpath.split(Pattern.quote(pathSeparator))) {
results.add(new File(path).toPath());
}
return results;
} |
1404216_8 | public static List<Path> getClasspathElements(String classpath, String pathSeparator) {
List<Path> results = new ArrayList<>();
for (String path : classpath.split(Pattern.quote(pathSeparator))) {
results.add(new File(path).toPath());
}
return results;
} |
1404216_9 | @Override
public void close() throws IOException {
externalResources.close();
} |
1404666_0 | public void coveredByUnitTest()
{
System.out.println("Hello, world.");
} |
1404666_1 | public void coveredByUnitTest()
{
System.out.println("Hello, world.");
} |
1404666_3 | public List getExtensions() {
return ImmutableList.of(FileDescriptorLeakDetector.class);
} |
1404666_4 | public double evaluate(Token... tokens) {
this.pos = -1;
this.stream = tokens;
return expression().getValue();
} |
1404666_5 | public double evaluate(Token... tokens) {
this.pos = -1;
this.stream = tokens;
return expression().getValue();
} |
1404666_6 | public double evaluate(Token... tokens) {
this.pos = -1;
this.stream = tokens;
return expression().getValue();
} |
1404666_7 | public double evaluate(Token... tokens) {
this.pos = -1;
this.stream = tokens;
return expression().getValue();
} |
1404666_8 | public double evaluate(Token... tokens) {
this.pos = -1;
this.stream = tokens;
return expression().getValue();
} |
1404666_9 | public double evaluate(Token... tokens) {
this.pos = -1;
this.stream = tokens;
return expression().getValue();
} |
1406218_0 | public String generateUniqueId(String text)
{
// Note: We always use a prefix (and a prefix with alpha characters) so that the generated id is a valid HTML id
// (since HTML id must start with an alpha prefix).
return generateUniqueId("I", text);
} |
1406218_1 | public String generateUniqueId(String text)
{
// Note: We always use a prefix (and a prefix with alpha characters) so that the generated id is a valid HTML id
// (since HTML id must start with an alpha prefix).
return generateUniqueId("I", text);
} |
1406218_2 | public String generateUniqueId(String text)
{
// Note: We always use a prefix (and a prefix with alpha characters) so that the generated id is a valid HTML id
// (since HTML id must start with an alpha prefix).
return generateUniqueId("I", text);
} |
1406218_3 | public String generateUniqueId(String text)
{
// Note: We always use a prefix (and a prefix with alpha characters) so that the generated id is a valid HTML id
// (since HTML id must start with an alpha prefix).
return generateUniqueId("I", text);
} |
1406218_4 | public String generateUniqueId(String text)
{
// Note: We always use a prefix (and a prefix with alpha characters) so that the generated id is a valid HTML id
// (since HTML id must start with an alpha prefix).
return generateUniqueId("I", text);
} |
1406218_5 | public SyntaxType getType()
{
return this.type;
} |
1406218_6 | @Override
public boolean equals(Object object)
{
if (object == this) {
return true;
}
if (!(object instanceof Syntax)) {
return false;
}
Syntax rhs = (Syntax) object;
return new EqualsBuilder().append(getType(), rhs.getType()).append(getVersion(), rhs.getVersion())
.append(getQualifier(), rhs.getQualifier()).isEquals();
} |
1406218_7 | @Override
public int compareTo(Syntax syntax)
{
return new CompareToBuilder().append(getType(), syntax.getType())
// TODO: Add a real version parser to compare the versions
.append(getVersion(), syntax.getVersion()).toComparison();
} |
1406218_8 | public static Syntax valueOf(String syntaxIdAsString) throws ParseException
{
if (syntaxIdAsString == null) {
throw new ParseException("The passed Syntax cannot be NULL");
}
Matcher matcher = SYNTAX_PATTERN.matcher(syntaxIdAsString);
if (!matcher.matches()) {
throw new ParseException(String.format("Invalid Syntax format [%s]", syntaxIdAsString));
}
String syntaxId = matcher.group(1);
String version = matcher.group(2);
// For well-known syntaxes, get the Syntax Name from the registered SyntaxType, otherwise use the id as both
// the human readable name and the technical id (since the syntax string doesn't contain any information about
// the pretty name of a syntax type).
SyntaxType syntaxType = SyntaxType.getSyntaxTypes().get(syntaxId);
if (syntaxType == null) {
syntaxType = new SyntaxType(syntaxId, syntaxId);
}
return new Syntax(syntaxType, version);
} |
1406218_9 | public static Syntax valueOf(String syntaxIdAsString) throws ParseException
{
if (syntaxIdAsString == null) {
throw new ParseException("The passed Syntax cannot be NULL");
}
Matcher matcher = SYNTAX_PATTERN.matcher(syntaxIdAsString);
if (!matcher.matches()) {
throw new ParseException(String.format("Invalid Syntax format [%s]", syntaxIdAsString));
}
String syntaxId = matcher.group(1);
String version = matcher.group(2);
// For well-known syntaxes, get the Syntax Name from the registered SyntaxType, otherwise use the id as both
// the human readable name and the technical id (since the syntax string doesn't contain any information about
// the pretty name of a syntax type).
SyntaxType syntaxType = SyntaxType.getSyntaxTypes().get(syntaxId);
if (syntaxType == null) {
syntaxType = new SyntaxType(syntaxId, syntaxId);
}
return new Syntax(syntaxType, version);
} |
1407946_0 | public String getAlign() {
EnumAlign enumAlign = (EnumAlign) comboBoxAlign.getSelectedItem();
return enumAlign.getXmlValue();
} |
1407946_1 | public void setAlign(EnumAlign enumAlign) {
comboBoxAlign.setSelectedItem(enumAlign);
} |
1407946_2 | public String getThickness() {
return textFieldSize.getText().trim();
} |
1407946_3 | public void setThickness(String thickness) {
textFieldSize.setText(thickness);
} |
1407946_4 | public String getCustomWidth() {
String value = textFieldWidth.getText().trim();
if (value == null || value.length() == 0) {
return null;
}
return value;
} |
1407946_5 | public String getCustomWidth() {
String value = textFieldWidth.getText().trim();
if (value == null || value.length() == 0) {
return null;
}
return value;
} |
1407946_6 | public void setCustomWidth(String width) {
textFieldWidth.setText(width);
} |
1407946_7 | public String getCustomWidthUnit() {
EnumWidthUnit enumWidthUnit = (EnumWidthUnit) comboBoxWidthUnit.getSelectedItem();
return enumWidthUnit.getXmlValue();
} |
1407946_8 | public void setCustomWidthUnit(EnumWidthUnit enumWidthUnit) {
comboBoxWidthUnit.setSelectedItem(enumWidthUnit);
} |
1407946_9 | public String getColor() {
Color color = colorChooser.getColor();
String red = Integer.toHexString(color.getRed());
if(red.length()==1)red="0"+red;
String green = Integer.toHexString(color.getGreen());
if(green.length()==1)green="0"+green;
String blue = Integer.toHexString(color.getBlue());
if(blue.length()==1)blue="0"+blue;
String rgbHexValue = red + green + blue;
return rgbHexValue;
} |
1415645_0 | public Statement read() throws Exception, UnexpectedInputException,
ParseException {
Customer customer = customerReader.read();
if(customer == null) {
return null;
} else {
Statement statement = new Statement();
statement.setCustomer(customer);
statement.setSecurityTotal(tickerDao.getTotalValueForCustomer(customer.getId()));
statement.setStocks(tickerDao.getStocksForCustomer(customer.getId()));
return statement;
}
} |
1415645_1 | public Statement read() throws Exception, UnexpectedInputException,
ParseException {
Customer customer = customerReader.read();
if(customer == null) {
return null;
} else {
Statement statement = new Statement();
statement.setCustomer(customer);
statement.setSecurityTotal(tickerDao.getTotalValueForCustomer(customer.getId()));
statement.setStocks(tickerDao.getStocksForCustomer(customer.getId()));
return statement;
}
} |
1421658_0 | public String buildOAuthUrl(ConnectionFactory<?> connectionFactory, NativeWebRequest request) {
return buildOAuthUrl(connectionFactory, request, null);
} |
1421658_1 | public String buildOAuthUrl(ConnectionFactory<?> connectionFactory, NativeWebRequest request) {
return buildOAuthUrl(connectionFactory, request, null);
} |
1421658_2 | public String buildOAuthUrl(ConnectionFactory<?> connectionFactory, NativeWebRequest request) {
return buildOAuthUrl(connectionFactory, request, null);
} |
1421658_3 | public String buildOAuthUrl(ConnectionFactory<?> connectionFactory, NativeWebRequest request) {
return buildOAuthUrl(connectionFactory, request, null);
} |
1421658_4 | public String buildOAuthUrl(ConnectionFactory<?> connectionFactory, NativeWebRequest request) {
return buildOAuthUrl(connectionFactory, request, null);
} |
1421658_5 | public String buildOAuthUrl(ConnectionFactory<?> connectionFactory, NativeWebRequest request) {
return buildOAuthUrl(connectionFactory, request, null);
} |
1421658_6 | public String buildOAuthUrl(ConnectionFactory<?> connectionFactory, NativeWebRequest request) {
return buildOAuthUrl(connectionFactory, request, null);
} |
1421658_7 | public String buildOAuthUrl(ConnectionFactory<?> connectionFactory, NativeWebRequest request) {
return buildOAuthUrl(connectionFactory, request, null);
} |
1421658_8 | public String buildOAuthUrl(ConnectionFactory<?> connectionFactory, NativeWebRequest request) {
return buildOAuthUrl(connectionFactory, request, null);
} |
1421658_9 | public Connection<?> completeConnection(OAuth1ConnectionFactory<?> connectionFactory, NativeWebRequest request) {
String verifier = request.getParameter("oauth_verifier");
AuthorizedRequestToken requestToken = new AuthorizedRequestToken(extractCachedRequestToken(request), verifier);
OAuthToken accessToken = connectionFactory.getOAuthOperations().exchangeForAccessToken(requestToken, null);
return connectionFactory.createConnection(accessToken);
} |
1421692_0 | public static String underlined(String str) {
int strLen;
if (str == null || (strLen = str.length()) == 0) {
return str;
}
StringBuilder ret = new StringBuilder();
int last = 0;
for (int i = 0; i < strLen; i++) {
char ch = str.charAt(i);
if (ch == '_') {
ret.append(Character.toLowerCase(ch));
last = -1;
} else if (!Character.isLetter(ch)) {
ret.append(ch);
last = -1;
} else if (Character.isUpperCase(ch)) {
if (i > 0 && (last == 0 || (last != -1 && i < strLen - 1 && Character.isLowerCase(str.charAt(i + 1))))) {
ret.append('_');
}
ret.append(Character.toLowerCase(ch));
last = 1;
} else {
ret.append(ch);
last = 0;
}
}
return ret.toString();
} |
1421692_1 | public void snapshot() {
for (Counter counter : counterMap.values()) {
counter.snapshot();
}
} |
1421692_2 | public static Class<?>[] getClasses(String packageName) throws ClassNotFoundException, IOException {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
assert classLoader != null;
String path = packageName.replace('.', '/');
Enumeration<URL> resources = classLoader.getResources(path);
List<File> dirs = new ArrayList<File>();
ArrayList<Class<?>> classes = new ArrayList<Class<?>>();
while (resources.hasMoreElements()) {
URL resource = resources.nextElement();
String p = "";
if (resource.getFile().indexOf("!") >= 0) {// 在其他的jar文件中
p = resource.getFile().substring(0, resource.getFile().indexOf("!")).replaceAll("%20", "");
} else {// 在classes目录中
p = resource.getFile();
}
if (p.startsWith("file:/"))
p = p.substring(5);
if (p.toLowerCase().endsWith(".jar")) {
JarFile jarFile = new JarFile(p);
Enumeration<JarEntry> enums = jarFile.entries();
while (enums.hasMoreElements()) {
JarEntry entry = (JarEntry) enums.nextElement();
String n = entry.getName();
if (n.endsWith(".class")) {
n = n.replaceAll("/", ".").substring(0, n.length() - 6);
if (n.startsWith(packageName)) {
classes.add(Class.forName(n));
}
}
}
jarFile.close();
} else {
dirs.add(new File(p));
}
}
for (File directory : dirs) {
classes.addAll(findClasses(directory, packageName));
}
return classes.toArray(new Class[classes.size()]);
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.