_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q176600
DroolsThread.stepOver
test
public synchronized void stepOver() throws DebugException { // Detection for active stackframe if ( !(getTopStackFrame() instanceof MVELStackFrame) ) { super.stepOver(); return; } //MVEL step over MVELStackFrame mvelStack = (MVELStackFrame) getTopStackFrame(); if ( !canStepOver() || !mvelStack.canStepOver() ) { return; } if ( !setRemoteOnBreakReturn( Debugger.STEP ) ) { return; } setRunning( true ); preserveStackFrames(); fireEvent( new DebugEvent( this, DebugEvent.RESUME, DebugEvent.STEP_OVER ) ); try { getUnderlyingThread().resume(); } catch ( RuntimeException e ) { //stepEnd(); targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIThread_exception_stepping, e.toString()), e); } }
java
{ "resource": "" }
q176601
DroolsBuilder.markParseErrors
test
protected void markParseErrors(List<DroolsBuildMarker> markers, List<BaseKnowledgeBuilderResultImpl> parserErrors) { for ( Iterator<BaseKnowledgeBuilderResultImpl> iter = parserErrors.iterator(); iter.hasNext(); ) { Object error = iter.next(); if ( error instanceof ParserError ) { ParserError err = (ParserError) error; markers.add( new DroolsBuildMarker( err.getMessage(), err.getRow() ) ); } else if ( error instanceof KnowledgeBuilderResult) { KnowledgeBuilderResult res = (KnowledgeBuilderResult) error; int[] errorLines = res.getLines(); markers.add( new DroolsBuildMarker( res.getMessage(), errorLines != null && errorLines.length > 0 ? errorLines[0] : -1 ) ); } else if ( error instanceof ExpanderException ) { ExpanderException exc = (ExpanderException) error; // TODO line mapping is incorrect markers.add( new DroolsBuildMarker( exc.getMessage(), -1 ) ); } else { markers.add( new DroolsBuildMarker( error.toString() ) ); } } }
java
{ "resource": "" }
q176602
Parser.skipWhiteSpace
test
public void skipWhiteSpace() { while (pos < s.length() && Character.isWhitespace(s.charAt(pos))) ++pos; }
java
{ "resource": "" }
q176603
GuvnorMetadataUtils.addResourceToGuvnor
test
public static boolean addResourceToGuvnor(String repLoc, String targetLoc, IFile selectedFile) { boolean res = false; try { String fullPath = targetLoc + selectedFile.getName(); IWebDavClient client = WebDavServerCache.getWebDavClient(repLoc); if (client == null) { client = WebDavClientFactory.createClient(new URL(repLoc)); WebDavServerCache.cacheWebDavClient(repLoc, client); } try { // res = client.createResource(fullPath, selectedFile.getContents(), false); // Hack: When creating a file, if the actual contents are passed first, // the client hangs for about 20 seconds when closing the InputStream. // Don't know why... // But, if the file is created with empty contents, and then the contents // set, the operation is fast (less than a couple of seconds) res = client.createResource(fullPath, new ByteArrayInputStream(new byte[0]), false); if (res) { client.putResource(fullPath, selectedFile.getContents()); } } catch (WebDavException wde) { if (wde.getErrorCode() != IResponse.SC_UNAUTHORIZED) { // If not an authentication failure, we don't know what to do with it throw wde; } boolean retry = PlatformUtils.getInstance(). authenticateForServer(repLoc, client); if (retry) { // res = client.createResource(fullPath, selectedFile.getContents(), false); // See Hack note immediately above... res = client.createResource(fullPath, new ByteArrayInputStream(new byte[0]), false); if (res) { client.putResource(fullPath, selectedFile.getContents()); } } } if (res) { GuvnorMetadataUtils.markCurrentGuvnorResource(selectedFile); ResourceProperties resProps = client.queryProperties(fullPath); GuvnorMetadataProps mdProps = new GuvnorMetadataProps(selectedFile.getName(), repLoc, fullPath, resProps.getLastModifiedDate(), resProps.getRevision()); GuvnorMetadataUtils.setGuvnorMetadataProps(selectedFile.getFullPath(), mdProps); } } catch (Exception e) { Activator.getDefault().displayError(IStatus.ERROR, e.getMessage(), e, true); } return res; }
java
{ "resource": "" }
q176604
GuvnorMetadataUtils.commitFileChanges
test
public static void commitFileChanges(IFile selectedFile) { try { GuvnorMetadataProps props = GuvnorMetadataUtils.getGuvnorMetadata(selectedFile); IWebDavClient client = WebDavServerCache.getWebDavClient(props.getRepository()); if (client == null) { client = WebDavClientFactory.createClient(new URL(props.getRepository())); WebDavServerCache.cacheWebDavClient(props.getRepository(), client); } ResourceProperties remoteProps = null; try { remoteProps = client.queryProperties(props.getFullpath()); } catch (WebDavException wde) { if (wde.getErrorCode() != IResponse.SC_UNAUTHORIZED) { // If not an authentication failure, we don't know what to do with it throw wde; } boolean retry = PlatformUtils.getInstance(). authenticateForServer(props.getRepository(), client); if (retry) { remoteProps = client.queryProperties(props.getFullpath()); } } if (remoteProps == null) { throw new Exception("Could not retrieve server version of " + props.getFullpath()); //$NON-NLS-1$ } // Check to make sure that the version in the repository is the same as the base // version for the local copy boolean proceed = true; if (!props.getRevision().equals(remoteProps.getRevision())) { String msg = MessageFormat.format(Messages.getString("overwrite.confirmation"), //$NON-NLS-1$ new Object[] { selectedFile.getName(), remoteProps.getRevision(), props.getRevision() }); Display display = PlatformUI.getWorkbench().getDisplay(); proceed = MessageDialog.openQuestion(display.getActiveShell(), Messages.getString("overwrite.confirmation.caption"), msg); //$NON-NLS-1$ } if (proceed) { client.putResource(props.getFullpath(), selectedFile.getContents()); GuvnorMetadataUtils.markCurrentGuvnorResource(selectedFile); ResourceProperties resProps = client.queryProperties(props.getFullpath()); GuvnorMetadataProps mdProps = GuvnorMetadataUtils.getGuvnorMetadata(selectedFile); mdProps.setVersion(resProps.getLastModifiedDate()); mdProps.setRevision(resProps.getRevision()); GuvnorMetadataUtils.setGuvnorMetadataProps(selectedFile.getFullPath(), mdProps); } } catch (Exception e) { Activator.getDefault().displayError(IStatus.ERROR, e.getMessage(), e, true); } }
java
{ "resource": "" }
q176605
Context.getAge
test
public int getAge() { String ageString = get(AGE); return (ageString == null) ? -1 : Integer.parseInt(ageString); }
java
{ "resource": "" }
q176606
Context.getContentLength
test
public long getContentLength() { String lengthString = get(CONTENT_LENGTH); return (lengthString == null) ? -1 : Long.parseLong(lengthString); }
java
{ "resource": "" }
q176607
Context.getMaxForwards
test
public int getMaxForwards() { String s = get(MAX_FORWARDS); return s == null ? -1 : Integer.parseInt(s); }
java
{ "resource": "" }
q176608
Context.getOverwrite
test
public boolean getOverwrite() { String overwriteString = get(OVERWRITE); return overwriteString == null ? false : overwriteString.equalsIgnoreCase("T"); //$NON-NLS-1$ }
java
{ "resource": "" }
q176609
Context.getPassthrough
test
public boolean getPassthrough() { String s = get(PASSTHROUGH); return s == null ? false : s.equalsIgnoreCase("T"); //$NON-NLS-1$ }
java
{ "resource": "" }
q176610
Context.getTimeout
test
public int getTimeout() { String timeoutString = get(TIMEOUT); if (timeoutString == null) return -1; if (timeoutString.equalsIgnoreCase(DEPTH_INFINITY)) return -2; if (timeoutString.regionMatches(true, 1, "Second-", 1, 7)) //$NON-NLS-1$ return Integer.parseInt(timeoutString.substring(7)); // ignore all other cases, and use infinite timeout return -2; }
java
{ "resource": "" }
q176611
Context.put
test
public void put(String key, String value) { ContextKey ckey = new ContextKey(key); if ((value == null) || (value.length() == 0)) properties.remove(ckey); else properties.put(ckey, value); }
java
{ "resource": "" }
q176612
Context.setTimeout
test
public void setTimeout(int value) { if (value == -1) put(TIMEOUT, ""); //$NON-NLS-1$ else put(TIMEOUT, (value == -2) ? DEPTH_INFINITY : "Second-" + Integer.toString(value)); //$NON-NLS-1$ }
java
{ "resource": "" }
q176613
DSLTree.openDSLFile
test
protected BufferedReader openDSLFile(String filename) { try { FileReader reader = new FileReader(filename); BufferedReader breader = new BufferedReader(reader); return breader; } catch (IOException e) { e.printStackTrace(); return null; } }
java
{ "resource": "" }
q176614
DSLTree.parseFile
test
protected void parseFile(BufferedReader reader) { String line = null; try { while ( (line = reader.readLine()) != null) { Section section = getSection(line); String nl = stripHeadingAndCode(line); String objname = this.getObjMetadata(nl); nl = this.stripObjMetadata(nl); addEntry(section, nl, objname); } } catch (IOException e) { e.printStackTrace(); } }
java
{ "resource": "" }
q176615
DSLTree.getObjMetadata
test
protected String getObjMetadata(String text) { if (text.startsWith("[")) { return text.substring(1,text.lastIndexOf("]")); } else { return ""; } }
java
{ "resource": "" }
q176616
DSLTree.stripObjMetadata
test
protected String stripObjMetadata(String text) { if (text.startsWith("[")) { return text.substring(text.lastIndexOf("]") + 1); } else { return text; } }
java
{ "resource": "" }
q176617
DSLTree.addTokens
test
public void addTokens(String[] tokens, Node rootNode) { Node thenode = rootNode; for (int i = 0; i < tokens.length; i++) { Node newnode = thenode.addToken(tokens[i]); thenode = newnode; } }
java
{ "resource": "" }
q176618
DSLTree.getConditionChildren
test
public Node[] getConditionChildren(String text) { Node thenode = this.rootCond; if (text.length() > 0) { StringTokenizer tokenz = new StringTokenizer(text); this.last = this.current; while (tokenz.hasMoreTokens()) { String strtk = tokenz.nextToken(); Node ch = thenode.getChild(strtk); // if a child is found, we set thenode to the child Node if (ch != null) { thenode = ch; } else { break; } } if (thenode != this.rootCond) { this.current = thenode; } } Collection<Node> children = thenode.getChildren(); Node[] nchild = new Node[children.size()]; return children.toArray(nchild); }
java
{ "resource": "" }
q176619
DSLTree.getChildren
test
public Node[] getChildren(String obj, String text) { Node thenode = this.rootCond.getChild(obj); if (thenode == null) { for (Node child: this.rootCond.getChildren()) { String tokenText = child.getToken(); if (tokenText != null) { int index = tokenText.indexOf("{"); if (index != -1) { String substring = tokenText.substring(0, index); if (obj != null && obj.startsWith(substring)) { thenode = child; } } } } } if (thenode != null && text.length() > 0) { StringTokenizer tokenz = new StringTokenizer(text); this.last = this.current; while (tokenz.hasMoreTokens()) { String strtk = tokenz.nextToken(); Node ch = thenode.getChild(strtk); // if a child is found, we set thenode to the child Node if (ch != null) { thenode = ch; } else { break; } } if (thenode != this.rootCond) { this.current = thenode; } } if (thenode == null) { return null; // thenode = this.rootCond; } Collection<Node> children = thenode.getChildren(); Node[] nchild = new Node[children.size()]; return children.toArray(nchild); }
java
{ "resource": "" }
q176620
DSLTree.addChildToList
test
public void addChildToList(Node n, String prefix, ArrayList<String> list) { if (n.getChildren().size() > 0) { for (Node child : n.getChildren()) { if (prefix != null && "-".equals(child.getToken())) { if (!list.contains(prefix)) { list.add(prefix); } return; } String text = (prefix == null ? "" : prefix + " ") + child.getToken(); // list.add(text); addChildToList(child,text,list); } } else { if (!list.contains(prefix)) { list.add(prefix); } } }
java
{ "resource": "" }
q176621
DSLTree.printTree
test
public void printTree() { System.out.println("ROOT"); for (Node n : rootCond.getChildren()) { printNode(n); } }
java
{ "resource": "" }
q176622
DSLTree.printNode
test
protected void printNode(Node n) { printTabs(n.getDepth()); System.out.println("- \"" + n.getToken() + "\""); for (Node c : n.getChildren()) { printNode(c); } }
java
{ "resource": "" }
q176623
DSLTree.printTabs
test
protected void printTabs(int count) { for (int idx=0; idx < count; idx++) { System.out.print(tab); } }
java
{ "resource": "" }
q176624
JsonValue.readFrom
test
public static JsonValue readFrom( String text ) { try { return new JsonParser( text ).parse(); } catch( IOException exception ) { // JsonParser does not throw IOException for String throw new RuntimeException( exception ); } }
java
{ "resource": "" }
q176625
Activator.getImageDescriptor
test
public static ImageDescriptor getImageDescriptor(String id) { ImageDescriptor retVal = getDefault().getImageRegistry().getDescriptor(id); if (retVal == null) { retVal = loadImageDescriptor(id); getDefault().getImageRegistry().put(id, retVal); } return retVal; }
java
{ "resource": "" }
q176626
HttpClient.invoke
test
public Response invoke(Request request) throws IOException { Assert.isNotNull(request); try { open(); URL resourceUrl = request.getResourceUrl(); URL originServerUrl = new URL(resourceUrl.getProtocol(), resourceUrl.getHost(), resourceUrl.getPort(), "/"); //$NON-NLS-1$ URL proxyServerUrl = getProxyServerUrl(originServerUrl); if (proxyServerUrl == null && !matchesProxyServerException(originServerUrl)) { proxyServerUrl = getDefaultProxyServerUrl(); } IContext context = webDAVFactory.newContext(request.getContext()); IContext defaultContext = getContext(originServerUrl); if (defaultContext == null) { defaultContext = getDefaultContext(); } if (defaultContext != null) { Enumeration e = defaultContext.keys(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); context.put(key, defaultContext.get(key)); } } if (authority != null) { authority.authorize(request, null, context, proxyServerUrl, true); authority.authorize(request, null, context, proxyServerUrl, false); } return invoke1(request, context, proxyServerUrl, originServerUrl, 0, 0); } finally { request.close(); } }
java
{ "resource": "" }
q176627
HttpConnection.setRequestHeaderField
test
public void setRequestHeaderField(String fieldName, String fieldValue) { Assert.isNotNull(fieldName); Assert.isNotNull(fieldValue); endRequest(); requestHeader.addField(fieldName, fieldValue); }
java
{ "resource": "" }
q176628
NewDroolsProjectWizard.createRuleSampleLauncher
test
private void createRuleSampleLauncher(IJavaProject project) throws JavaModelException, IOException { Version version = startPage.getRuntime().getVersion(); if (version.getMajor()==4) { createProjectJavaFile(project, "org/drools/eclipse/wizard/project/RuleLauncherSample_4.java.template", "DroolsTest.java"); } else if (version.getMajor()==5) { createProjectJavaFile(project, "org/drools/eclipse/wizard/project/RuleLauncherSample_5.java.template", "DroolsTest.java"); } else if (version.getMajor()>=6) { createProjectJavaFile(project, "org/drools/eclipse/wizard/project/RuleLauncherSample_6.java.template", "DroolsTest.java"); } }
java
{ "resource": "" }
q176629
NewDroolsProjectWizard.createRule
test
private void createRule(IJavaProject project, IProgressMonitor monitor) throws CoreException { if (startPage.getRuntime().getVersion().getMajor()>=6) { FileUtils.createFolder(project, "src/main/resources/com/sample/rules", monitor); createProjectFile(project, monitor, "org/drools/eclipse/wizard/project/Sample.drl.template", "src/main/resources/com/sample/rules", "Sample.drl"); } else { createProjectFile(project, monitor, "org/drools/eclipse/wizard/project/Sample.drl.template", "src/main/rules", "Sample.drl"); } }
java
{ "resource": "" }
q176630
NewDroolsProjectWizard.createRuleFlow
test
private void createRuleFlow(IJavaProject project, IProgressMonitor monitor) throws CoreException { Version version = startPage.getRuntime().getVersion(); if (version.getMajor()==4) { createProjectFile(project, monitor, "org/drools/eclipse/wizard/project/ruleflow_4.rf.template", "src/main/rules", "ruleflow.rf"); createProjectFile(project, monitor, "org/drools/eclipse/wizard/project/ruleflow_4.rfm.template", "src/main/rules", "ruleflow.rfm"); createProjectFile(project, monitor, "org/drools/eclipse/wizard/project/ruleflow_4.drl.template", "src/main/rules", "ruleflow.drl"); } else if (version.getMajor()==5 && version.getMinor()==0) { createProjectFile(project, monitor, "org/drools/eclipse/wizard/project/ruleflow.rf.template", "src/main/rules", "ruleflow.rf"); } else if (version.getMajor()==5) { createProjectFile(project, monitor, "org/drools/eclipse/wizard/project/sample.bpmn.template", "src/main/rules", "sample.bpmn"); } else { FileUtils.createFolder(project, "src/main/resources/com/sample/process", monitor); createProjectFile(project, monitor, "org/drools/eclipse/wizard/project/sample.bpmn.template", "src/main/resources/com/sample/process", "sample.bpmn"); } }
java
{ "resource": "" }
q176631
NewDroolsProjectWizard.createRuleFlowSampleLauncher
test
private void createRuleFlowSampleLauncher(IJavaProject project) throws JavaModelException, IOException { String s; Version version = startPage.getRuntime().getVersion(); if (version.getMajor()==4) { s = "org/drools/eclipse/wizard/project/RuleFlowLauncherSample_4.java.template"; } else if (version.getMajor()==5 && version.getMinor()==0) { s = "org/drools/eclipse/wizard/project/RuleFlowLauncherSample.java.template"; } else if (version.getMajor()==5) { s = "org/drools/eclipse/wizard/project/ProcessLauncherSample_bpmn_5.java.template"; } else { s = "org/drools/eclipse/wizard/project/ProcessLauncherSample_bpmn_6.java.template"; } createProjectJavaFile(project, s, "ProcessTest.java"); }
java
{ "resource": "" }
q176632
IUTreeViewer.getSelectedIUs
test
public List<IInstallableUnit> getSelectedIUs(){ List<IInstallableUnit> result = new ArrayList<IInstallableUnit>(); for (Object o : getCheckedElements()) { if (o instanceof IUTreeItem) { IUTreeItem item = (IUTreeItem) o; if (item.parent!=null) result.add(item.iu); } } return result; }
java
{ "resource": "" }
q176633
GenericModelEditor.createImage
test
public void createImage(OutputStream stream, int format) { SWTGraphics g = null; GC gc = null; Image image = null; LayerManager layerManager = (LayerManager) getGraphicalViewer().getEditPartRegistry().get(LayerManager.ID); IFigure figure = layerManager.getLayer(LayerConstants.PRINTABLE_LAYERS); Rectangle r = figure.getBounds(); try { image = new Image(Display.getDefault(), r.width, r.height); gc = new GC(image); g = new SWTGraphics(gc); g.translate(r.x * -1, r.y * -1); figure.paint(g); ImageLoader imageLoader = new ImageLoader(); imageLoader.data = new ImageData[] { image.getImageData() }; imageLoader.save(stream, format); } catch (Throwable t) { DroolsEclipsePlugin.log(t); } finally { if (g != null) { g.dispose(); } if (gc != null) { gc.dispose(); } if (image != null) { image.dispose(); } } }
java
{ "resource": "" }
q176634
AlphaNodeVertex.getFieldName
test
public String getFieldName() { AlphaNodeFieldConstraint constraint = this.node.getConstraint(); if (constraint instanceof MvelConstraint) { MvelConstraint mvelConstraint = (MvelConstraint) constraint; InternalReadAccessor accessor = mvelConstraint.getFieldExtractor(); if (accessor instanceof ClassFieldReader) { return ((ClassFieldReader) accessor).getFieldName(); } } return null; }
java
{ "resource": "" }
q176635
AlphaNodeVertex.getEvaluator
test
public String getEvaluator() { AlphaNodeFieldConstraint constraint = this.node.getConstraint(); if (constraint instanceof MvelConstraint) { MvelConstraint mvelConstraint = (MvelConstraint) constraint; return mvelConstraint.toString(); } return null; }
java
{ "resource": "" }
q176636
AlphaNodeVertex.getValue
test
public String getValue() { AlphaNodeFieldConstraint constraint = this.node.getConstraint(); if (constraint instanceof MvelConstraint) { MvelConstraint mvelConstraint = (MvelConstraint) constraint; FieldValue field = mvelConstraint.getField(); return field != null ? field.toString() : null; } return null; }
java
{ "resource": "" }
q176637
WebDavClient.addGuvnorResourceProperties
test
private void addGuvnorResourceProperties(ResourceProperties props, String filename, String resource) throws Exception { if (props == null) { return; } IResponse response = null; try { String path = resource.substring(0, resource.lastIndexOf('/')); String apiVer = changeToAPICall(path); Properties guvProps = new Properties(); response = getResourceInputStream(apiVer); guvProps.load(response.getInputStream()); String val = guvProps.getProperty(filename); if (val != null) { StringTokenizer tokens = new StringTokenizer(val, ","); //$NON-NLS-1$ // String dateStamp = tokens.nextToken(); // String revision = tokens.nextToken(); if(tokens.hasMoreElements()){ props.setLastModifiedDate(tokens.nextToken()); } if(tokens.hasMoreElements()){ props.setRevision(tokens.nextToken()); } } else { Exception nfe = new Exception("Failed to get Guvnor properties for " + filename); //$NON-NLS-1$ Activator.getDefault().writeLog(IStatus.WARNING, nfe.getMessage(), nfe); } } finally { if (response != null) { response.close(); } } }
java
{ "resource": "" }
q176638
CollectionHandle.baselineControl
test
public void baselineControl(ILocator baseline) throws DAVException { Assert.isNotNull(baseline); // Build the document body to describe the baseline control element. Document document = newDocument(); Element root = ElementEditor.create(document, "baseline-control"); //$NON-NLS-1$ ElementEditor.addChild(root, "baseline", //$NON-NLS-1$ baseline.getResourceURL(), new String[] {"baseline"}, //$NON-NLS-1$ true); // Send the baseline control method to the server and check the response. IResponse response = null; try { response = davClient.baselineControl(locator, newContext(), document); examineResponse(response); } catch (IOException e) { throw new SystemException(e); } finally { closeResponse(response); } }
java
{ "resource": "" }
q176639
CollectionHandle.bind
test
public void bind(String member, ILocator source) throws DAVException { bind(member, source, false); }
java
{ "resource": "" }
q176640
CollectionHandle.getMember
test
public ILocator getMember(String memberName) { Assert.isTrue(locator.getLabel() == null); Assert.isTrue(!locator.isStable()); String parentName = locator.getResourceURL(); String childName; if (parentName.endsWith("/")) //$NON-NLS-1$ childName = parentName + memberName; else childName = parentName + "/" + memberName; //$NON-NLS-1$ return davClient.getDAVFactory().newLocator(childName); }
java
{ "resource": "" }
q176641
Row.optimize
test
public void optimize() { final List<BaseVertex> sorted = new ArrayList<BaseVertex>( this.vertices ); Collections.sort(sorted, new Comparator<BaseVertex>() { public int compare(final BaseVertex v1, final BaseVertex v2) { int v1OutDegree = v1.getSourceConnections().size(); int v2OutDegree = v2.getSourceConnections().size(); if (v1OutDegree < v2OutDegree) { return 1; } if (v1OutDegree > v2OutDegree) { return -1; } return 0; } }); final LinkedList<BaseVertex> optimized = new LinkedList<BaseVertex>(); boolean front = false; for ( final Iterator<BaseVertex> vertexIter = sorted.iterator(); vertexIter.hasNext(); ) { final BaseVertex vertex = vertexIter.next(); if ( front ) { optimized.addFirst( vertex ); } else { optimized.addLast( vertex ); } front = !front; } this.vertices = optimized; }
java
{ "resource": "" }
q176642
ExportImageDialog.initializeControls
test
private void initializeControls() { if (originalFile != null) { resourceGroup.setContainerFullPath(originalFile.getParent() .getFullPath()); String fileName = originalFile.getName(); int index = fileName.lastIndexOf("."); if (index != -1) { fileName = fileName.substring(0, index); } fileName += "-image.png"; resourceGroup.setResource(fileName); } else if (originalName != null) { resourceGroup.setResource(originalName); } setDialogComplete(validatePage()); }
java
{ "resource": "" }
q176643
ExportImageDialog.validatePage
test
private boolean validatePage() { if (!resourceGroup.areAllValuesValid()) { if (!resourceGroup.getResource().equals("")) { //$NON-NLS-1$ setErrorMessage(resourceGroup.getProblemMessage()); } else { setErrorMessage(null); } return false; } String resourceName = resourceGroup.getResource(); IWorkspace workspace = ResourcesPlugin.getWorkspace(); // Do not allow a closed project to be selected IPath fullPath = resourceGroup.getContainerFullPath(); if (fullPath != null) { String projectName = fullPath.segment(0); IStatus isValidProjectName = workspace.validateName(projectName, IResource.PROJECT); if(isValidProjectName.isOK()) { IProject project = workspace.getRoot().getProject(projectName); if(!project.isOpen()) { setErrorMessage(IDEWorkbenchMessages.SaveAsDialog_closedProjectMessage); return false; } } } IStatus result = workspace.validateName(resourceName, IResource.FILE); if (!result.isOK()){ setErrorMessage(result.getMessage()); return false; } setErrorMessage(null); return true; }
java
{ "resource": "" }
q176644
EntityTag.generateEntityTag
test
public static EntityTag generateEntityTag() { String xx = basetime + ":" + Integer.toHexString(Thread.currentThread().hashCode()); //$NON-NLS-1$ bcnt++; xx += ":" + bcnt; //$NON-NLS-1$ return new EntityTag(xx); }
java
{ "resource": "" }
q176645
Connection.getOpposite
test
public BaseVertex getOpposite(BaseVertex vertex) { // If null or not part of this connection if ( vertex == null || (!vertex.equals( getSource() ) && !vertex.equals( getTarget() )) ) { return null; } if ( vertex.equals( getSource() ) ) { return getTarget(); } return getSource(); }
java
{ "resource": "" }
q176646
YubikeyLoginModule.validate_otps
test
private boolean validate_otps(List<String> otps, NameCallback nameCb) throws LoginException { boolean validated = false; for (String otp : otps) { log.trace("Checking OTP {}", otp); VerificationResponse ykr; try { ykr = this.yc.verify(otp); } catch (YubicoVerificationException e) { log.warn("Errors during validation: ", e); throw new LoginException("Errors during validation: " + e.getMessage()); } catch (YubicoValidationFailure e) { log.warn("Something went very wrong during authentication: ", e); throw new LoginException("Something went very wrong during authentication: " + e.getMessage()); } if (ykr != null) { log.trace("OTP {} verify result : {}", otp, ykr.getStatus().toString()); if (ykr.getStatus() == ResponseStatus.OK) { String publicId = YubicoClient.getPublicId(otp); log.info("OTP verified successfully (YubiKey id {})", publicId); if (is_right_user(nameCb.getName(), publicId)) { this.principals.add(new YubikeyPrincipal(publicId, this.idRealm)); /* Don't just return here, we want to "consume" all OTPs if * more than one is provided. */ validated = true; } } else { log.debug("OTP validation returned {}", ykr.getStatus().toString()); } } } return validated; }
java
{ "resource": "" }
q176647
YubikeyLoginModule.is_right_user
test
private boolean is_right_user(String username, String publicId) { log.debug("Check if YubiKey {} belongs to user {}", publicId, username); return this.ykmap.is_right_user(username, publicId); }
java
{ "resource": "" }
q176648
YubikeyToUserMapImpl.get_username_for_id
test
private String get_username_for_id(String publicId, String filename) throws FileNotFoundException { Scanner sc = null; File file = new File(filename); try { sc = new Scanner(file); while (sc.hasNextLine()) { String line = sc.nextLine(); if (line.startsWith("yk." + publicId + ".user")) { String ykuser = line.split("=")[1].trim(); return ykuser; } } } finally { if (sc != null) { sc.close(); } } return null; }
java
{ "resource": "" }
q176649
YubikeyToUserMapImpl.add_yubikey_to_user
test
private void add_yubikey_to_user(String publicId, String username, String filename) { try { File file = new File(filename); FileWriter writer = new FileWriter(file, true); writer.write("yk." + publicId + ".user = " + username + System.getProperty("line.separator")); writer.close(); } catch (IOException ex) { log.error("Failed appending entry to file {}", filename, ex); } }
java
{ "resource": "" }
q176650
HttpOathOtpLoginModule.verify_otp
test
boolean verify_otp(String userName, String otp) { try { String authString = userName + ":" + otp; String authStringEnc = Base64.encodeBase64URLSafeString(authString.getBytes()); BufferedReader in = attemptAuthentication(authStringEnc); String inputLine; while ((inputLine = in.readLine()) != null) { if (inputLine.contains(expectedOutput)) { return true; } } } catch (Exception ex) { log.error("Failed verifying OATH OTP :", ex); } return false; }
java
{ "resource": "" }
q176651
MultiValuePasswordCallback.clearPassword
test
public void clearPassword() { for (char pw[] : this.secrets) { for (int i = 0; i < pw.length; i++) { pw[i] = 0; } } /* Now discard the list. */ this.secrets = new ArrayList<char []>(); }
java
{ "resource": "" }
q176652
YubicoClient.getPublicId
test
public static String getPublicId(String otp) { if ((otp == null) || (otp.length() < OTP_MIN_LEN)){ //not a valid OTP format, throw an exception throw new IllegalArgumentException("The OTP is too short to be valid"); } Integer len = otp.length(); /* The OTP part is always the last 32 bytes of otp. Whatever is before that * (if anything) is the public ID of the YubiKey. The ID can be set to '' * through personalization. */ return otp.substring(0, len - 32).toLowerCase(); }
java
{ "resource": "" }
q176653
YubicoClient.isValidOTPFormat
test
public static boolean isValidOTPFormat(String otp) { if (otp == null){ return false; } int len = otp.length(); for (char c : otp.toCharArray()) { if (c < 0x20 || c > 0x7E) { return false; } } return OTP_MIN_LEN <= len && len <= OTP_MAX_LEN; }
java
{ "resource": "" }
q176654
EvaluationPool.create
test
public Evaluation create(SimpleNode node, Object source) { return create(node, source, false); }
java
{ "resource": "" }
q176655
EvaluationPool.create
test
public Evaluation create(SimpleNode node, Object source, boolean setOperation) { // synchronization is removed as we do not rely anymore on the in-house object pooling return new Evaluation(node, source, setOperation); }
java
{ "resource": "" }
q176656
OgnlRuntime.clearCache
test
public static void clearCache() { _methodParameterTypesCache.clear(); _ctorParameterTypesCache.clear(); _propertyDescriptorCache.clear(); _constructorCache.clear(); _staticMethodCache.clear(); _instanceMethodCache.clear(); _invokePermissionCache.clear(); _fieldCache.clear(); _superclasses.clear(); _declaredMethods[0].clear(); _declaredMethods[1].clear(); _methodAccessCache.clear(); _methodPermCache.clear(); }
java
{ "resource": "" }
q176657
OgnlRuntime.isJdk15
test
public static boolean isJdk15() { if (_jdkChecked) return _jdk15; try { Class.forName("java.lang.annotation.Annotation"); _jdk15 = true; } catch (Exception e) { /* ignore */ } _jdkChecked = true; return _jdk15; }
java
{ "resource": "" }
q176658
OgnlRuntime.getPackageName
test
public static String getPackageName(Object o) { return (o == null) ? null : getClassPackageName(o.getClass()); }
java
{ "resource": "" }
q176659
OgnlRuntime.getClassPackageName
test
public static String getClassPackageName(Class c) { String s = c.getName(); int i = s.lastIndexOf('.'); return (i < 0) ? null : s.substring(0, i); }
java
{ "resource": "" }
q176660
OgnlRuntime.getUniqueDescriptor
test
public static String getUniqueDescriptor(Object object, boolean fullyQualified) { StringBuffer result = new StringBuffer(); if (object != null) { if (object instanceof Proxy) { Class interfaceClass = object.getClass().getInterfaces()[0]; result.append(getClassName(interfaceClass, fullyQualified)); result.append('^'); object = Proxy.getInvocationHandler(object); } result.append(getClassName(object, fullyQualified)); result.append('@'); result.append(getPointerString(object)); } else { result.append(NULL_OBJECT_STRING); } return new String(result); }
java
{ "resource": "" }
q176661
OgnlRuntime.getArgClass
test
public static final Class getArgClass(Object arg) { if (arg == null) return null; Class c = arg.getClass(); if (c == Boolean.class) return Boolean.TYPE; else if (c.getSuperclass() == Number.class) { if (c == Integer.class) return Integer.TYPE; if (c == Double.class) return Double.TYPE; if (c == Byte.class) return Byte.TYPE; if (c == Long.class) return Long.TYPE; if (c == Float.class) return Float.TYPE; if (c == Short.class) return Short.TYPE; } else if (c == Character.class) return Character.TYPE; return c; }
java
{ "resource": "" }
q176662
OgnlRuntime.isMoreSpecific
test
public static final boolean isMoreSpecific(Class[] classes1, Class[] classes2) { for (int index = 0, count = classes1.length; index < count; ++index) { Class c1 = classes1[index], c2 = classes2[index]; if (c1 == c2) continue; else if (c1.isPrimitive()) return true; else if (c1.isAssignableFrom(c2)) return false; else if (c2.isAssignableFrom(c1)) return true; } // They are the same! So the first is not more specific than the second. return false; }
java
{ "resource": "" }
q176663
OgnlRuntime.getAppropriateMethod
test
public static Method getAppropriateMethod(OgnlContext context, Object source, Object target, String propertyName, String methodName, List methods, Object[] args, Object[] actualArgs) { Method result = null; if (methods != null) { Class typeClass = target != null ? target.getClass() : null; if (typeClass == null && source != null && Class.class.isInstance(source)) { typeClass = (Class)source; } Class[] argClasses = getArgClasses(args); MatchingMethod mm = findBestMethod(methods, typeClass, methodName, argClasses); if (mm != null) { result = mm.mMethod; Class[] mParameterTypes = mm.mParameterTypes; System.arraycopy(args, 0, actualArgs, 0, args.length); for (int j = 0; j < mParameterTypes.length; j++) { Class type = mParameterTypes[j]; if (mm.report.conversionNeeded[j] || (type.isPrimitive() && (actualArgs[j] == null))) { actualArgs[j] = getConvertedType(context, source, result, propertyName, args[j], type); } } } } if (result == null) { result = getConvertedMethodAndArgs(context, target, propertyName, methods, args, actualArgs); } return result; }
java
{ "resource": "" }
q176664
OgnlRuntime.getMethodValue
test
public static final Object getMethodValue(OgnlContext context, Object target, String propertyName, boolean checkAccessAndExistence) throws OgnlException, IllegalAccessException, NoSuchMethodException, IntrospectionException { Object result = null; Method m = getGetMethod(context, (target == null) ? null : target.getClass() , propertyName); if (m == null) m = getReadMethod((target == null) ? null : target.getClass(), propertyName, null); if (checkAccessAndExistence) { if ((m == null) || !context.getMemberAccess().isAccessible(context, target, m, propertyName)) { result = NotFound; } } if (result == null) { if (m != null) { try { result = invokeMethod(target, m, NoArguments); } catch (InvocationTargetException ex) { throw new OgnlException(propertyName, ex.getTargetException()); } } else { throw new NoSuchMethodException(propertyName); } } return result; }
java
{ "resource": "" }
q176665
OgnlRuntime.getPropertyDescriptors
test
public static Map getPropertyDescriptors(Class targetClass) throws IntrospectionException, OgnlException { Map result; if ((result = (Map) _propertyDescriptorCache.get(targetClass)) == null) { synchronized (_propertyDescriptorCache) { if ((result = (Map) _propertyDescriptorCache.get(targetClass)) == null) { PropertyDescriptor[] pda = Introspector.getBeanInfo(targetClass).getPropertyDescriptors(); result = new HashMap(101); for (int i = 0, icount = pda.length; i < icount; i++) { // workaround for Introspector bug 6528714 (bugs.sun.com) if (pda[i].getReadMethod() != null && !isMethodCallable(pda[i].getReadMethod())) { pda[i].setReadMethod(findClosestMatchingMethod(targetClass, pda[i].getReadMethod(), pda[i].getName(), pda[i].getPropertyType(), true)); } if (pda[i].getWriteMethod() != null && !isMethodCallable(pda[i].getWriteMethod())) { pda[i].setWriteMethod(findClosestMatchingMethod(targetClass, pda[i].getWriteMethod(), pda[i].getName(), pda[i].getPropertyType(), false)); } result.put(pda[i].getName(), pda[i]); } findObjectIndexedPropertyDescriptors(targetClass, result); _propertyDescriptorCache.put(targetClass, result); } } } return result; }
java
{ "resource": "" }
q176666
OgnlRuntime.getPropertyDescriptorFromArray
test
public static PropertyDescriptor getPropertyDescriptorFromArray(Class targetClass, String name) throws IntrospectionException { PropertyDescriptor result = null; PropertyDescriptor[] pda = getPropertyDescriptorsArray(targetClass); for (int i = 0, icount = pda.length; (result == null) && (i < icount); i++) { if (pda[i].getName().compareTo(name) == 0) { result = pda[i]; } } return result; }
java
{ "resource": "" }
q176667
OgnlRuntime.getReadMethod
test
public static Method getReadMethod(Class target, String name) { return getReadMethod(target, name, null); }
java
{ "resource": "" }
q176668
JavaCharStream.readChar
test
public char readChar() throws java.io.IOException { if (inBuf > 0) { --inBuf; if (++bufpos == bufsize) bufpos = 0; return buffer[bufpos]; } char c; if (++bufpos == available) AdjustBuffSize(); if ((buffer[bufpos] = c = ReadByte()) == '\\') { UpdateLineColumn(c); int backSlashCnt = 1; for (;;) // Read all the backslashes { if (++bufpos == available) AdjustBuffSize(); try { if ((buffer[bufpos] = c = ReadByte()) != '\\') { UpdateLineColumn(c); // found a non-backslash char. if ((c == 'u') && ((backSlashCnt & 1) == 1)) { if (--bufpos < 0) bufpos = bufsize - 1; break; } backup(backSlashCnt); return '\\'; } } catch(java.io.IOException e) { if (backSlashCnt > 1) backup(backSlashCnt-1); return '\\'; } UpdateLineColumn(c); backSlashCnt++; } // Here, we have seen an odd number of backslash's followed by a 'u' try { while ((c = ReadByte()) == 'u') ++column; buffer[bufpos] = c = (char)(hexval(c) << 12 | hexval(ReadByte()) << 8 | hexval(ReadByte()) << 4 | hexval(ReadByte())); column += 4; } catch(java.io.IOException e) { throw new Error("Invalid escape character at line " + line + " column " + column + "."); } if (backSlashCnt == 1) return c; else { backup(backSlashCnt - 1); return '\\'; } } else { UpdateLineColumn(c); return c; } }
java
{ "resource": "" }
q176669
OgnlParser.projection
test
final public void projection() throws ParseException { /*@bgen(jjtree) Project */ ASTProject jjtn000 = new ASTProject(JJTPROJECT); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); try { jj_consume_token(54); expression(); jj_consume_token(55); } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte000;} } if (jjte000 instanceof ParseException) { {if (true) throw (ParseException)jjte000;} } {if (true) throw (Error)jjte000;} } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } }
java
{ "resource": "" }
q176670
OgnlParser.selectAll
test
final public void selectAll() throws ParseException { /*@bgen(jjtree) Select */ ASTSelect jjtn000 = new ASTSelect(JJTSELECT); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); try { jj_consume_token(54); jj_consume_token(3); expression(); jj_consume_token(55); } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte000;} } if (jjte000 instanceof ParseException) { {if (true) throw (ParseException)jjte000;} } {if (true) throw (Error)jjte000;} } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } }
java
{ "resource": "" }
q176671
OgnlOps.longValue
test
public static long longValue(Object value) throws NumberFormatException { if (value == null) return 0L; Class c = value.getClass(); if (c.getSuperclass() == Number.class) return ((Number) value).longValue(); if (c == Boolean.class) return ((Boolean) value).booleanValue() ? 1 : 0; if (c == Character.class) return ((Character) value).charValue(); return Long.parseLong(stringValue(value, true)); }
java
{ "resource": "" }
q176672
OgnlOps.doubleValue
test
public static double doubleValue(Object value) throws NumberFormatException { if (value == null) return 0.0; Class c = value.getClass(); if (c.getSuperclass() == Number.class) return ((Number) value).doubleValue(); if (c == Boolean.class) return ((Boolean) value).booleanValue() ? 1 : 0; if (c == Character.class) return ((Character) value).charValue(); String s = stringValue(value, true); return (s.length() == 0) ? 0.0 : Double.parseDouble(s); }
java
{ "resource": "" }
q176673
OgnlOps.bigIntValue
test
public static BigInteger bigIntValue(Object value) throws NumberFormatException { if (value == null) return BigInteger.valueOf(0L); Class c = value.getClass(); if (c == BigInteger.class) return (BigInteger) value; if (c == BigDecimal.class) return ((BigDecimal) value).toBigInteger(); if (c.getSuperclass() == Number.class) return BigInteger.valueOf(((Number) value).longValue()); if (c == Boolean.class) return BigInteger.valueOf(((Boolean) value).booleanValue() ? 1 : 0); if (c == Character.class) return BigInteger.valueOf(((Character) value).charValue()); return new BigInteger(stringValue(value, true)); }
java
{ "resource": "" }
q176674
OgnlOps.bigDecValue
test
public static BigDecimal bigDecValue(Object value) throws NumberFormatException { if (value == null) return BigDecimal.valueOf(0L); Class c = value.getClass(); if (c == BigDecimal.class) return (BigDecimal) value; if (c == BigInteger.class) return new BigDecimal((BigInteger) value); if (c == Boolean.class) return BigDecimal.valueOf(((Boolean) value).booleanValue() ? 1 : 0); if (c == Character.class) return BigDecimal.valueOf(((Character) value).charValue()); return new BigDecimal(stringValue(value, true)); }
java
{ "resource": "" }
q176675
OgnlOps.stringValue
test
public static String stringValue(Object value, boolean trim) { String result; if (value == null) { result = OgnlRuntime.NULL_STRING; } else { result = value.toString(); if (trim) { result = result.trim(); } } return result; }
java
{ "resource": "" }
q176676
OgnlOps.getNumericType
test
public static int getNumericType(Object value) { if (value != null) { Class c = value.getClass(); if (c == Integer.class) return INT; if (c == Double.class) return DOUBLE; if (c == Boolean.class) return BOOL; if (c == Byte.class) return BYTE; if (c == Character.class) return CHAR; if (c == Short.class) return SHORT; if (c == Long.class) return LONG; if (c == Float.class) return FLOAT; if (c == BigInteger.class) return BIGINT; if (c == BigDecimal.class) return BIGDEC; } return NONNUMERIC; }
java
{ "resource": "" }
q176677
OgnlOps.convertValue
test
public static Object convertValue(Object value, Class toType) { return convertValue(value, toType, false); }
java
{ "resource": "" }
q176678
OgnlOps.getIntValue
test
public static int getIntValue(Object value) { try { if (value == null) return -1; if (Number.class.isInstance(value)) { return ((Number)value).intValue(); } String str = String.class.isInstance(value) ? (String)value : value.toString(); return Integer.parseInt(str); } catch (Throwable t) { throw new RuntimeException("Error converting " + value + " to integer:", t); } }
java
{ "resource": "" }
q176679
OgnlOps.getNumericType
test
public static int getNumericType(int t1, int t2, boolean canBeNonNumeric) { if (t1 == t2) return t1; if (canBeNonNumeric && (t1 == NONNUMERIC || t2 == NONNUMERIC || t1 == CHAR || t2 == CHAR)) return NONNUMERIC; if (t1 == NONNUMERIC) t1 = DOUBLE; // Try to interpret strings as doubles... if (t2 == NONNUMERIC) t2 = DOUBLE; // Try to interpret strings as doubles... if (t1 >= MIN_REAL_TYPE) { if (t2 >= MIN_REAL_TYPE) return Math.max(t1, t2); if (t2 < INT) return t1; if (t2 == BIGINT) return BIGDEC; return Math.max(DOUBLE, t1); } else if (t2 >= MIN_REAL_TYPE) { if (t1 < INT) return t2; if (t1 == BIGINT) return BIGDEC; return Math.max(DOUBLE, t2); } else return Math.max(t1, t2); }
java
{ "resource": "" }
q176680
OgnlOps.getNumericType
test
public static int getNumericType(Object v1, Object v2, boolean canBeNonNumeric) { return getNumericType(getNumericType(v1), getNumericType(v2), canBeNonNumeric); }
java
{ "resource": "" }
q176681
OgnlOps.newInteger
test
public static Number newInteger(int type, long value) { switch(type) { case BOOL: case CHAR: case INT: return new Integer((int) value); case FLOAT: if ((long) (float) value == value) { return new Float((float) value); } // else fall through: case DOUBLE: if ((long) (double) value == value) { return new Double((double) value); } // else fall through: case LONG: return new Long(value); case BYTE: return new Byte((byte) value); case SHORT: return new Short((short) value); default: return BigInteger.valueOf(value); } }
java
{ "resource": "" }
q176682
OgnlContext.popEvaluation
test
public Evaluation popEvaluation() { Evaluation result; result = _currentEvaluation; setCurrentEvaluation(result.getParent()); if (_currentEvaluation == null) { setLastEvaluation(getKeepLastEvaluation() ? result : null); setRootEvaluation(null); setCurrentNode(null); } return result; }
java
{ "resource": "" }
q176683
ExpressionCompiler.generateOgnlGetter
test
protected String generateOgnlGetter(CtClass clazz, CtMethod valueGetter, CtField node) throws Exception { String body = "return " + node.getName() + ".getValue($1, $2);"; valueGetter.setBody(body); clazz.addMethod(valueGetter); return body; }
java
{ "resource": "" }
q176684
ExpressionCompiler.generateOgnlSetter
test
protected String generateOgnlSetter(CtClass clazz, CtMethod valueSetter, CtField node) throws Exception { String body = node.getName() + ".setValue($1, $2, $3);"; valueSetter.setBody(body); clazz.addMethod(valueSetter); return body; }
java
{ "resource": "" }
q176685
SimpleNode.flattenTree
test
protected void flattenTree() { boolean shouldFlatten = false; int newSize = 0; for (int i = 0; i < _children.length; ++i) if (_children[i].getClass() == getClass()) { shouldFlatten = true; newSize += _children[i].jjtGetNumChildren(); } else ++newSize; if (shouldFlatten) { Node[] newChildren = new Node[newSize]; int j = 0; for (int i = 0; i < _children.length; ++i) { Node c = _children[i]; if (c.getClass() == getClass()) { for (int k = 0; k < c.jjtGetNumChildren(); ++k) newChildren[j++] = c.jjtGetChild(k); } else newChildren[j++] = c; } if (j != newSize) throw new Error("Assertion error: " + j + " != " + newSize); _children = newChildren; } }
java
{ "resource": "" }
q176686
Evaluation.init
test
public void init(SimpleNode node, Object source, boolean setOperation) { this.node = node; this.source = source; this.setOperation = setOperation; result = null; exception = null; parent = null; next = null; previous = null; firstChild = null; lastChild = null; }
java
{ "resource": "" }
q176687
OgnlParserTokenManager.escapeChar
test
private char escapeChar() { int ofs = image.length() - 1; switch ( image.charAt(ofs) ) { case 'n': return '\n'; case 'r': return '\r'; case 't': return '\t'; case 'b': return '\b'; case 'f': return '\f'; case '\\': return '\\'; case '\'': return '\''; case '\"': return '\"'; } // Otherwise, it's an octal number. Find the backslash and convert. while ( image.charAt(--ofs) != '\\' ) {} int value = 0; while ( ++ofs < image.length() ) value = (value << 3) | (image.charAt(ofs) - '0'); return (char) value; }
java
{ "resource": "" }
q176688
Ognl.setRoot
test
public static void setRoot(Map context, Object root) { context.put(OgnlContext.ROOT_CONTEXT_KEY, root); }
java
{ "resource": "" }
q176689
Ognl.getValue
test
public static Object getValue(String expression, Map context, Object root) throws OgnlException { return getValue(expression, context, root, null); }
java
{ "resource": "" }
q176690
Ognl.setValue
test
public static void setValue(ExpressionAccessor expression, OgnlContext context, Object root, Object value) { expression.set(context, root, value); }
java
{ "resource": "" }
q176691
Ognl.setValue
test
public static void setValue(Object tree, Object root, Object value) throws OgnlException { setValue(tree, createDefaultContext(root), root, value); }
java
{ "resource": "" }
q176692
Ognl.isConstant
test
public static boolean isConstant(String expression, Map context) throws OgnlException { return isConstant(parseExpression(expression), context); }
java
{ "resource": "" }
q176693
FileWatchServices.getDefaultWatchServiceId
test
public static String getDefaultWatchServiceId() { String result = "polling"; String osName = System.getProperty( "os.name" ); if ( osName != null ) { osName = osName.toLowerCase( Locale.ENGLISH ); if ( osName.contains( "windows" ) || osName.contains( "linux" ) ) { result = isAtLeastJava7() ? "jdk7" : "jnotify"; } else if ( osName.contains( "mac" ) ) { result = "jnotify"; } } return result; }
java
{ "resource": "" }
q176694
AbstractPlay2StartServerMojo.waitForServerStarted
test
protected void waitForServerStarted( String rootUrl, JavaRunnable runner, int startTimeout, boolean spawned ) throws MojoExecutionException, IOException { long endTimeMillis = startTimeout > 0 ? System.currentTimeMillis() + startTimeout : 0L; boolean started = false; URL connectUrl = new URL( rootUrl ); int verifyWaitDelay = 1000; while ( !started ) { if ( startTimeout > 0 && endTimeMillis - System.currentTimeMillis() < 0L ) { if ( spawned ) { InternalPlay2StopMojo internalStop = new InternalPlay2StopMojo(); internalStop.project = project; try { internalStop.execute(); } catch ( MojoExecutionException e ) { // just ignore } catch ( MojoFailureException e ) { // just ignore } } throw new MojoExecutionException( String.format( "Failed to start Play! server in %d ms", Integer.valueOf( startTimeout ) ) ); } BuildException runnerException = runner.getException(); if ( runnerException != null ) { throw new MojoExecutionException( "Play! server start exception", runnerException ); } try { URLConnection conn = connectUrl.openConnection(); if ( startTimeout > 0 ) { int connectTimeOut = Long.valueOf( Math.min( endTimeMillis - System.currentTimeMillis(), Integer.valueOf( Integer.MAX_VALUE ).longValue() ) ).intValue(); if ( connectTimeOut > 0 ) { conn.setConnectTimeout( connectTimeOut ); } } connectUrl.openConnection().getContent(); started = true; } catch ( Exception e ) { // return false; } if ( !started ) { long sleepTime = verifyWaitDelay; if ( startTimeout > 0 ) { sleepTime = Math.min( sleepTime, endTimeMillis - System.currentTimeMillis() ); } if ( sleepTime > 0 ) { try { Thread.sleep( sleepTime ); } catch ( InterruptedException e ) { throw new MojoExecutionException( "?", e ); } } } } }
java
{ "resource": "" }
q176695
Play2BuildFailure.readFileAsString
test
private String readFileAsString() throws IOException { FileInputStream is = new FileInputStream( e.source() ); try { byte[] buffer = new byte[8192]; int len = is.read( buffer ); ByteArrayOutputStream out = new ByteArrayOutputStream(); while ( len != -1 ) { out.write( buffer, 0, len ); len = is.read( buffer ); } return charsetName != null ? new String( out.toByteArray(), charsetName ) : new String( out.toByteArray() ); } finally { is.close(); } }
java
{ "resource": "" }
q176696
Reloader.reload
test
@Override /* BuildLink interface */ public synchronized Object reload() { Object result = null; try { boolean reloadRequired = buildLink.build(); if ( reloadRequired ) { int version = ++classLoaderVersion; String name = "ReloadableClassLoader(v" + version + ")"; currentApplicationClassLoader = new DelegatedResourcesClassLoader( name, toUrls( outputDirectories ), baseLoader ); result = currentApplicationClassLoader; } } catch ( MalformedURLException e ) { throw new UnexpectedException( "Unexpected reloader exception", e ); //?? } catch ( Play2BuildFailure e ) { result = new CompilationException( e.getMessage(), e.line(), e.position(), e.source() != null ? e.source().getAbsolutePath() : null, e.input() ); } catch ( Play2BuildError e ) { result = new UnexpectedException( e.getMessage(), e.getCause() ); //?? } return result; }
java
{ "resource": "" }
q176697
AbstractArchivingMojo.getArchiver
test
protected Archiver getArchiver( String archiverName ) throws NoSuchArchiverException { Archiver result = archiverManager.getArchiver( archiverName ); result.setDuplicateBehavior( Archiver.DUPLICATES_FAIL ); // Just in case return result; }
java
{ "resource": "" }
q176698
AbstractArchivingMojo.checkArchiverForProblems
test
protected void checkArchiverForProblems( Archiver archiver ) { for ( ResourceIterator iter = archiver.getResources(); iter.hasNext(); ) { iter.next(); } }
java
{ "resource": "" }
q176699
AbstractPlay2SourcePositionMapper.readFileAsString
test
protected String readFileAsString( File file ) throws IOException { FileInputStream is = new FileInputStream( file ); try { byte[] buffer = new byte[8192]; int len = is.read( buffer ); ByteArrayOutputStream out = new ByteArrayOutputStream(); while ( len != -1 ) { out.write( buffer, 0, len ); len = is.read( buffer ); } return charsetName != null ? new String( out.toByteArray(), charsetName ) : new String( out.toByteArray() ); } finally { is.close(); } }
java
{ "resource": "" }