code
stringlengths 10
174k
| nl
stringlengths 3
129k
|
---|---|
public boolean isDrawerOpen(){
return false;
}
| Get the current state of the drawer. True if the drawer is currently open. |
float map(float value,float start1,float stop1,float start2,float stop2){
return start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));
}
| Takes a value, assumes it falls between start1 and stop1, and maps it to a value between start2 and stop2. For example, above, our slide goes 0-100, starting at 50. We map 0 on the slider to .1f and 100 to 1.9f, in order to better suit our shader calculations |
public td addElement(String hashcode,String element){
addElementToRegistry(hashcode,element);
return (this);
}
| Adds an Element to the element. |
public CompilationUnitChange attachChange(CompilationUnitChange cuChange,boolean generateGroups) throws CoreException {
boolean needsAstRewrite=fRewrite != null;
boolean needsImportRemoval=fImportRemover != null && fImportRemover.hasRemovedNodes();
boolean needsImportRewrite=fImportRewrite != null && fImportRewrite.hasRecordedChanges() || needsImportRemoval;
if (!needsAstRewrite && !needsImportRemoval && !needsImportRewrite) return null;
MultiTextEdit multiEdit=(MultiTextEdit)cuChange.getEdit();
if (multiEdit == null) {
multiEdit=new MultiTextEdit();
cuChange.setEdit(multiEdit);
}
if (needsAstRewrite) {
TextEdit rewriteEdit;
if (fRememberContent != null) {
rewriteEdit=fRewrite.rewriteAST(fRememberContent,WorkerMessageHandler.get().getOptions());
}
else {
rewriteEdit=fRewrite.rewriteAST(document,WorkerMessageHandler.get().getOptions());
}
if (!isEmptyEdit(rewriteEdit)) {
multiEdit.addChild(rewriteEdit);
if (generateGroups) {
for (Iterator<TextEditGroup> iter=fTextEditGroups.iterator(); iter.hasNext(); ) {
TextEditGroup group=iter.next();
cuChange.addTextEditGroup(group);
}
}
}
}
if (needsImportRemoval) {
fImportRemover.applyRemoves(getImportRewrite());
}
if (needsImportRewrite) {
TextEdit importsEdit=fImportRewrite.rewriteImports();
if (!isEmptyEdit(importsEdit)) {
multiEdit.addChild(importsEdit);
String importUpdateName=RefactoringCoreMessages.INSTANCE.ASTData_update_imports();
cuChange.addTextEditGroup(new TextEditGroup(importUpdateName,importsEdit));
}
}
else {
}
if (isEmptyEdit(multiEdit)) return null;
return cuChange;
}
| Attaches the changes of this compilation unit rewrite to the given CU Change. The given change <b>must</b> either have no root edit, or a MultiTextEdit as a root edit. The edits in the given change <b>must not</b> overlap with the changes of this compilation unit. |
@Override public double[] distributionForInstance(Instance instance) throws Exception {
if (m_Filter.numPendingOutput() > 0) {
throw new Exception("Filter output queue not empty!");
}
if (!m_Filter.input(instance)) {
throw new Exception("Filter didn't make the test instance immediately available!");
}
m_Filter.batchFinished();
Instance newInstance=m_Filter.output();
return m_Clusterer.distributionForInstance(newInstance);
}
| Classifies a given instance after filtering. |
public ScaleIOSnapshotVolumeResponse snapshotMultiVolume(Map<String,String> id2snapshot,String systemId) throws Exception {
String uri=ScaleIOConstants.getSnapshotVolumesURI(systemId);
ScaleIOSnapshotVolumes spVol=new ScaleIOSnapshotVolumes();
for ( Map.Entry<String,String> entry : id2snapshot.entrySet()) {
spVol.addSnapshot(entry.getKey(),entry.getValue());
}
ClientResponse response=post(URI.create(uri),getJsonForEntity(spVol));
return getResponseObject(ScaleIOSnapshotVolumeResponse.class,response);
}
| Create multiple snapshots in a consistency group |
public static String decodeUnicodeStr(String s){
StringBuilder sb=new StringBuilder(s.length());
char[] chars=s.toCharArray();
for (int i=0; i < chars.length; i++) {
char c=chars[i];
if (c == '\\' && chars[i + 1] == 'u') {
char cc=0;
for (int j=0; j < 4; j++) {
char ch=Character.toLowerCase(chars[i + 2 + j]);
if ('0' <= ch && ch <= '9' || 'a' <= ch && ch <= 'f') {
cc|=(Character.digit(ch,16) << (3 - j) * 4);
}
else {
cc=0;
break;
}
}
if (cc > 0) {
i+=5;
sb.append(cc);
continue;
}
}
sb.append(c);
}
return sb.toString();
}
| decode Unicode string |
private int readMethod(final ClassVisitor classVisitor,final Context context,int u){
char[] c=context.buffer;
context.access=readUnsignedShort(u);
context.name=readUTF8(u + 2,c);
context.desc=readUTF8(u + 4,c);
u+=6;
int code=0;
int exception=0;
String[] exceptions=null;
String signature=null;
int methodParameters=0;
int anns=0;
int ianns=0;
int tanns=0;
int itanns=0;
int dann=0;
int mpanns=0;
int impanns=0;
int firstAttribute=u;
Attribute attributes=null;
for (int i=readUnsignedShort(u); i > 0; --i) {
String attrName=readUTF8(u + 2,c);
if ("Code".equals(attrName)) {
if ((context.flags & SKIP_CODE) == 0) {
code=u + 8;
}
}
else if ("Exceptions".equals(attrName)) {
exceptions=new String[readUnsignedShort(u + 8)];
exception=u + 10;
for (int j=0; j < exceptions.length; ++j) {
exceptions[j]=readClass(exception,c);
exception+=2;
}
}
else if (SIGNATURES && "Signature".equals(attrName)) {
signature=readUTF8(u + 8,c);
}
else if ("Deprecated".equals(attrName)) {
context.access|=Opcodes.ACC_DEPRECATED;
}
else if (ANNOTATIONS && "RuntimeVisibleAnnotations".equals(attrName)) {
anns=u + 8;
}
else if (ANNOTATIONS && "RuntimeVisibleTypeAnnotations".equals(attrName)) {
tanns=u + 8;
}
else if (ANNOTATIONS && "AnnotationDefault".equals(attrName)) {
dann=u + 8;
}
else if ("Synthetic".equals(attrName)) {
context.access|=Opcodes.ACC_SYNTHETIC | ClassWriter.ACC_SYNTHETIC_ATTRIBUTE;
}
else if (ANNOTATIONS && "RuntimeInvisibleAnnotations".equals(attrName)) {
ianns=u + 8;
}
else if (ANNOTATIONS && "RuntimeInvisibleTypeAnnotations".equals(attrName)) {
itanns=u + 8;
}
else if (ANNOTATIONS && "RuntimeVisibleParameterAnnotations".equals(attrName)) {
mpanns=u + 8;
}
else if (ANNOTATIONS && "RuntimeInvisibleParameterAnnotations".equals(attrName)) {
impanns=u + 8;
}
else if ("MethodParameters".equals(attrName)) {
methodParameters=u + 8;
}
else {
Attribute attr=readAttribute(context.attrs,attrName,u + 8,readInt(u + 4),c,-1,null);
if (attr != null) {
attr.next=attributes;
attributes=attr;
}
}
u+=6 + readInt(u + 4);
}
u+=2;
MethodVisitor mv=classVisitor.visitMethod(context.access,context.name,context.desc,signature,exceptions);
if (mv == null) {
return u;
}
if (WRITER && mv instanceof MethodWriter) {
MethodWriter mw=(MethodWriter)mv;
if (mw.cw.cr == this && signature == mw.signature) {
boolean sameExceptions=false;
if (exceptions == null) {
sameExceptions=mw.exceptionCount == 0;
}
else if (exceptions.length == mw.exceptionCount) {
sameExceptions=true;
for (int j=exceptions.length - 1; j >= 0; --j) {
exception-=2;
if (mw.exceptions[j] != readUnsignedShort(exception)) {
sameExceptions=false;
break;
}
}
}
if (sameExceptions) {
mw.classReaderOffset=firstAttribute;
mw.classReaderLength=u - firstAttribute;
return u;
}
}
}
if (methodParameters != 0) {
for (int i=b[methodParameters] & 0xFF, v=methodParameters + 1; i > 0; --i, v=v + 4) {
mv.visitParameter(readUTF8(v,c),readUnsignedShort(v + 2));
}
}
if (ANNOTATIONS && dann != 0) {
AnnotationVisitor dv=mv.visitAnnotationDefault();
readAnnotationValue(dann,c,null,dv);
if (dv != null) {
dv.visitEnd();
}
}
if (ANNOTATIONS && anns != 0) {
for (int i=readUnsignedShort(anns), v=anns + 2; i > 0; --i) {
v=readAnnotationValues(v + 2,c,true,mv.visitAnnotation(readUTF8(v,c),true));
}
}
if (ANNOTATIONS && ianns != 0) {
for (int i=readUnsignedShort(ianns), v=ianns + 2; i > 0; --i) {
v=readAnnotationValues(v + 2,c,true,mv.visitAnnotation(readUTF8(v,c),false));
}
}
if (ANNOTATIONS && tanns != 0) {
for (int i=readUnsignedShort(tanns), v=tanns + 2; i > 0; --i) {
v=readAnnotationTarget(context,v);
v=readAnnotationValues(v + 2,c,true,mv.visitTypeAnnotation(context.typeRef,context.typePath,readUTF8(v,c),true));
}
}
if (ANNOTATIONS && itanns != 0) {
for (int i=readUnsignedShort(itanns), v=itanns + 2; i > 0; --i) {
v=readAnnotationTarget(context,v);
v=readAnnotationValues(v + 2,c,true,mv.visitTypeAnnotation(context.typeRef,context.typePath,readUTF8(v,c),false));
}
}
if (ANNOTATIONS && mpanns != 0) {
readParameterAnnotations(mv,context,mpanns,true);
}
if (ANNOTATIONS && impanns != 0) {
readParameterAnnotations(mv,context,impanns,false);
}
while (attributes != null) {
Attribute attr=attributes.next;
attributes.next=null;
mv.visitAttribute(attributes);
attributes=attr;
}
if (code != 0) {
mv.visitCode();
readCode(mv,context,code);
}
mv.visitEnd();
return u;
}
| Reads a method and makes the given visitor visit it. |
private JSONObject executeSqlStatementNDK(String query,JSONArray paramsAsJson,CallbackContext cbc) throws Exception {
JSONObject rowsResult=new JSONObject();
boolean hasRows;
SQLiteStatement myStatement=mydb.prepareStatement(query);
try {
for (int i=0; i < paramsAsJson.length(); ++i) {
if (paramsAsJson.isNull(i)) {
myStatement.bindNull(i + 1);
}
else {
Object p=paramsAsJson.get(i);
if (p instanceof Float || p instanceof Double) myStatement.bindDouble(i + 1,paramsAsJson.getDouble(i));
else if (p instanceof Number) myStatement.bindLong(i + 1,paramsAsJson.getLong(i));
else myStatement.bindTextNativeString(i + 1,paramsAsJson.getString(i));
}
}
hasRows=myStatement.step();
}
catch ( Exception ex) {
ex.printStackTrace();
String errorMessage=ex.getMessage();
Log.v("executeSqlBatch","SQLitePlugin.executeSql[Batch](): Error=" + errorMessage);
myStatement.dispose();
throw ex;
}
if (hasRows) {
JSONArray rowsArrayResult=new JSONArray();
String key;
int colCount=myStatement.getColumnCount();
do {
JSONObject row=new JSONObject();
try {
for (int i=0; i < colCount; ++i) {
key=myStatement.getColumnName(i);
switch (myStatement.getColumnType(i)) {
case SQLColumnType.NULL:
row.put(key,JSONObject.NULL);
break;
case SQLColumnType.REAL:
row.put(key,myStatement.getColumnDouble(i));
break;
case SQLColumnType.INTEGER:
row.put(key,myStatement.getColumnLong(i));
break;
case SQLColumnType.BLOB:
case SQLColumnType.TEXT:
default :
row.put(key,myStatement.getColumnTextNativeString(i));
}
}
rowsArrayResult.put(row);
}
catch (JSONException e) {
e.printStackTrace();
}
}
while (myStatement.step());
try {
rowsResult.put("rows",rowsArrayResult);
}
catch (JSONException e) {
e.printStackTrace();
}
}
myStatement.dispose();
return rowsResult;
}
| Get rows results from query cursor. |
public void paint(Graphics g,JComponent c){
if (progressBar.isIndeterminate()) {
paintIndeterminate(g,c);
}
else {
paintDeterminate(g,c);
}
}
| Delegates painting to one of two methods: paintDeterminate or paintIndeterminate. |
@After public void tearDown(){
List<HashMap> financialActivities=this.financialActivityAccountHelper.getAllFinancialActivityAccounts(this.responseSpec);
for ( HashMap financialActivity : financialActivities) {
Integer financialActivityAccountId=(Integer)financialActivity.get("id");
Integer deletedFinancialActivityAccountId=this.financialActivityAccountHelper.deleteFinancialActivityAccount(financialActivityAccountId,this.responseSpec,CommonConstants.RESPONSE_RESOURCE_ID);
Assert.assertNotNull(deletedFinancialActivityAccountId);
Assert.assertEquals(financialActivityAccountId,deletedFinancialActivityAccountId);
}
}
| Delete the Liability transfer account |
public <T>Tuple5<T,A,B,C,D> prepend(T t){
return Tuple5.of(t,_1,_2,_3,_4);
}
| Creates a tuple 5 by prepending the supplied value |
public String doImport(){
boolean alreadyDone;
try {
alreadyDone=isImportAlreadyDone();
}
catch ( ImporterMetaDataException e) {
errorMessage=e.getMessage();
return ERROR;
}
if (importerManager.isInProgress() || alreadyDone) {
return WAIT;
}
ImportAction.logger.info("doImport");
this.importerManager.importAll();
return Action.SUCCESS;
}
| Run import if not in progress or already done, otherwise return Wait view |
public NetworkTopologyEventImpl(JmDNS jmDNS,InetAddress inetAddress){
super(jmDNS);
this._inetAddress=inetAddress;
}
| Constructs a Network Topology Event. |
public void endVisit(MethodInvocation node){
}
| End of visit the given type-specific AST node. <p> The default implementation does nothing. Subclasses may reimplement. </p> |
public boolean cancelLeaseOfIPv4(IPv4Address ip){
DHCPBinding binding=this.getDHCPbindingFromIPv4(ip);
if (binding != null) {
binding.clearLeaseTimes();
binding.setLeaseStatus(false);
this.setPoolAvailability(this.getPoolAvailability() + 1);
this.setPoolFull(false);
return true;
}
return false;
}
| Cancel an IP lease. |
void customize(){
}
| Customize dialog To be overwritten by concrete classes |
@Override public void run(){
try {
handleAlarm();
}
catch ( Throwable e) {
log.log(Level.WARNING,e.toString(),e);
}
finally {
_isRunning=false;
_runningAlarmCount.decrementAndGet();
}
}
| Runs the alarm. This is only called from the worker thread. |
public Builder(){
}
| Instantiates a new builder. |
public void test_checkServerTrusted_01() throws Exception {
X509TrustManagerImpl xtm=new X509TrustManagerImpl();
X509Certificate[] xcert=null;
try {
xtm.checkServerTrusted(xcert,"SSL");
fail("IllegalArgumentException wasn't thrown");
}
catch ( IllegalArgumentException expected) {
}
xcert=new X509Certificate[0];
try {
xtm.checkServerTrusted(xcert,"SSL");
fail("IllegalArgumentException wasn't thrown");
}
catch ( IllegalArgumentException expected) {
}
xcert=setX509Certificate();
try {
xtm.checkServerTrusted(xcert,null);
fail("IllegalArgumentException wasn't thrown");
}
catch ( IllegalArgumentException expected) {
}
try {
xtm.checkServerTrusted(xcert,"");
fail("IllegalArgumentException wasn't thrown");
}
catch ( IllegalArgumentException expected) {
}
}
| javax.net.ssl.X509TrustManager#checkServerTrusted(X509Certificate[] chain, String authType) |
@Override public CompilerPhase newExecution(IR ir){
return this;
}
| Return this instance of this phase. This phase contains no per-compilation instance fields. |
public final String toString(){
return description;
}
| Returns a <code>String</code> representation of this <code>BOM</code> value. |
public boolean supportsPreStripping(){
return false;
}
| Return true if the xsl:strip-space or xsl:preserve-space was processed during construction of the DTM document. <p>%REVEIW% Presumes a 1:1 mapping from DTM to Document, since we aren't saying which Document to query...?</p> |
public static <T>Key<T> of(Class<T> type,Annotation ann){
Objects.requireNonNull(type);
Objects.requireNonNull(ann);
return new Key<>(type,new Annotation[]{ann});
}
| Builds Key from a Class and annotation |
private void lazyChopIfNeeded(Object object){
if (lazyChop) {
if (object instanceof LazyValueMap) {
LazyValueMap m=(LazyValueMap)object;
m.chopMap();
}
else if (object instanceof ValueList) {
ValueList list=(ValueList)object;
list.chopList();
}
}
}
| If in lazy chop mode, and the object is a Lazy Value Map or a ValueList then we force a chop operation for each of its items. |
protected void loadRefs(){
try {
myLocalBranches.clear();
myRemoteBranches.clear();
myTags.clear();
final VirtualFile root=gitRoot();
GitRepository repository=GitUtil.getRepositoryManager(myProject).getRepositoryForRoot(root);
if (repository != null) {
myLocalBranches.addAll(repository.getBranches().getLocalBranches());
myRemoteBranches.addAll(repository.getBranches().getRemoteBranches());
myCurrentBranch=repository.getCurrentBranch();
}
else {
LOG.error("Repository is null for root " + root);
}
GitTag.list(myProject,root,myTags);
}
catch ( VcsException e) {
GitUIUtil.showOperationError(myProject,e,"git branch -a");
}
}
| Load tags and branches |
public static void hideKeyboard(Activity activity,IBinder windowToken){
InputMethodManager mgr=(InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.hideSoftInputFromWindow(windowToken,0);
}
| This method is used to hide a keyboard after a user has finished typing the url. |
public static void main(String[] args){
System.out.println(parseSchedule("EmailTest,//GAI/datascience/tasks/daily/EmailTest,sendmail.r,Now,, [email protected], true,,false",true));
System.out.println(parseSchedule("EmailTest,//GAI/datascience/tasks/daily/EmailTest,sendmail.r,Now,, [email protected], true,,false",false));
System.out.println(parseSchedule("EmailTest,//GAI/datascience/tasks/daily/EmailTest,sendmail.r,Hourly,19:35, [email protected], true,,false",true));
System.out.println(parseSchedule("EmailTest,//GAI/datascience/tasks/daily/EmailTest,sendmail.r,Daily,11:00, [email protected], true,,false",true));
System.out.println(parseSchedule("EmailTest,//GAI/datascience/tasks/daily/EmailTest,sendmail.r,Weekly,Sun 18:00, [email protected], false,,false",true));
System.out.println(parseSchedule("EmailTest,//GAI/datascience/tasks/daily/EmailTest,sendmail.r,Monthly,24 11:30, [email protected], true,,false",true));
System.out.println(parseSchedule("EmailTest,//GAI/datascience/tasks/daily/EmailTest,sendmail.r,Never,, [email protected], true,,false",true));
System.out.println(parseSchedule("PvZ2_Model, //GAI/popcap/,tasks/berfu/PvZ2_Model/pvz2_model_data.R,Monthly,27 11:45,[email protected],TRUE,,",true));
}
| Unit test. |
@Override public void close(){
this.allowedOps.clear();
}
| Clears the cached information for this principal. |
public static String createFaultXml(String faultCode,String faultString,String faultActor,String detail) throws IOException {
return createFaultXml(new QName(faultCode),faultString,faultActor,detail);
}
| Creates a SOAP fault message. |
void shrink(){
int n=m_opMap.elementAt(MAPINDEX_LENGTH);
m_opMap.setToSize(n + 4);
m_opMap.setElementAt(0,n);
m_opMap.setElementAt(0,n + 1);
m_opMap.setElementAt(0,n + 2);
n=m_tokenQueue.size();
m_tokenQueue.setToSize(n + 4);
m_tokenQueue.setElementAt(null,n);
m_tokenQueue.setElementAt(null,n + 1);
m_tokenQueue.setElementAt(null,n + 2);
}
| Replace the large arrays with a small array. |
@Override public void eUnset(int featureID){
switch (featureID) {
case N4JSPackage.FUNCTION_DECLARATION__DECLARED_MODIFIERS:
getDeclaredModifiers().clear();
return;
case N4JSPackage.FUNCTION_DECLARATION__BODY:
setBody((Block)null);
return;
case N4JSPackage.FUNCTION_DECLARATION__LOK:
set_lok((LocalArgumentsVariable)null);
return;
case N4JSPackage.FUNCTION_DECLARATION__DEFINED_TYPE:
setDefinedType((Type)null);
return;
case N4JSPackage.FUNCTION_DECLARATION__FPARS:
getFpars().clear();
return;
case N4JSPackage.FUNCTION_DECLARATION__RETURN_TYPE_REF:
setReturnTypeRef((TypeRef)null);
return;
case N4JSPackage.FUNCTION_DECLARATION__GENERATOR:
setGenerator(GENERATOR_EDEFAULT);
return;
case N4JSPackage.FUNCTION_DECLARATION__DECLARED_ASYNC:
setDeclaredAsync(DECLARED_ASYNC_EDEFAULT);
return;
case N4JSPackage.FUNCTION_DECLARATION__TYPE_VARS:
getTypeVars().clear();
return;
case N4JSPackage.FUNCTION_DECLARATION__NAME:
setName(NAME_EDEFAULT);
return;
}
super.eUnset(featureID);
}
| <!-- begin-user-doc --> <!-- end-user-doc --> |
public static ThreadContext push(String key,Object value) throws IllegalArgumentException {
if (key == null) throw new IllegalArgumentException("null key");
ThreadContext oldContext=getContext();
if (oldContext == null) oldContext=new ThreadContext(null,null,null);
ThreadContext newContext=new ThreadContext(oldContext,key,value);
setContext(newContext);
return oldContext;
}
| <p>Push an object on the context stack with the given key. This operation can subsequently be undone by calling <code>restore</code> with the ThreadContext value returned here.</p> |
public boolean hasRestriction(Resource r){
return classes.containsKey(r) && !classes.get(r).getOnProperty().isEmpty();
}
| Return whether this resource corresponds to a property restriction. |
public static void openShareFileIntent(Context context,File file,String shareDialogMessage){
try {
context.startActivity(Intent.createChooser(getShareFileIntent(context,file),shareDialogMessage));
}
catch ( Exception e) {
logThis(TAG,"openShareFileIntent Exception",e);
}
}
| Opens share file intent |
@Override public boolean isReadOnly() throws SQLException {
try {
if (isDebugEnabled()) {
debugCode("isReadOnly");
}
checkClosed();
return session.isReadOnly();
}
catch ( Exception e) {
throw logAndConvert(e);
}
}
| Returns true if the database is read-only. |
void optimize(Environment env,Label lbl){
lbl.pc=REACHED;
for (Instruction inst=lbl.next; inst != null; inst=inst.next) {
switch (inst.pc) {
case NOTREACHED:
inst.optimize(env);
inst.pc=REACHED;
break;
case REACHED:
return;
case NEEDED:
break;
}
switch (inst.opc) {
case opc_label:
case opc_dead:
if (inst.pc == REACHED) {
inst.pc=NOTREACHED;
}
break;
case opc_ifeq:
case opc_ifne:
case opc_ifgt:
case opc_ifge:
case opc_iflt:
case opc_ifle:
case opc_if_icmpeq:
case opc_if_icmpne:
case opc_if_icmpgt:
case opc_if_icmpge:
case opc_if_icmplt:
case opc_if_icmple:
case opc_if_acmpeq:
case opc_if_acmpne:
case opc_ifnull:
case opc_ifnonnull:
optimize(env,(Label)inst.value);
break;
case opc_goto:
optimize(env,(Label)inst.value);
return;
case opc_jsr:
optimize(env,(Label)inst.value);
break;
case opc_ret:
case opc_return:
case opc_ireturn:
case opc_lreturn:
case opc_freturn:
case opc_dreturn:
case opc_areturn:
case opc_athrow:
return;
case opc_tableswitch:
case opc_lookupswitch:
{
SwitchData sw=(SwitchData)inst.value;
optimize(env,sw.defaultLabel);
for (Enumeration<Label> e=sw.tab.elements(); e.hasMoreElements(); ) {
optimize(env,e.nextElement());
}
return;
}
case opc_try:
{
TryData td=(TryData)inst.value;
td.getEndLabel().pc=NEEDED;
for (Enumeration<CatchData> e=td.catches.elements(); e.hasMoreElements(); ) {
CatchData cd=e.nextElement();
optimize(env,cd.getLabel());
}
break;
}
}
}
}
| Optimize instructions and mark those that can be reached |
public final void yyreset(java.io.Reader reader){
zzBuffer=s.array;
zzStartRead=s.offset;
zzEndRead=zzStartRead + s.count - 1;
zzCurrentPos=zzMarkedPos=s.offset;
zzLexicalState=YYINITIAL;
zzReader=reader;
zzAtEOF=false;
}
| Resets the scanner to read from a new input stream. Does not close the old reader. All internal variables are reset, the old input stream <b>cannot</b> be reused (internal buffer is discarded and lost). Lexical state is set to <tt>YY_INITIAL</tt>. |
private static void queryPositionEntry(FinanceService service,String entryUrl) throws IOException, MalformedURLException, ServiceException {
System.out.println("Requesting Entry at location " + entryUrl);
PositionEntry positionEntry=service.getEntry(new URL(entryUrl),PositionEntry.class);
printPositionEntry(positionEntry);
}
| Queries a positon entry and prints entry details. |
public void sort(final int columnIndex,final boolean sortAscending){
sortingController.sort(columnIndex,sortAscending);
}
| Sorts the table by the values of the column of the given index. |
public void addVetoableChangeListener(String propertyName,VetoableChangeListener in_vcl){
beanContextChildSupport.addVetoableChangeListener(propertyName,in_vcl);
}
| Method for BeanContextChild interface. Uses the BeanContextChildSupport to add a listener to this object's property. This listener wants to have the right to veto a property change. |
public String prettyPrint(String sparql){
return OpAsQuery.asQuery(Algebra.compile(QueryFactory.create(sparql))).serialize();
}
| Reformats the SPARQL query for logging purpose |
public ArrayStoreException(){
super();
}
| Constructs an <code>ArrayStoreException</code> with no detail message. |
private RDOParameter createRoleBasedParameter(RDOParameter parameterRdo,RDORole role,int parentEntryNr){
RDOParameter roleBasedParameter=new RDOParameter();
roleBasedParameter.setParentEntryNr(parentEntryNr);
roleBasedParameter.setEntryNr(sequence.nextValue());
roleBasedParameter.setId(parameterRdo.getId());
roleBasedParameter.setValue(parameterRdo.getValue());
roleBasedParameter.setValueFactor(parameterRdo.getValueFactor());
roleBasedParameter.setBasePrice(role.getBasePrice());
roleBasedParameter.setPrice(role.getPrice());
roleBasedParameter.setFactor(role.getFactor());
return roleBasedParameter;
}
| Create a new role based parameter. The information from the role and the parameter are merged. |
@After public void tearDown() throws Exception {
}
| Method tearDown. |
public void lostOwnership(Clipboard clipboard,Transferable contents){
}
| Required by the AbstractAction interface; does nothing. |
@Nonnull public BugInstance addSourceLine(SourceLineAnnotation sourceLine){
add(sourceLine);
return this;
}
| Add a source line annotation. |
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. |
static ClassLoader findClassLoader() throws ConfigurationError {
return Thread.currentThread().getContextClassLoader();
}
| Figure out which ClassLoader to use. For JDK 1.2 and later use the context ClassLoader. |
public int convertColumnIndexToModel(int viewColumnIndex){
return viewColumnIndex;
}
| Convert the index for a column from the display index to the corresponding index in the underlying model. <p> This is unused for this implementation because the column ordering cannot be dynamically changed. |
private int compare(WorkSource other,int i1,int i2){
final int diff=mUids[i1] - other.mUids[i2];
if (diff != 0) {
return diff;
}
return mNames[i1].compareTo(other.mNames[i2]);
}
| Returns 0 if equal, negative if 'this' is before 'other', positive if 'this' is after 'other'. |
@Override public int[] reduce(List<ComputeJobResult> results){
if (results.size() == 1) return results.get(0).getData();
assert results.size() == 2;
int[] arr1=results.get(0).getData();
int[] arr2=results.get(1).getData();
return mergeArrays(arr1,arr2);
}
| This method is called when both child jobs are completed, and is a Reduce step of Merge Sort algorithm. On this step we do a merge of 2 sorted arrays, produced by child tasks, into a 1 sorted array. |
public void actionPerformed(ActionEvent e){
GraphicsEnvironment.getLocalGraphicsEnvironment();
if (!GraphicsEnvironment.isHeadless()) {
if (UI == null) {
UI=new UserInterface();
}
else {
UI.setVisible(true);
}
}
else {
new FacelessServer();
}
}
| Start the server end of WiThrottle. |
Object processValue(StylesheetHandler handler,String uri,String name,String rawName,String value,ElemTemplateElement owner) throws org.xml.sax.SAXException {
int type=getType();
Object processedValue=null;
switch (type) {
case T_AVT:
processedValue=processAVT(handler,uri,name,rawName,value,owner);
break;
case T_CDATA:
processedValue=processCDATA(handler,uri,name,rawName,value,owner);
break;
case T_CHAR:
processedValue=processCHAR(handler,uri,name,rawName,value,owner);
break;
case T_ENUM:
processedValue=processENUM(handler,uri,name,rawName,value,owner);
break;
case T_EXPR:
processedValue=processEXPR(handler,uri,name,rawName,value,owner);
break;
case T_NMTOKEN:
processedValue=processNMTOKEN(handler,uri,name,rawName,value,owner);
break;
case T_PATTERN:
processedValue=processPATTERN(handler,uri,name,rawName,value,owner);
break;
case T_NUMBER:
processedValue=processNUMBER(handler,uri,name,rawName,value,owner);
break;
case T_QNAME:
processedValue=processQNAME(handler,uri,name,rawName,value,owner);
break;
case T_QNAMES:
processedValue=processQNAMES(handler,uri,name,rawName,value);
break;
case T_QNAMES_RESOLVE_NULL:
processedValue=processQNAMESRNU(handler,uri,name,rawName,value);
break;
case T_SIMPLEPATTERNLIST:
processedValue=processSIMPLEPATTERNLIST(handler,uri,name,rawName,value,owner);
break;
case T_URL:
processedValue=processURL(handler,uri,name,rawName,value,owner);
break;
case T_YESNO:
processedValue=processYESNO(handler,uri,name,rawName,value);
break;
case T_STRINGLIST:
processedValue=processSTRINGLIST(handler,uri,name,rawName,value);
break;
case T_PREFIX_URLLIST:
processedValue=processPREFIX_URLLIST(handler,uri,name,rawName,value);
break;
case T_ENUM_OR_PQNAME:
processedValue=processENUM_OR_PQNAME(handler,uri,name,rawName,value,owner);
break;
case T_NCNAME:
processedValue=processNCNAME(handler,uri,name,rawName,value,owner);
break;
case T_AVT_QNAME:
processedValue=processAVT_QNAME(handler,uri,name,rawName,value,owner);
break;
case T_PREFIXLIST:
processedValue=processPREFIX_LIST(handler,uri,name,rawName,value);
break;
default :
}
return processedValue;
}
| Process an attribute value. |
public synchronized void add(String name,long threadId){
if (mFinished) {
throw new IllegalStateException("Marker added to finished log");
}
mMarkers.add(new Marker(name,threadId,SystemClock.elapsedRealtime()));
}
| Adds a marker to this log with the specified name. |
private static int convertToValue(final String rawValue){
int value=-1;
if (rawValue.equals("\"SUM\"")) {
value=SUM;
}
else if (rawValue.equals("\"AVG\"")) {
value=AVG;
}
else if (rawValue.equals("\"PRD\"")) {
value=PRD;
}
else if (rawValue.equals("\"MIN\"")) {
value=MIN;
}
else if (rawValue.equals("\"MAX\"")) {
value=MAX;
}
return value;
}
| get string name as int value if recognised |
public static final String toFEN(Position pos){
StringBuilder ret=new StringBuilder();
for (int r=7; r >= 0; r--) {
int numEmpty=0;
for (int c=0; c < 8; c++) {
int p=pos.getPiece(Position.getSquare(c,r));
if (p == Piece.EMPTY) {
numEmpty++;
}
else {
if (numEmpty > 0) {
ret.append(numEmpty);
numEmpty=0;
}
switch (p) {
case Piece.WKING:
ret.append('K');
break;
case Piece.WQUEEN:
ret.append('Q');
break;
case Piece.WROOK:
ret.append('R');
break;
case Piece.WBISHOP:
ret.append('B');
break;
case Piece.WKNIGHT:
ret.append('N');
break;
case Piece.WPAWN:
ret.append('P');
break;
case Piece.BKING:
ret.append('k');
break;
case Piece.BQUEEN:
ret.append('q');
break;
case Piece.BROOK:
ret.append('r');
break;
case Piece.BBISHOP:
ret.append('b');
break;
case Piece.BKNIGHT:
ret.append('n');
break;
case Piece.BPAWN:
ret.append('p');
break;
default :
throw new RuntimeException();
}
}
}
if (numEmpty > 0) {
ret.append(numEmpty);
}
if (r > 0) {
ret.append('/');
}
}
ret.append(pos.whiteMove ? " w " : " b ");
boolean anyCastle=false;
if (pos.h1Castle()) {
ret.append('K');
anyCastle=true;
}
if (pos.a1Castle()) {
ret.append('Q');
anyCastle=true;
}
if (pos.h8Castle()) {
ret.append('k');
anyCastle=true;
}
if (pos.a8Castle()) {
ret.append('q');
anyCastle=true;
}
if (!anyCastle) {
ret.append('-');
}
{
ret.append(' ');
if (pos.getEpSquare() >= 0) {
int x=Position.getX(pos.getEpSquare());
int y=Position.getY(pos.getEpSquare());
ret.append((char)(x + 'a'));
ret.append((char)(y + '1'));
}
else {
ret.append('-');
}
}
ret.append(' ');
ret.append(pos.halfMoveClock);
ret.append(' ');
ret.append(pos.fullMoveCounter);
return ret.toString();
}
| Return a FEN string corresponding to a chess Position object. |
public static void announceDeletion(final DigestURL url,final int depth,final State state){
if (state == State.INVENTORY || state == State.ANY) inventory.announceDeletion(url,depth);
if (state == State.ARCHIVE || state == State.ANY) archive.announceDeletion(url,depth);
}
| Delete information about the storage of a snapshot to the Snapshot-internal index. The actual deletion of files in the target directory must be done elsewehre, this method does not store the snapshot files. |
public void stopProcess(){
if (getProcessState() != Process.PROCESS_STATE_STOPPED) {
getProcess().getLogger().info("Process stopped. Completing current operator.");
getStatusBar().setSpecialText("Process stopped. Completing current operator.");
if (processThread != null) {
if (processThread.isAlive()) {
processThread.setPriority(Thread.MIN_PRIORITY);
processThread.stopProcess();
}
}
}
}
| Can be used to stop the currently running process. Please note that the ProcessThread will still be running in the background until the current operator is finished. |
public CUnselectSubtreeNodesAction(final ZyGraph graph,final ITreeNode<CTag> tag){
super("Unselect Subtree Nodes");
m_graph=Preconditions.checkNotNull(graph,"IE02323: Graph argument can not be null");
m_tag=Preconditions.checkNotNull(tag,"IE02324: Tag can't be null");
}
| Creates a new action object. |
public void yypushback(int number){
if (number > yylength()) zzScanError(ZZ_PUSHBACK_2BIG);
zzMarkedPos-=number;
}
| Pushes the specified amount of characters back into the input stream. They will be read again by then next call of the scanning method |
public final boolean isClassC(){
return (ipAddress & 0x00000007) == 3;
}
| Check if the IP address is belongs to a Class C IP address. |
public SemIm(SemPm semPm){
this(semPm,null,new Parameters());
}
| Constructs a new SEM IM from a SEM PM. |
public ConnectionConfig(){
super();
}
| Ctor for a functional Swing object with no existing adapter |
public static String addSentenceMarkers(String s){
return Vocabulary.START_SYM + " " + s+ " "+ Vocabulary.STOP_SYM;
}
| wrap sentence with sentence start/stop markers as defined by Vocabulary; separated by a single whitespace. |
private void updateProgress(String progressLabel,int progress){
if (myHost != null) {
myHost.updateProgress(progressLabel,progress);
}
else {
System.out.println(progressLabel + " " + progress+ "%");
}
}
| Used to communicate a progress update between a plugin tool and the main Whitebox user interface. |
private void inspect(final Player admin,final RPObject target){
final StringBuilder sb=new StringBuilder();
sb.append("Inspecting " + target.get("name") + "\n");
for ( final String value : target) {
sb.append(value + ": " + target.get(value)+ "\n");
}
admin.sendPrivateText(sb.toString());
sb.setLength(0);
for ( final RPSlot slot : target.slots()) {
if (slot.getName().equals("!buddy") || slot.getName().equals("!ignore")) {
continue;
}
sb.append("\nSlot " + slot.getName() + ": \n");
for ( final RPObject object : slot) {
sb.append(" " + object + "\n");
}
sb.append("\n");
admin.sendPrivateText(sb.toString());
sb.setLength(0);
}
if (target instanceof Player) {
Player player=(Player)target;
sb.append("Production:\n ");
final ProducerRegister producerRegister=SingletonRepository.getProducerRegister();
final List<String> produceList=new LinkedList<String>();
for ( String food : producerRegister.getProducedItemNames("food")) {
produceList.add(food);
}
for ( String drink : producerRegister.getProducedItemNames("drink")) {
produceList.add(drink);
}
for ( String resource : producerRegister.getProducedItemNames("resource")) {
produceList.add(resource);
}
for ( String product : produceList) {
int quant=player.getQuantityOfProducedItems(product);
if (quant > 0) {
sb.append("[" + product + "="+ Integer.toString(quant)+ "]");
}
}
sb.append("\n");
admin.sendPrivateText(sb.toString());
sb.setLength(0);
Collection<Item> itemList=SingletonRepository.getEntityManager().getItems();
sb.append("Loots:\n ");
int itemCount=0;
for ( Item item : itemList) {
itemCount=player.getNumberOfLootsForItem(item.getName());
if (itemCount > 0) {
sb.append("[" + item.getName() + "="+ Integer.toString(itemCount)+ "]");
}
}
sb.append("\n");
admin.sendPrivateText(sb.toString());
sb.setLength(0);
sb.append("Harvested Items (FishSource, FlowerGrower, VegetableGrower):\n ");
itemCount=0;
for ( Item item : itemList) {
itemCount=player.getQuantityOfHarvestedItems(item.getName());
if (itemCount > 0) {
sb.append("[" + item.getName() + "="+ Integer.toString(itemCount)+ "]");
}
}
sb.append("\n");
admin.sendPrivateText(sb.toString());
sb.setLength(0);
}
}
| Inspects a player |
private boolean isViewTopHigherThenPreviousViewBottom(int previousViewBottom,int viewTop){
return viewTop < previousViewBottom;
}
| View top is higher when it's smaller then previous View Bottom |
@DSGenerator(tool_name="Doppelganger",tool_version="2.0",generated_on="2013-12-30 13:00:59.704 -0500",hash_original_method="7B8E28B63F298B36AFEC228A9203A43A",hash_generated_method="BA670570AB62185827AD01CD9C696E60") public static void checkURI(String uri) throws IOException {
try {
URI ur=new URI(uri);
if (ur.getScheme() == null || ur.getRawSchemeSpecificPart().isEmpty()) {
throw new IOException("No scheme or scheme-specific-part in uniformResourceIdentifier: " + uri);
}
if (!ur.isAbsolute()) {
throw new IOException("Relative uniformResourceIdentifier: " + uri);
}
}
catch ( URISyntaxException e) {
throw (IOException)new IOException("Bad representation of uniformResourceIdentifier: " + uri).initCause(e);
}
}
| Checks the correctness of the string representation of URI name. The correctness is checked as pointed out in RFC 3280 p. 34. |
@SuppressWarnings("WeakerAccess") public TerminalEmulatorDeviceConfiguration(int lineBufferScrollbackSize,int blinkLengthInMilliSeconds,CursorStyle cursorStyle,TextColor cursorColor,boolean cursorBlinking){
this(lineBufferScrollbackSize,blinkLengthInMilliSeconds,cursorStyle,cursorColor,cursorBlinking,true);
}
| Creates a new terminal device configuration object with all configurable values specified. |
private void cmdConvert(CommandSender sender,String[] args){
if (isNotPermissed(sender,"nametagedit.convert")) return;
if (args.length != 4) {
NametagMessages.USAGE_CONVERT.send(sender);
}
else {
boolean sourceIsFile=args[1].equalsIgnoreCase("file");
boolean destinationIsSQL=args[2].equalsIgnoreCase("db");
boolean legacy=args[3].equalsIgnoreCase("true");
NametagMessages.CONVERSION.send(sender,"groups & players",sourceIsFile ? "file" : "mysql",destinationIsSQL ? "mysql" : "file",legacy);
if (sourceIsFile && !destinationIsSQL && legacy) {
new Converter().legacyConversion(sender,handler.getPlugin());
}
else if ((destinationIsSQL && sourceIsFile) || (!sourceIsFile && !destinationIsSQL)) {
new ConverterTask(!destinationIsSQL,sender,handler.getPlugin()).runTaskAsynchronously(handler.getPlugin());
}
}
}
| Handles /nte convert |
public List<Synapse> connectAllToAll(List<Neuron> sourceNeurons,List<Neuron> targetNeurons){
return connectAllToAll(sourceNeurons,targetNeurons,Utils.intersects(sourceNeurons,targetNeurons),selfConnectionAllowed,true);
}
| Connect all to all using underlying connection object to store parameters. Used by quick connect. |
public Vset checkAmbigName(Environment env,Context ctx,Vset vset,Hashtable exp,UnaryExpression loc){
return checkValue(env,ctx,vset,exp);
}
| Check something that might be an AmbiguousName (refman 6.5.2). A string of dot-separated identifiers might be, in order of preference: <nl> <li> a variable name followed by fields or types <li> a type name followed by fields or types <li> a package name followed a type and then fields or types </nl> If a type name is found, it rewrites itself as a <tt>TypeExpression</tt>. If a node decides it can only be a package prefix, it sets its type to <tt>Type.tPackage</tt>. The caller must detect this and act appropriately to verify the full package name. |
public final int size(){
return numOfEntries;
}
| Returns the number of the entries. |
public void initializeClassifier(Instances data) throws Exception {
m_RandomInstance=new Random(m_Seed);
int classIndex=data.classIndex();
if (m_Classifier == null) {
throw new Exception("A base classifier has not been specified!");
}
if (!(m_Classifier instanceof WeightedInstancesHandler) && !m_UseResampling) {
m_UseResampling=true;
}
getCapabilities().testWithFail(data);
if (m_Debug) {
System.err.println("Creating copy of the training data");
}
m_data=new Instances(data);
m_data.deleteWithMissingClass();
if (m_data.numAttributes() == 1) {
System.err.println("Cannot build model (only class attribute present in data!), " + "using ZeroR model instead!");
m_ZeroR=new weka.classifiers.rules.ZeroR();
m_ZeroR.buildClassifier(m_data);
return;
}
else {
m_ZeroR=null;
}
m_NumClasses=m_data.numClasses();
m_ClassAttribute=m_data.classAttribute();
if (m_Debug) {
System.err.println("Creating base classifiers");
}
m_Classifiers=new ArrayList<Classifier[]>();
int numInstances=m_data.numInstances();
m_trainFs=new double[numInstances][m_NumClasses];
m_trainYs=new double[numInstances][m_NumClasses];
for (int j=0; j < m_NumClasses; j++) {
for (int i=0, k=0; i < numInstances; i++, k++) {
m_trainYs[i][j]=(m_data.instance(k).classValue() == j) ? 1.0 - m_Offset : 0.0 + (m_Offset / (double)m_NumClasses);
}
}
m_data.setClassIndex(-1);
m_data.deleteAttributeAt(classIndex);
m_data.insertAttributeAt(new Attribute("'pseudo class'"),classIndex);
m_data.setClassIndex(classIndex);
m_NumericClassData=new Instances(m_data,0);
m_probs=initialProbs(numInstances);
m_logLikelihood=logLikelihood(m_trainYs,m_probs);
m_NumGenerated=0;
if (m_Debug) {
System.err.println("Avg. log-likelihood: " + m_logLikelihood);
}
m_sumOfWeights=m_data.sumOfWeights();
}
| Builds the boosted classifier |
public int compare(JavaScriptElement element1,JavaScriptElement element2){
int category1=category(element1);
int category2=category(element2);
if (category1 != category2) {
return category1 - category2;
}
return element1.friendlyString().compareTo(element2.friendlyString());
}
| Compares two Build Elements. Returns a negative number if first build element has a lower category value. Returns a positive number if the first build element has a higher category value. If category values are equal, returns the string comparison of their friendly strings. |
public static double quantile(double p,double k,double theta,double shift){
return Math.log(GammaDistribution.quantile(p,k,theta)) + shift;
}
| Compute probit (inverse cdf) for ExpGamma distributions. |
@SuppressWarnings("deprecation") static HttpUriRequest createHttpRequest(Request<?> request,Map<String,String> additionalHeaders) throws AuthFailureError {
switch (request.getMethod()) {
case Method.DEPRECATED_GET_OR_POST:
{
byte[] postBody=request.getPostBody();
if (postBody != null) {
HttpPost postRequest=new HttpPost(request.getUrl());
postRequest.addHeader(HEADER_CONTENT_TYPE,request.getPostBodyContentType());
HttpEntity entity;
entity=new ByteArrayEntity(postBody);
postRequest.setEntity(entity);
return postRequest;
}
else {
return new HttpGet(request.getUrl());
}
}
case Method.GET:
return new HttpGet(request.getUrl());
case Method.DELETE:
return new HttpDelete(request.getUrl());
case Method.POST:
{
HttpPost postRequest=new HttpPost(request.getUrl());
postRequest.addHeader(HEADER_CONTENT_TYPE,request.getBodyContentType());
setEntityIfNonEmptyBody(postRequest,request);
return postRequest;
}
case Method.PUT:
{
HttpPut putRequest=new HttpPut(request.getUrl());
putRequest.addHeader(HEADER_CONTENT_TYPE,request.getBodyContentType());
setEntityIfNonEmptyBody(putRequest,request);
return putRequest;
}
case Method.HEAD:
return new HttpHead(request.getUrl());
case Method.OPTIONS:
return new HttpOptions(request.getUrl());
case Method.TRACE:
return new HttpTrace(request.getUrl());
case Method.PATCH:
{
HttpPatch patchRequest=new HttpPatch(request.getUrl());
patchRequest.addHeader(HEADER_CONTENT_TYPE,request.getBodyContentType());
setEntityIfNonEmptyBody(patchRequest,request);
return patchRequest;
}
default :
throw new IllegalStateException("Unknown request method.");
}
}
| Creates the appropriate subclass of HttpUriRequest for passed in request. |
public static void selectClickedRow(final JTable table,final MouseEvent event){
final int row=table.rowAtPoint(event.getPoint());
if (row == -1) {
return;
}
table.setRowSelectionInterval(row,row);
}
| Selects a table row depending on a mouse event. |
public int size(){
return al.size();
}
| Returns the number of elements in this set. |
public static void i(Object... msg){
if (LuaViewConfig.isDebug()) {
Log.i(DEFAULT_PREFIX,getMsg(msg));
}
}
| log a info message |
private void returnData(Object ret){
if (myHost != null) {
myHost.returnData(ret);
}
}
| Used to communicate a return object from a plugin tool to the main Whitebox user-interface. |
public PointMutation(double probability){
super();
this.probability=probability;
}
| Constructs a new point mutation instance. |
protected static File createRelativePath(File absolute) throws Exception {
File userDir=new File(System.getProperty("user.dir"));
String userPath=userDir.getAbsolutePath() + File.separator;
String targetPath=(new File(absolute.getParent())).getPath() + File.separator;
String fileName=absolute.getName();
StringBuffer relativePath=new StringBuffer();
int subdir=targetPath.indexOf(userPath);
if (subdir == 0) {
if (userPath.length() == targetPath.length()) {
relativePath.append(fileName);
}
else {
int ll=userPath.length();
relativePath.append(targetPath.substring(ll));
relativePath.append(fileName);
}
}
else {
int sepCount=0;
String temp=new String(userPath);
while (temp.indexOf(File.separator) != -1) {
int ind=temp.indexOf(File.separator);
sepCount++;
temp=temp.substring(ind + 1,temp.length());
}
String targetTemp=new String(targetPath);
String userTemp=new String(userPath);
int tcount=0;
while (targetTemp.indexOf(File.separator) != -1) {
int ind=targetTemp.indexOf(File.separator);
int ind2=userTemp.indexOf(File.separator);
String tpart=targetTemp.substring(0,ind + 1);
String upart=userTemp.substring(0,ind2 + 1);
if (tpart.compareTo(upart) != 0) {
if (tcount == 0) {
tcount=-1;
}
break;
}
tcount++;
targetTemp=targetTemp.substring(ind + 1,targetTemp.length());
userTemp=userTemp.substring(ind2 + 1,userTemp.length());
}
if (tcount == -1) {
throw new Exception("Can't construct a path to file relative to user " + "dir.");
}
if (targetTemp.indexOf(File.separator) == -1) {
targetTemp="";
}
for (int i=0; i < sepCount - tcount; i++) {
relativePath.append(".." + File.separator);
}
relativePath.append(targetTemp + fileName);
}
return new File(relativePath.toString());
}
| Converts a File's absolute path to a path relative to the user (ie start) directory. |
protected void pickUpCar(PrintWriter file,Car car,boolean isManifest){
if (isManifest) {
pickUpCar(file,car,new StringBuffer(padAndTruncateString(Setup.getPickupCarPrefix(),Setup.getManifestPrefixLength())),Setup.getPickupManifestMessageFormat(),isManifest);
}
else {
pickUpCar(file,car,new StringBuffer(padAndTruncateString(Setup.getSwitchListPickupCarPrefix(),Setup.getSwitchListPrefixLength())),Setup.getPickupSwitchListMessageFormat(),isManifest);
}
}
| Adds the car's pick up string to the output file using the manifest or switch list format |
public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception {
String errM="";
sessionContext.checkPermission(Right.TimetableManagers);
WebTable.setOrder(sessionContext,"timetableManagerList.ord",request.getParameter("order"),1);
boolean showAll="1".equals(sessionContext.getUser().getProperty("TimetableManagers.showAll","0"));
if (request.getParameter("all") != null) {
showAll=("true".equalsIgnoreCase(request.getParameter("all")));
sessionContext.getUser().setProperty("TimetableManagers.showAll",showAll ? "1" : "0");
}
PdfWebTable table=new TimetableManagerBuilder().getManagersTable(sessionContext,true,showAll);
int order=WebTable.getOrder(sessionContext,"timetableManagerList.ord");
String tblData=table.printTable(order);
if ("Export PDF".equals(request.getParameter("op"))) {
ExportUtils.exportPDF(new TimetableManagerBuilder().getManagersTable(sessionContext,false,showAll),order,response,"managers");
return null;
}
request.setAttribute("schedDeputyList",errM + tblData);
request.setAttribute("showAllManagers",showAll);
return mapping.findForward("success");
}
| Reads list of schedule deputies and assistants and displays them in the form of a HTML table |
public Configurator emptyImage(int imageRes){
if (imageRes > 0) {
viewEmptyImage=imageRes;
}
return this;
}
| Customize the empty view image. |
public BaseElement(Node n,BaseElement parent){
node=n;
attributes=n.getAttributes();
if (parent != null) {
this.parent=parent;
parent.children.add(this);
errors_are_exceptions=parent.errors_are_exceptions;
log=parent.log;
}
}
| Create a new XML element. Children inherit settings from their parent |
public int decode(String data,OutputStream out) throws IOException {
byte b1, b2, b3, b4;
int length=0;
int end=data.length();
while (end > 0) {
if (!ignore(data.charAt(end - 1))) {
break;
}
end--;
}
int i=0;
int finish=end - 4;
i=nextI(data,i,finish);
while (i < finish) {
b1=decodingTable[data.charAt(i++)];
i=nextI(data,i,finish);
b2=decodingTable[data.charAt(i++)];
i=nextI(data,i,finish);
b3=decodingTable[data.charAt(i++)];
i=nextI(data,i,finish);
b4=decodingTable[data.charAt(i++)];
if ((b1 | b2 | b3| b4) < 0) {
throw new IOException("invalid characters encountered in base64 data");
}
out.write((b1 << 2) | (b2 >> 4));
out.write((b2 << 4) | (b3 >> 2));
out.write((b3 << 6) | b4);
length+=3;
i=nextI(data,i,finish);
}
length+=decodeLastBlock(out,data.charAt(end - 4),data.charAt(end - 3),data.charAt(end - 2),data.charAt(end - 1));
return length;
}
| decode the base 64 encoded String data writing it to the given output stream, whitespace characters will be ignored. |
private String printOFormat(final long x){
String sx=null;
if (x == Long.MIN_VALUE) {
sx="1000000000000000000000";
}
else if (x < 0) {
final String t=Long.toString((~(-x - 1)) ^ Long.MIN_VALUE,8);
switch (t.length()) {
case 1:
sx="100000000000000000000" + t;
break;
case 2:
sx="10000000000000000000" + t;
break;
case 3:
sx="1000000000000000000" + t;
break;
case 4:
sx="100000000000000000" + t;
break;
case 5:
sx="10000000000000000" + t;
break;
case 6:
sx="1000000000000000" + t;
break;
case 7:
sx="100000000000000" + t;
break;
case 8:
sx="10000000000000" + t;
break;
case 9:
sx="1000000000000" + t;
break;
case 10:
sx="100000000000" + t;
break;
case 11:
sx="10000000000" + t;
break;
case 12:
sx="1000000000" + t;
break;
case 13:
sx="100000000" + t;
break;
case 14:
sx="10000000" + t;
break;
case 15:
sx="1000000" + t;
break;
case 16:
sx="100000" + t;
break;
case 17:
sx="10000" + t;
break;
case 18:
sx="1000" + t;
break;
case 19:
sx="100" + t;
break;
case 20:
sx="10" + t;
break;
case 21:
sx='1' + t;
break;
}
}
else {
sx=Long.toString(x,8);
}
return printOFormat(sx);
}
| Format method for the o conversion character and long argument. For o format, the flag character '-', means that the output should be left justified within the field. The default is to pad with blanks on the left. The '#' flag character means that the output begins with a leading 0 and the precision is increased by 1. The field width is treated as the minimum number of characters to be printed. The default is to add no padding. Padding is with blanks by default. The precision, if set, is the minimum number of digits to appear. Padding is with leading 0s. |
public void init() throws ServletException {
}
| Initialization of the servlet. <br> |
public void removeItem(YeomanGeneratorType type,String name,GeneratedItemView itemView){
List<String> existingNames=namesByTypes.get(type);
if (existingNames != null && existingNames.contains(name)) {
existingNames.remove(name);
if (existingNames.isEmpty()) {
namesByTypes.remove(type);
FoldingPanel previous=widgetByTypes.remove(type);
view.removeFoldingPanel(previous);
}
else {
FoldingPanel selectedPanel=widgetByTypes.get(type);
selectedPanel.remove(itemView);
}
}
updateGenerateButton();
}
| Remove an item from the data |
public SortableAndSearchableWrapperTableModel(TableModel model){
super();
m_MouseListener=null;
m_SortedIndices=null;
m_DisplayIndices=null;
m_ColumnIsNumeric=null;
setUnsortedModel(model);
}
| initializes with the given model. |
void cancelAllSuperActivityToasts(){
removeMessages(Messages.DISPLAY);
removeMessages(Messages.REMOVE);
for ( SuperActivityToast superActivityToast : mList) {
if (superActivityToast.isShowing()) {
superActivityToast.getViewGroup().removeView(superActivityToast.getView());
superActivityToast.getViewGroup().invalidate();
}
}
mList.clear();
}
| Removes all SuperActivityToasts and clears the list |
public void playSequentially(List<Animator> items){
if (items != null && items.size() > 0) {
mNeedsSort=true;
if (items.size() == 1) {
play(items.get(0));
}
else {
for (int i=0; i < items.size() - 1; ++i) {
play(items.get(i)).before(items.get(i + 1));
}
}
}
}
| Sets up this AnimatorSet to play each of the supplied animations when the previous animation ends. |
public boolean exportFormatX509(){
return formatX509;
}
| Was chosen export format X.509? |
public void write(org.apache.thrift.protocol.TProtocol oprot,Attachment struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.isSetId()) {
oprot.writeFieldBegin(ID_FIELD_DESC);
oprot.writeI64(struct.id);
oprot.writeFieldEnd();
}
if (struct.type != null) {
oprot.writeFieldBegin(TYPE_FIELD_DESC);
oprot.writeString(struct.type);
oprot.writeFieldEnd();
}
if (struct.name != null) {
if (struct.isSetName()) {
oprot.writeFieldBegin(NAME_FIELD_DESC);
oprot.writeString(struct.name);
oprot.writeFieldEnd();
}
}
if (struct.isSetFileSize()) {
oprot.writeFieldBegin(FILE_SIZE_FIELD_DESC);
oprot.writeI64(struct.fileSize);
oprot.writeFieldEnd();
}
if (struct.url != null) {
oprot.writeFieldBegin(URL_FIELD_DESC);
oprot.writeString(struct.url);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
| Description: <br> |
public static Map consultFolderInfo(AxSf axsf,Integer bookID,int page,Locale locale,Map extendedValues,String origen,String destino,Map fldDefs){
String data=axsf.getFormat().getData();
FormFormat formFormat=new FormFormat(data);
longFormatter=new SimpleDateFormat(RBUtil.getInstance(locale).getProperty(I18N_DATE_LONGFORMAT));
shortFormatter=new SimpleDateFormat(RBUtil.getInstance(locale).getProperty(I18N_DATE_SHORTFORMAT));
TreeMap pages=formFormat.getDlgDef().getPagedefs();
FPageDef pageDef=(FPageDef)pages.get(new Integer(page));
TreeMap ctrls=pageDef.getCtrldefs();
FCtrlDef ctrlDef=null;
Map folderValues=new HashMap();
String value=null;
FFldDef flddef=null;
for (Iterator it=ctrls.values().iterator(); it.hasNext(); ) {
ctrlDef=(FCtrlDef)it.next();
if (ctrlDef.getName().startsWith(IDOC_EDIT)) {
value=getFolderInfoFromForm(ctrlDef,axsf,locale,extendedValues,origen,destino);
for (Iterator it1=fldDefs.keySet().iterator(); it1.hasNext(); ) {
Integer key=(Integer)it1.next();
flddef=(FFldDef)fldDefs.get(key);
if (flddef.getColname().equals(XML_FLD_UPPERF_TEXT + ctrlDef.getFldId())) {
break;
}
}
folderValues.put(flddef.getColname(),value);
}
}
return folderValues;
}
| Public methods |
public void incomingPanDisconnection(BluetoothAdapter adapter,BluetoothDevice device){
disconnectFromRemoteOrVerifyConnectNap(adapter,device,false);
}
| Checks that a remote PANU disconnects from the local NAP correctly and that the correct actions were broadcast. |
private static void writeHeader(File file,OutputStream out) throws IOException {
String header="*** " + file.toString() + "\n";
out.write(header.getBytes());
}
| Writes a header for the given file. |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.