code
stringlengths 10
174k
| nl
stringlengths 3
129k
|
---|---|
public static List<Type> types(List<? extends JCTree> trees){
ListBuffer<Type> ts=new ListBuffer<Type>();
for (List<? extends JCTree> l=trees; l.nonEmpty(); l=l.tail) ts.append(l.head.type);
return ts.toList();
}
| Return the types of a list of trees. |
public void service(Mail mail){
counter++;
log(counter + "");
mail.setState(Mail.GHOST);
}
| Count processed mails, marking each mail as completed after counting. |
public static boolean isPostJDK7(String bytecodeVersion){
return JDK7.equals(bytecodeVersion) || JDK8.equals(bytecodeVersion);
}
| Checks if the specified bytecode version string represents a JDK 1.7+ compatible bytecode version. |
@Override protected void registerOperator(Process process){
super.registerOperator(process);
for ( ExecutionUnit subprocess : subprocesses) {
for ( Operator child : subprocess.getOperators()) {
child.registerOperator(process);
}
}
}
| Register this operator chain and all of its children in the given process. This might change the name of the operator. |
public ListQueuesResult listQueues(String queueNamePrefix) throws AmazonServiceException, AmazonClientException {
return amazonSqsToBeExtended.listQueues(queueNamePrefix);
}
| <p> Returns a list of your queues. The maximum number of queues that can be returned is 1000. If you specify a value for the optional <code>QueueNamePrefix</code> parameter, only queues with a name beginning with the specified value are returned. </p> |
public void exitLock(long id){
lock(id).unlock();
}
| Exits a lock. |
public WriteMultipleRegistersResponse(int reference,int wordCount){
super();
setFunctionCode(Modbus.WRITE_MULTIPLE_REGISTERS);
setDataLength(4);
this.reference=reference;
this.wordCount=wordCount;
}
| Constructs a new <tt>WriteMultipleRegistersResponse</tt> instance. |
public IJavaElement createLambdaTypeElement(LambdaExpression expression,ICompilationUnit unit,HashSet existingElements,HashMap knownScopes){
return createElement(expression.scope,expression.sourceStart(),unit,existingElements,knownScopes).getParent();
}
| Returns a handle denoting the lambda type identified by its scope. |
@Override public boolean onLongClick(View v){
TextInfo parsed=(TextInfo)v.getTag();
String text=parsed.getClipboardPrefix() + parsed.getString();
Util.copyToClipboard(v.getContext(),R.string.atlas_text_cell_factory_clipboard_description,text);
Toast.makeText(v.getContext(),R.string.atlas_text_cell_factory_copied_to_clipboard,Toast.LENGTH_SHORT).show();
return true;
}
| Long click copies message text and sender name to clipboard |
public synchronized static boolean isOpen(String location){
location=normalize(location);
HyperGraph graph=dbs.get(location);
return graph != null && graph.isOpen();
}
| <p> Return <code>true</code> if the database at the given location is already open and <code>false</code> otherwise. </p> |
public NodeFilter createXPathFilter(String xpathFilterExpression){
return createXPath(xpathFilterExpression);
}
| <p> <code>createXPathFilter</code> parses a NodeFilter from the given XPath filter expression. XPath filter expressions occur within XPath expressions such as <code>self::node()[ filterExpression ]</code> </p> |
long generateRegionId(){
long result;
do {
result=this.regionIdCtr.getAndIncrement();
}
while (result <= MAX_RESERVED_DRID && result >= MIN_RESERVED_DRID);
return result;
}
| Called when creating a new disk region (not a recovered one). |
public void incFunctionExecutionHasResultRunning(){
this._stats.incInt(_functionExecutionsHasResultRunningId,1);
aggregateStats.incFunctionExecutionHasResultRunning();
}
| Increments the "FunctionExecutionsCall" stat. |
public int size(){
return map.size();
}
| Returns the number of attributes in this Map. |
@Override public void onBookClicked(View view,String userId,String userName,String userImage,String cardId,String tagName,String contactNumber,String price,String title){
loadChat(userId,userName,userImage,tagName,contactNumber,price,title);
}
| Method callback when the chat action is clicked |
public void generateBooleanEqual(BlockScope currentScope,boolean valueRequired){
boolean isEqualOperator=((this.bits & OperatorMASK) >> OperatorSHIFT) == EQUAL_EQUAL;
Constant cst=this.left.optimizedBooleanConstant();
if (cst != Constant.NotAConstant) {
Constant rightCst=this.right.optimizedBooleanConstant();
if (rightCst != Constant.NotAConstant) {
this.left.generateCode(currentScope,false);
this.right.generateCode(currentScope,false);
}
else if (cst.booleanValue() == isEqualOperator) {
this.left.generateCode(currentScope,false);
this.right.generateCode(currentScope,valueRequired);
}
else {
if (valueRequired) {
BranchLabel falseLabel=new BranchLabel();
this.left.generateCode(currentScope,false);
this.right.generateOptimizedBoolean(currentScope,null,falseLabel,valueRequired);
}
else {
this.left.generateCode(currentScope,false);
this.right.generateCode(currentScope,false);
}
}
return;
}
cst=this.right.optimizedBooleanConstant();
if (cst != Constant.NotAConstant) {
if (cst.booleanValue() == isEqualOperator) {
this.left.generateCode(currentScope,valueRequired);
this.right.generateCode(currentScope,false);
}
else {
if (valueRequired) {
BranchLabel falseLabel=new BranchLabel();
this.left.generateOptimizedBoolean(currentScope,null,falseLabel,valueRequired);
this.right.generateCode(currentScope,false);
}
else {
this.left.generateCode(currentScope,false);
this.right.generateCode(currentScope,false);
}
return;
}
this.left.generateCode(currentScope,valueRequired);
this.right.generateCode(currentScope,valueRequired);
}
}
| Boolean generation for == with boolean operands <p/> Note this code does not optimize conditional constants !!!! |
private void readObject(ObjectInputStream s) throws InvalidObjectException {
throw new InvalidObjectException("Deserialization via serialization delegate");
}
| Defend against malicious streams. |
@Override public void put(String name,long value){
emulatedFields.put(name,value);
}
| Find and set the long value of a given field named <code>name</code> in the receiver. |
public NdefMessage(NdefRecord record,NdefRecord... records){
if (record == null) throw new NullPointerException("record cannot be null");
for ( NdefRecord r : records) {
if (r == null) {
throw new NullPointerException("record cannot be null");
}
}
mRecords=new NdefRecord[1 + records.length];
mRecords[0]=record;
System.arraycopy(records,0,mRecords,1,records.length);
}
| Construct an NDEF Message from one or more NDEF Records. |
@Override public void eSet(int featureID,Object newValue){
switch (featureID) {
case DomPackage.LINE_TAG__DOCLET:
setDoclet((Doclet)newValue);
return;
}
super.eSet(featureID,newValue);
}
| <!-- begin-user-doc --> <!-- end-user-doc --> |
public IntHashMap(Map t){
this(Math.max(2 * t.size(),11),0.75f);
putAll(t);
}
| Constructs a new map with the same mappings as the given map. The map is created with a capacity of twice the number of mappings in the given map or 11 (whichever is greater), and a default load factor, which is 0.75. |
public View build(Context ctx){
mContainer=new LinearLayout(ctx);
if (mInnerShadow) {
if (!mInRTL) {
mContainer.setBackgroundResource(R.drawable.material_drawer_shadow_left);
}
else {
mContainer.setBackgroundResource(R.drawable.material_drawer_shadow_right);
}
}
mRecyclerView=new RecyclerView(ctx);
mContainer.addView(mRecyclerView,ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT);
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
mRecyclerView.setFadingEdgeLength(0);
mRecyclerView.setClipToPadding(false);
mRecyclerView.setLayoutManager(new LinearLayoutManager(ctx));
mDrawerAdapter=new DrawerAdapter();
mRecyclerView.setAdapter(mDrawerAdapter);
if (mDrawer != null && mDrawer.mDrawerBuilder != null && (mDrawer.mDrawerBuilder.mFullscreen || mDrawer.mDrawerBuilder.mTranslucentStatusBar)) {
mRecyclerView.setPadding(mRecyclerView.getPaddingLeft(),UIUtils.getStatusBarHeight(ctx),mRecyclerView.getPaddingRight(),mRecyclerView.getPaddingBottom());
}
if (mDrawer != null && mDrawer.mDrawerBuilder != null && (mDrawer.mDrawerBuilder.mFullscreen || mDrawer.mDrawerBuilder.mTranslucentNavigationBar)) {
mRecyclerView.setPadding(mRecyclerView.getPaddingLeft(),mRecyclerView.getPaddingTop(),mRecyclerView.getPaddingRight(),UIUtils.getNavigationBarHeight(ctx));
}
createItems();
return mContainer;
}
| build the MiniDrawer |
private void showFeedback(String message){
if (myHost != null) {
myHost.showFeedback(message);
}
else {
System.out.println(message);
}
}
| Used to communicate feedback pop-up messages between a plugin tool and the main Whitebox user-interface. |
public void endVisit(MemberValuePair node){
}
| End of visit the given type-specific AST node. <p> The default implementation does nothing. Subclasses may reimplement. </p> |
public <T>CLBuffer<T> createBuffer(CLMem.Usage usage,Pointer<T> data){
return createBuffer(usage,data,true);
}
| #documentCallsFunction("clCreateBuffer") Create an OpenCL buffer with the provided initial values, in copy mode (see <a href="http://www.khronos.org/registry/cl/sdk/1.0/docs/man/xhtml/clCreateBuffer.html">CL_MEM_COPY_HOST_PTR</a>). |
public void notifyClientsOffline(){
for ( MqttConnection connection : connections.values()) {
connection.offline();
}
}
| Notify clients we're offline |
protected PropertyChangeListener createPropertyChangeListener(){
return getHandler();
}
| Creates a listener that is responsible that updates the UI based on how the tree changes. |
private Map<IVariable<?>,Map<URI,StatementPatternNode>> verifyGraphPattern(final AbstractTripleStore database,final GroupNodeBase<IGroupMemberNode> group){
Map<IVariable<?>,Map<URI,StatementPatternNode>> tmp=null;
final int arity=group.arity();
for (int i=0; i < arity; i++) {
final BOp child=group.get(i);
if (child instanceof GroupNodeBase<?>) {
throw new FulltextSearchException("Nested groups are not allowed.");
}
if (child instanceof StatementPatternNode) {
final StatementPatternNode sp=(StatementPatternNode)child;
final TermNode p=sp.p();
if (!p.isConstant()) throw new FulltextSearchException("Expecting search predicate: " + sp);
final URI uri=(URI)((ConstantNode)p).getValue();
if (!uri.stringValue().startsWith(FTS.NAMESPACE)) throw new FulltextSearchException("Expecting search predicate: " + sp);
if (!ASTFulltextSearchOptimizer.searchUris.contains(uri)) throw new FulltextSearchException("Unknown search predicate: " + uri);
final TermNode s=sp.s();
if (!s.isVariable()) throw new FulltextSearchException("Subject of search predicate is constant: " + sp);
final IVariable<?> searchVar=((VarNode)s).getValueExpression();
if (tmp == null) {
tmp=new LinkedHashMap<IVariable<?>,Map<URI,StatementPatternNode>>();
}
Map<URI,StatementPatternNode> statementPatterns=tmp.get(searchVar);
if (statementPatterns == null) {
tmp.put(searchVar,statementPatterns=new LinkedHashMap<URI,StatementPatternNode>());
}
statementPatterns.put(uri,sp);
}
}
return tmp;
}
| Validate the search request. This looks for external search magic predicates and returns them all. It is an error if anything else is found in the group. All such search patterns are reported back by this method, but the service can only be invoked for one a single search variable at a time. The caller will detect both the absence of any search and the presence of more than one search and throw an exception. |
private void configurePlatformApiGwtClients(){
bind(UserServiceClient.class).to(UserServiceClientImpl.class).in(Singleton.class);
bind(UserProfileServiceClient.class).to(UserProfileServiceClientImpl.class).in(Singleton.class);
bind(GitServiceClient.class).to(GitServiceClientImpl.class).in(Singleton.class);
bind(AccountServiceClient.class).to(AccountServiceClientImpl.class).in(Singleton.class);
bind(FactoryServiceClient.class).to(FactoryServiceClientImpl.class).in(Singleton.class);
bind(WorkspaceServiceClient.class).to(WorkspaceServiceClientImpl.class).in(Singleton.class);
bind(VfsServiceClient.class).to(VfsServiceClientImpl.class).in(Singleton.class);
bind(ProjectServiceClient.class).to(ProjectServiceClientImpl.class).in(Singleton.class);
bind(ProjectImportersServiceClient.class).to(ProjectImportersServiceClientImpl.class).in(Singleton.class);
bind(ProjectTypeServiceClient.class).to(ProjectTypeServiceClientImpl.class).in(Singleton.class);
bind(ProjectTemplateServiceClient.class).to(ProjectTemplateServiceClientImpl.class).in(Singleton.class);
bind(BuilderServiceClient.class).to(BuilderServiceClientImpl.class).in(Singleton.class);
bind(RunnerServiceClient.class).to(RunnerServiceClientImpl.class).in(Singleton.class);
bind(ProjectTypeRegistry.class).to(ProjectTypeRegistryImpl.class).in(Singleton.class);
bind(ProjectTemplateRegistry.class).to(ProjectTemplateRegistryImpl.class).in(Singleton.class);
}
| Configure GWT-clients for Codenvy Platform API services |
private static void updateNetwork(WifiManager wifiManager,WifiConfiguration config){
Integer foundNetworkID=findNetworkInExistingConfig(wifiManager,config.SSID);
if (foundNetworkID != null) {
Log.i(TAG,"Removing old configuration for network " + config.SSID);
wifiManager.removeNetwork(foundNetworkID);
wifiManager.saveConfiguration();
}
int networkId=wifiManager.addNetwork(config);
if (networkId >= 0) {
if (wifiManager.enableNetwork(networkId,true)) {
Log.i(TAG,"Associating to network " + config.SSID);
wifiManager.saveConfiguration();
}
else {
Log.w(TAG,"Failed to enable network " + config.SSID);
}
}
else {
Log.w(TAG,"Unable to add network " + config.SSID);
}
}
| Update the network: either create a new network or modify an existing network |
public CModulesTableRenderer(final JTable table){
m_table=Preconditions.checkNotNull(table,"IE02290: table argument can not be null");
}
| Creates a new renderer object. |
protected Set adjustForQueuing(Set recipients){
Set result=null;
return result;
}
| Adjust the specified set of recipients by removing any of them that are currently having their data queued. |
public static Range iterateRangeBounds(CategoryDataset dataset){
return iterateRangeBounds(dataset,true);
}
| Iterates over the data item of the category dataset to find the range bounds. |
protected void checkDOMVersion(Hashtable h){
if (null == h) h=new Hashtable();
final String DOM_LEVEL2_CLASS="org.w3c.dom.Document";
final String DOM_LEVEL2_METHOD="createElementNS";
final String DOM_LEVEL2WD_CLASS="org.w3c.dom.Node";
final String DOM_LEVEL2WD_METHOD="supported";
final String DOM_LEVEL2FD_CLASS="org.w3c.dom.Node";
final String DOM_LEVEL2FD_METHOD="isSupported";
final Class twoStringArgs[]={java.lang.String.class,java.lang.String.class};
try {
Class clazz=ObjectFactory.findProviderClass(DOM_LEVEL2_CLASS,ObjectFactory.findClassLoader(),true);
Method method=clazz.getMethod(DOM_LEVEL2_METHOD,twoStringArgs);
h.put(VERSION + "DOM","2.0");
try {
clazz=ObjectFactory.findProviderClass(DOM_LEVEL2WD_CLASS,ObjectFactory.findClassLoader(),true);
method=clazz.getMethod(DOM_LEVEL2WD_METHOD,twoStringArgs);
h.put(ERROR + VERSION + "DOM.draftlevel","2.0wd");
h.put(ERROR,ERROR_FOUND);
}
catch ( Exception e2) {
try {
clazz=ObjectFactory.findProviderClass(DOM_LEVEL2FD_CLASS,ObjectFactory.findClassLoader(),true);
method=clazz.getMethod(DOM_LEVEL2FD_METHOD,twoStringArgs);
h.put(VERSION + "DOM.draftlevel","2.0fd");
}
catch ( Exception e3) {
h.put(ERROR + VERSION + "DOM.draftlevel","2.0unknown");
h.put(ERROR,ERROR_FOUND);
}
}
}
catch ( Exception e) {
h.put(ERROR + VERSION + "DOM","ERROR attempting to load DOM level 2 class: " + e.toString());
h.put(ERROR,ERROR_FOUND);
}
}
| Report version info from DOM interfaces. Currently distinguishes between pre-DOM level 2, the DOM level 2 working draft, the DOM level 2 final draft, and not found. |
public TLongHash(){
_hashingStrategy=this;
}
| Creates a new <code>TLongHash</code> instance with the default capacity and load factor. |
public ErrorCountTranspilationHandler(TranspilationHandler delegate){
this.delegate=delegate;
}
| Decorates the given transpilation handler. |
private synchronized void addChildNode(DefaultMutableTreeNode parent,DefaultMutableTreeNode child,int index){
DefaultTreeModel model=(DefaultTreeModel)getModel();
model.insertNodeInto(child,parent,index);
}
| This method adds the child to the specified parent node at specific index. |
public static List<LoadMetadataDetails> filterOutNewlyAddedSegments(List<LoadMetadataDetails> segments,List<LoadMetadataDetails> loadsToMerge,LoadMetadataDetails lastSeg){
List<LoadMetadataDetails> list=new ArrayList<>(segments);
List<LoadMetadataDetails> trimmedList=new ArrayList<>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
CarbonDataMergerUtil.sortSegments(list);
trimmedList=list.subList(0,list.indexOf(lastSeg) + 1);
return trimmedList;
}
| Removing the already merged segments from list. |
public void count(Collection<T> collection){
for ( T element : collection) {
count(element);
}
}
| Increment the counts for all elements contained in the collection. When elements are contained multiple times, they are counted multiple times as well. |
@Override public boolean equals(Object o){
if (this == o) return true;
if (o == null || !(o instanceof RyaType)) return false;
RyaType ryaType=(RyaType)o;
if (data != null ? !data.equals(ryaType.data) : ryaType.data != null) return false;
if (dataType != null ? !dataType.equals(ryaType.dataType) : ryaType.dataType != null) return false;
return true;
}
| Determine equality based on string representations of data and datatype. |
public void testTimedInvokeAny1() throws Throwable {
ExecutorService e=new ForkJoinPool(1);
PoolCleaner cleaner=null;
try {
cleaner=cleaner(e);
try {
e.invokeAny(null,MEDIUM_DELAY_MS,MILLISECONDS);
shouldThrow();
}
catch ( NullPointerException success) {
}
}
finally {
if (cleaner != null) {
cleaner.close();
}
}
}
| timed invokeAny(null) throws NullPointerException |
public BinomialMinPQ(Key[] a){
comp=new MyComparator();
for ( Key k : a) insert(k);
}
| Initializes a priority queue with given keys Worst case is O(n*log(n)) |
public void addField(FieldInfo finfo) throws DuplicateMemberException {
testExistingField(finfo.getName(),finfo.getDescriptor());
fields.add(finfo);
}
| Appends a field to the class. |
@Override public String toString(){
StringBuffer result=new StringBuffer();
for (int i=0; i < data.length; i++) {
result.append((i == 0 ? "" : ",") + data[i]);
}
return result.toString();
}
| Returns a string representation of the data row. |
public String globalInfo(){
return "Applies the given filter before calling the given distance function.";
}
| Returns a string describing this object. |
public void testFieldTypeTablesMatch() throws Exception {
FieldDescriptor.Type[] values1=FieldDescriptor.Type.values();
WireFormat.FieldType[] values2=WireFormat.FieldType.values();
assertEquals(values1.length,values2.length);
for (int i=0; i < values1.length; i++) {
assertEquals(values1[i].toString(),values2[i].toString());
}
}
| Test that the FieldDescriptor.Type enum is the same as the WireFormat.FieldType enum. |
public static String toRegex(String glob,char separator){
return new GlobToRegexParser(glob,separator).parseToRegex();
}
| Converts the given glob pattern into a regular expression. |
private void drawFrequencies(Graphics2D graphics){
Stroke currentStroke=graphics.getStroke();
long minFrequency=getMinDisplayFrequency();
long maxFrequency=getMaxDisplayFrequency();
int label=mLabelSizeMonitor.getLabelIncrement(graphics);
int major=mLabelSizeMonitor.getMajorTickIncrement(graphics);
int minor=mLabelSizeMonitor.getMinorTickIncrement(graphics);
if (minor == 0) {
minor=1;
}
long frequency=minFrequency - (minFrequency % minor);
while (frequency < maxFrequency) {
if (frequency % label == 0) {
drawFrequencyLineAndLabel(graphics,frequency);
}
else if (frequency % major == 0) {
drawTickLine(graphics,frequency,true);
}
else {
drawTickLine(graphics,frequency,false);
}
frequency+=minor;
}
}
| Draws the frequency lines and labels every 10kHz |
final public void yyclose() throws java.io.IOException {
yy_atEOF=true;
yy_endRead=yy_startRead;
if (yy_reader != null) yy_reader.close();
}
| Closes the input stream. |
public static void execute(ExecutablePool pool,int txId){
RollbackOpImpl op=new RollbackOpImpl(txId);
pool.execute(op);
}
| Does a rollback on the server for given transaction |
public static void fft(ComplexArray ca,boolean inverse){
final double[] real=ca.real;
final double[] complex=ca.complex;
int n, mmax, m, j, istep, i;
double wtemp, wr, wpr, wpi, wi, theta;
double tempr, tempi;
final double radians;
if (inverse) {
radians=2.0 * Math.PI;
}
else {
radians=-2.0 * Math.PI;
}
n=ca.length << 1;
j=1;
for (i=1; i < n; i+=2) {
if (j > i) {
final int halfI=i >> 1;
final int halfJ=j >> 1;
swap(real,halfJ,halfI);
swap(complex,halfJ,halfI);
}
m=ca.length;
while (m >= 2 && j > m) {
j-=m;
m>>=1;
}
j+=m;
}
mmax=2;
while (n > mmax) {
istep=mmax << 1;
theta=(radians / mmax);
wtemp=Math.sin(0.5 * theta);
wpr=-2.0 * wtemp * wtemp;
wpi=Math.sin(theta);
wr=1.0;
wi=0.0;
for (m=1; m < mmax; m+=2) {
for (i=m; i <= n; i+=istep) {
j=i + mmax;
final int halfI=i >> 1;
final int halfJ=j >> 1;
tempr=wr * real[halfJ] - wi * complex[halfJ];
tempi=wr * complex[halfJ] + wi * real[halfJ];
real[halfJ]=real[halfI] - tempr;
complex[halfJ]=complex[halfI] - tempi;
real[halfI]+=tempr;
complex[halfI]+=tempi;
}
wtemp=wr;
wr+=wr * wpr - wi * wpi;
wi+=wi * wpr + wtemp * wpi;
}
mmax=istep;
}
}
| Computes the fast fourier transform |
public BitVector dominators(BasicBlock block,IR ir){
BitVector dominators=new BitVector(ir.getMaxBasicBlockNumber() + 1);
dominators.set(block.getNumber());
while ((block=getIdom(block,ir)) != null) {
dominators.set(block.getNumber());
}
return dominators;
}
| This method returns the set of blocks that dominates the passed block, i.e., it answers the question "Who dominates me?" |
@Override public void repaint(long tm,int x,int y,int width,int height){
}
| Overridden for performance reasons. See the <a href="#override">Implementation Note</a> for more information. |
public void disconnectPort(MrcPortController p){
istream=null;
ostream=null;
if (controller != p) {
log.warn("disconnectPort: disconnect called from non-connected MrcPortController");
}
controller=null;
}
| Break connection to existing MrcPortController object. Once broken, attempts to send via "message" member will fail. |
public GenericEntry createOrganizationUnit(String customerId,String orgUnitName,String parentOrgUnitPath,String description,boolean blockInheritance) throws AppsForYourDomainException, MalformedURLException, IOException, ServiceException {
GenericEntry entry=new GenericEntry();
entry.addProperty("parentOrgUnitPath",parentOrgUnitPath);
entry.addProperty("description",description);
entry.addProperty("name",orgUnitName);
entry.addProperty("blockInheritance",String.valueOf(blockInheritance));
entry=service.insert(new URL("https://apps-apis.google.com/a/feeds/orgunit/2.0/" + customerId),entry);
return entry;
}
| Create a new organization unit under the given parent. |
private boolean isSomethingToSave(){
if (allowEmpty) {
return true;
}
String currentInput=format(input.getText());
return currentInput != null && !currentInput.isEmpty();
}
| Check if there is currently something to save, based on the allowEmpty property and the current input (possibly after formatting). |
public void processingInstruction(String target,String data) throws SAXException {
charactersFlush();
int dataIndex=m_data.size();
m_previous=addNode(DTM.PROCESSING_INSTRUCTION_NODE,DTM.PROCESSING_INSTRUCTION_NODE,m_parents.peek(),m_previous,-dataIndex,false);
m_data.addElement(m_valuesOrPrefixes.stringToIndex(target));
m_values.addElement(data);
m_data.addElement(m_valueIndex++);
}
| Override the processingInstruction() interface in SAX2DTM2. <p> %OPT% This one is different from SAX2DTM.processingInstruction() in that we do not use extended types for PI nodes. The name of the PI is saved in the DTMStringPool. Receive notification of a processing instruction. |
public static boolean equals(Object[] array1,Object[] array2){
if (array1 == array2) {
return true;
}
if (array1 == null || array2 == null || array1.length != array2.length) {
return false;
}
for (int i=0; i < array1.length; i++) {
Object e1=array1[i], e2=array2[i];
if (!(e1 == null ? e2 == null : e1.equals(e2))) {
return false;
}
}
return true;
}
| Compares the two arrays. |
public SVG build() throws SVGParseException {
if (data == null) {
throw new IllegalStateException("SVG input not specified. Call one of the readFrom...() methods first.");
}
try {
final SVGParser.SVGHandler handler=new SVGParser.SVGHandler();
handler.setColorSwap(searchColor,replaceColor,overideOpacity);
handler.setWhiteMode(whiteMode);
if (strokeColorFilter != null) {
handler.strokePaint.setColorFilter(strokeColorFilter);
}
if (fillColorFilter != null) {
handler.fillPaint.setColorFilter(fillColorFilter);
}
if (!data.markSupported()) data=new BufferedInputStream(data);
try {
data.mark(4);
byte[] magic=new byte[2];
int r=data.read(magic,0,2);
int magicInt=(magic[0] + ((magic[1]) << 8)) & 0xffff;
data.reset();
if (r == 2 && magicInt == GZIPInputStream.GZIP_MAGIC) {
GZIPInputStream gin=new GZIPInputStream(data);
data=gin;
}
}
catch ( IOException ioe) {
throw new SVGParseException(ioe);
}
final SVG svg=SVGParser.parse(new InputSource(data),handler);
return svg;
}
finally {
if (closeInputStream) {
try {
data.close();
}
catch ( IOException e) {
Log.e(SVGParser.TAG,"Error closing SVG input stream.",e);
}
}
}
}
| Loads, reads, parses the SVG (or SVGZ). |
public synchronized OMGraphicList prepare(){
OMGraphicList list=getList();
if (list == null) {
list=new OMGraphicList();
}
else {
list.clear();
}
Debug.message("basic",getName() + "|DayNightLayer.prepare(): doing it");
OMGraphic ras=createImage(getProjection());
if (timer != null) timer.restart();
list.add(ras);
return list;
}
| Prepares the graphics for the layer. This is where the getRectangle() method call is made on the location. <p> Occasionally it is necessary to abort a prepare call. When this happens, the map will set the cancel bit in the LayerThread, (the thread that is running the prepare). If this Layer needs to do any cleanups during the abort, it should do so, but return out of the prepare asap. |
private String toIndentedString(Object o){
if (o == null) {
return "null";
}
return o.toString().replace("\n","\n ");
}
| Convert the given object to string with each line indented by 4 spaces (except the first line). |
public void insert(INode n){
stack.push(n);
}
| Insert pushes the element onto the stack. |
protected boolean drawTopBorder(Component c,Graphics g,int x,int y,int width,int height){
Rectangle titleBarRect=new Rectangle(x,y,width,BORDER_SIZE);
if (!g.getClipBounds().intersects(titleBarRect)) {
return false;
}
int maxX=width - 1;
int maxY=BORDER_SIZE - 1;
g.setColor(frameColor);
g.drawLine(x,y + 2,maxX - 2,y + 2);
g.drawLine(x,y + 3,maxX - 2,y + 3);
g.drawLine(x,y + 4,maxX - 2,y + 4);
g.setColor(frameHighlight);
g.drawLine(x,y,maxX,y);
g.drawLine(x,y + 1,maxX,y + 1);
g.drawLine(x,y + 2,x,y + 4);
g.drawLine(x + 1,y + 2,x + 1,y + 4);
g.setColor(frameShadow);
g.drawLine(x + 4,y + 4,maxX - 4,y + 4);
g.drawLine(maxX,y + 1,maxX,maxY);
g.drawLine(maxX - 1,y + 2,maxX - 1,maxY);
return true;
}
| Draws the FrameBorder's top border. |
public String fullTypeName(){
StringBuilder strb=new StringBuilder();
boolean _moduleNameSet=this.moduleNameSet();
if (_moduleNameSet) {
String _moduleName=this.getModuleName();
strb.append(_moduleName);
}
boolean _typeNameSet=this.typeNameSet();
if (_typeNameSet) {
strb.append(".");
String _typeName=this.getTypeName();
strb.append(_typeName);
}
return strb.toString();
}
| <!-- begin-user-doc --> <!-- end-user-doc --> |
private E xfer(E e,boolean haveData,int how,long nanos){
if (haveData && (e == null)) throw new NullPointerException();
Node s=null;
retry: for (; ; ) {
for (Node h=head, p=h; p != null; ) {
boolean isData=p.isData;
Object item=p.item;
if (item != p && (item != null) == isData) {
if (isData == haveData) break;
if (p.casItem(item,e)) {
for (Node q=p; q != h; ) {
Node n=q.next;
if (head == h && casHead(h,n == null ? q : n)) {
h.forgetNext();
break;
}
if ((h=head) == null || (q=h.next) == null || !q.isMatched()) break;
}
LockSupport.unpark(p.waiter);
return LinkedTransferQueue.<E>cast(item);
}
}
Node n=p.next;
p=(p != n) ? n : (h=head);
}
if (how != NOW) {
if (s == null) s=new Node(e,haveData);
Node pred=tryAppend(s,haveData);
if (pred == null) continue retry;
if (how != ASYNC) return awaitMatch(s,pred,e,(how == TIMED),nanos);
}
return e;
}
}
| Implements all queuing methods. See above for explanation. |
public ButtonColors(Color top,Color leftOuter,Color leftInner,Color edge,Color edgeShade,Color shadow,Color interior){
this.top=top;
this.leftOuter=leftOuter;
this.leftInner=leftInner;
this.edge=edge;
this.edgeShade=edgeShade;
this.shadow=shadow;
this.interior=interior;
}
| Creates a new ButtonColors object. |
public static PropertyValuesHolder ofObject(String propertyName,TypeEvaluator evaluator,Object... values){
PropertyValuesHolder pvh=new PropertyValuesHolder(propertyName);
pvh.setObjectValues(values);
pvh.setEvaluator(evaluator);
return pvh;
}
| Constructs and returns a PropertyValuesHolder with a given property name and set of Object values. This variant also takes a TypeEvaluator because the system cannot automatically interpolate between objects of unknown type. |
public void paintDesktopPaneBackground(SynthContext context,Graphics g,int x,int y,int w,int h){
paintBackground(context,g,x,y,w,h,null);
}
| Paints the background of a desktop pane. |
public void addInfo(String msg){
addInfo(msg,null);
}
| Adds an <code>INFO</code> entry filled with the given message to this status. If the current severity is <code>OK</code> it will be changed to <code>INFO </code>. It will remain unchanged otherwise. |
public int hashCode(){
return toString().hashCode();
}
| Returns a hashcode for this DerValue. |
@Override protected EClass eStaticClass(){
return SexecPackage.Literals.SEQUENCE;
}
| <!-- begin-user-doc --> <!-- end-user-doc --> |
public static List<String> readLines(Reader input) throws IOException {
BufferedReader reader=toBufferedReader(input);
List<String> list=new ArrayList<String>();
String line=reader.readLine();
while (line != null) {
list.add(line);
line=reader.readLine();
}
return list;
}
| Get the contents of a <code>Reader</code> as a list of Strings, one entry per line. <p> This method buffers the input internally, so there is no need to use a <code>BufferedReader</code>. |
private void validate(){
if (checkers != null) {
for ( RamlChecker checker : checkers) {
Pair<Set<Issue>,Set<Issue>> check=checker.check(published,implemented);
warnings.addAll(check.getFirst());
errors.addAll(check.getSecond());
}
}
}
| Main orchestration method that will compare two Raml models together and identify discrepancies between the implementation and contract |
@Override @TargetApi(21) public void onReceivedClientCertRequest(WebView view,ClientCertRequest request){
PluginManager pluginManager=this.parentEngine.pluginManager;
if (pluginManager != null && pluginManager.onReceivedClientCertRequest(null,new CordovaClientCertRequest(request))) {
parentEngine.client.clearLoadTimeoutTimer();
return;
}
super.onReceivedClientCertRequest(view,request);
}
| On received client cert request. The method forwards the request to any running plugins before using the default implementation. |
public OracleExtractException(String message,Throwable cause){
super(message,cause);
}
| Creates a new <code>OracleExtractException</code> object |
public double positivePredictedValue(int classindex){
int tp=truePositives(classindex);
return (double)tp / ((double)(tp + falsePositives(classindex)));
}
| Provides the <i>positive predicted value</i> for the specified class. |
public void removeCardOffer(Offer offer){
((AcceptedOfferBinder)getDataBinder(TYPE_CARDS)).remove(offer);
}
| Set the offer to be removed from the AcceptedOfferBinder |
public static Coord inverseMercator(double latitude,double longitude){
double x=(longitude / SIZE) * 180;
double y=(latitude / SIZE) * 180;
y=180.0 / Math.PI * (2 * MathUtil.atan(MathUtil.exp(y * Math.PI / 180)) - Math.PI / 2);
return new Coord(y,x,false);
}
| Create a unprojected Coord(Latitude, Longitude) from the projected Coord |
private List<Pair<String,String>> extractPortsList(final MachineEntity machine){
List<Pair<String,String>> ports=new ArrayList<>();
if (machine == null || machine.getRuntime() == null) {
return ports;
}
Map<String,? extends Server> servers=machine.getRuntime().getServers();
for ( Map.Entry<String,? extends Server> entry : servers.entrySet()) {
String port=entry.getKey();
if (port.endsWith("/tcp")) {
String portWithoutTcp=port.substring(0,port.length() - 4);
String description=portWithoutTcp + " (" + entry.getValue().getRef()+ ")";
Pair<String,String> pair=new Pair<>(description,portWithoutTcp);
ports.add(pair);
}
}
return ports;
}
| Extracts list of ports available for connecting to the remote debugger. |
public void keyReleased(KeyEvent e){
}
| Key Listener. |
private void initialize(){
this.setIconImages(DisplayUtils.getZapIconImages());
this.setVisible(false);
this.setTitle(Constant.PROGRAM_NAME);
final Dimension dim=restoreWindowSize();
if (dim == null) {
this.setSize(WINDOW_DEFAULT_WIDTH,WINDOW_DEFAULT_HEIGHT);
}
final Point point=restoreWindowLocation();
if (point == null) {
centerFrame();
}
restoreWindowState();
this.addWindowStateListener(new FrameWindowStateListener());
this.addComponentListener(new FrameResizedListener());
}
| This method initializes this |
public boolean IsWindowsAuthEnabled(){
return this._windowsAuthEnabled;
}
| get if Windows authentication is enabled or not |
private void muteDevice(String code){
resultBuilder.build(code);
AudioManager audioManager=(AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
audioManager.setStreamVolume(AudioManager.STREAM_RING,DEFAULT_VOLUME,DEFAULT_FLAG);
}
| Mute the device. |
public TextOverflowHandle(TextHolderFigure owner){
super(owner);
}
| Creates a new instance. |
public void write(ByteCodeWriter out) throws IOException {
out.writeShort(_accessFlags);
out.writeUTF8Const(_name);
out.writeUTF8Const(_descriptor);
out.writeShort(_attributes.size());
for (int i=0; i < _attributes.size(); i++) {
Attribute attr=_attributes.get(i);
attr.write(out);
}
}
| Writes the field to the output. |
public static void exportWriter(Cursor cursor,BufferedWriter out,boolean header,String delim,char quote,ExportFilter filter) throws IOException {
String delimiter=(delim == null) ? DEFAULT_DELIMITER : delim;
Pattern needsQuotePattern=Pattern.compile("(?:" + Pattern.quote(delimiter) + ")|(?:"+ Pattern.quote("" + quote)+ ")|(?:[\n\r])");
List<? extends Column> origCols=cursor.getTable().getColumns();
List<Column> columns=new ArrayList<Column>(origCols);
columns=filter.filterColumns(columns);
Collection<String> columnNames=null;
if (!origCols.equals(columns)) {
columnNames=new HashSet<String>();
for ( Column c : columns) {
columnNames.add(c.getName());
}
}
if (header) {
for (Iterator<Column> iter=columns.iterator(); iter.hasNext(); ) {
writeValue(out,iter.next().getName(),quote,needsQuotePattern);
if (iter.hasNext()) {
out.write(delimiter);
}
}
out.newLine();
}
Object[] unfilteredRowData=new Object[columns.size()];
Row row;
while ((row=cursor.getNextRow(columnNames)) != null) {
for (int i=0; i < columns.size(); i++) {
unfilteredRowData[i]=columns.get(i).getRowValue(row);
}
Object[] rowData=filter.filterRow(unfilteredRowData);
if (rowData == null) {
continue;
}
for (int i=0; i < columns.size(); i++) {
Object obj=rowData[i];
if (obj != null) {
String value=null;
if (obj instanceof byte[]) {
value=ByteUtil.toHexString((byte[])obj);
}
else {
value=String.valueOf(rowData[i]);
}
writeValue(out,value,quote,needsQuotePattern);
}
if (i < columns.size() - 1) {
out.write(delimiter);
}
}
out.newLine();
}
out.flush();
}
| Copy a table in this database into a new delimited text file. |
public void storeOriginals(){
mStartingStartTrim=mStartTrim;
mStartingEndTrim=mEndTrim;
mStartingRotation=mRotation;
}
| If the start / end trim are offset to begin with, store them so that animation starts from that offset. |
public InvertedGenerationalDistance(Problem problem,NondominatedPopulation referenceSet){
this(problem,referenceSet,Settings.getIGDPower());
}
| Constructs an inverted generational distance evaluator for the specified problem and corresponding reference set. |
public RegisteredProject removeProjectType(String projectPath,String type) throws ConflictException, ForbiddenException, NotFoundException, ServerException {
final RegisteredProject project=getProject(projectPath);
if (project == null) {
return null;
}
List<String> newMixins=project.getMixins();
String newType=project.getType();
if (newMixins.contains(type)) {
newMixins.remove(type);
}
else if (newType.equals(type)) {
if (project.isDetected()) {
projects.remove(project.getPath());
return null;
}
newType=BaseProjectType.ID;
}
final NewProjectConfig conf=new NewProjectConfig(project.getPath(),newType,newMixins,project.getName(),project.getDescription(),project.getAttributes(),project.getSource());
return putProject(conf,project.getBaseFolder(),true,project.isDetected());
}
| Extension writer should call this method to apply changes which supposedly make the Project no longer have particular Project Type. In a case of removing primary project type: - if the project was NOT detected BASE Project Type will be set as primary - if the project was detected it will be converted back to the folder For example: - extension code knows that removing some file inside project's file system will (or may) cause removing particular project type |
@Override public boolean isActive(){
return amIActive;
}
| Used by the Whitebox GUI to tell if this plugin is still running. |
public void quit(){
}
| Called by the Console when the user is quitting the SimState. A good place to stick stuff that you'd ordinarily put in a finalizer -- finalizers are tenuous at best. So here you'd put things like the code that closes the relevant display windows etc. |
@Override public boolean isActive(){
return amIActive;
}
| Used by the Whitebox GUI to tell if this plugin is still running. |
public static String removeLeadingZeros(final String str){
String result=str;
if (str != null && str.length() != 0) {
int startIndex=0;
while (startIndex < str.length() - 1) {
final char ch=str.charAt(startIndex);
if (ch != '0') {
break;
}
startIndex++;
}
if (startIndex > 0) {
result=str.substring(startIndex);
}
}
return result;
}
| Remove leading zeros from string. |
public int readNonBlock(byte[] buffer,int offset,int length) throws IOException {
return readTimeout(buffer,offset,length,0);
}
| Reads the next chunk from the stream in non-blocking mode. |
public CommunicationException(String arg0){
super(arg0);
}
| Creates a new instance of CommunicationException. |
@SmallTest public void testPreconditions(){
assertNotNull(mLeftButton);
assertTrue("center button should be right of left button",mLeftButton.getRight() < mCenterButton.getLeft());
assertTrue("right button should be right of center button",mCenterButton.getRight() < mRightButton.getLeft());
}
| The name 'test preconditions' is a convention to signal that if this test doesn't pass, the test case was not set up properly and it might explain any and all failures in other tests. This is not guaranteed to run before other tests, as junit uses reflection to find the tests. |
private JSONWriter end(char mode,char c) throws JSONException {
if (this.mode != mode) {
throw new JSONException(mode == 'a' ? "Misplaced endArray." : "Misplaced endObject.");
}
this.pop(mode);
try {
this.writer.write(c);
}
catch ( IOException e) {
throw new JSONException(e);
}
this.comma=true;
return this;
}
| End something. |
public static void initPrivateKey(Properties props) throws Exception {
String privateKeyFilePath=props.getProperty(PRIVATE_KEY_FILE_PROP);
privateKeyAlias="";
privateKeyEncrypt=null;
if (privateKeyFilePath != null && privateKeyFilePath.length() > 0) {
KeyStore ks=KeyStore.getInstance("PKCS12");
privateKeyAlias=props.getProperty(PRIVATE_KEY_ALIAS_PROP);
if (privateKeyAlias == null) {
privateKeyAlias="";
}
String keyStorePass=props.getProperty(PRIVATE_KEY_PASSWD_PROP);
char[] passPhrase=(keyStorePass != null ? keyStorePass.toCharArray() : null);
FileInputStream privateKeyFile=new FileInputStream(privateKeyFilePath);
try {
ks.load(privateKeyFile,passPhrase);
}
finally {
privateKeyFile.close();
}
Key key=ks.getKey(privateKeyAlias,passPhrase);
Certificate keyCert=ks.getCertificate(privateKeyAlias);
if (key instanceof PrivateKey && keyCert instanceof X509Certificate) {
privateKeyEncrypt=(PrivateKey)key;
privateKeySignAlgo=((X509Certificate)keyCert).getSigAlgName();
privateKeySubject=((X509Certificate)keyCert).getSubjectDN().getName();
}
}
}
| Load the private key of the server. This method is not thread safe. |
public final Vector3d vectorTo(IMovingAgent agent){
Vector3d v=new Vector3d();
v.sub(agent.getLocation(),location);
return v;
}
| Calculate the vector from this agent to the provided one. |
@DSComment("Wifi subsystem") @DSSpec(DSCat.WIFI) @DSGenerator(tool_name="Doppelganger",tool_version="2.0",generated_on="2013-12-30 12:36:05.312 -0500",hash_original_method="13D7026BA6E2310038D9CCEC7D1F5CA4",hash_generated_method="68D6939781BFBE3ABBF2F3F61C7E9CDE") public boolean disconnect(){
try {
mService.disconnect();
return true;
}
catch ( RemoteException e) {
return false;
}
}
| Disassociate from the currently active access point. This may result in the asynchronous delivery of state change events. |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.