code
stringlengths 10
174k
| nl
stringlengths 3
129k
|
---|---|
public void onSequenceAborted(int sequenceId){
}
| Note that this is typically invoked on the camera thread and at high frequency, so implementations must execute quickly and not make assumptions regarding the thread they are on. |
public static Float[] convertSVGNumberOptionalNumber(Element elem,String attrName,String attrValue,BridgeContext ctx){
Float[] ret=new Float[2];
if (attrValue.length() == 0) return ret;
try {
StringTokenizer tokens=new StringTokenizer(attrValue," ");
ret[0]=new Float(Float.parseFloat(tokens.nextToken()));
if (tokens.hasMoreTokens()) {
ret[1]=new Float(Float.parseFloat(tokens.nextToken()));
}
if (tokens.hasMoreTokens()) {
throw new BridgeException(ctx,elem,ERR_ATTRIBUTE_VALUE_MALFORMED,new Object[]{attrName,attrValue});
}
}
catch ( NumberFormatException nfEx) {
throw new BridgeException(ctx,elem,nfEx,ERR_ATTRIBUTE_VALUE_MALFORMED,new Object[]{attrName,attrValue,nfEx});
}
return ret;
}
| This function parses attrValue for a number followed by an optional second Number. It always returns an array of two Floats. If either or both values are not provided the entries are set to null |
public String numExamplesTipText(){
return "The number of examples to generate.";
}
| Returns the tip text for this property |
public Object jjtAccept(SyntaxTreeBuilderVisitor visitor,Object data) throws VisitorException {
return visitor.visit(this,data);
}
| Accept the visitor. |
public User clear(){
emailHash=null;
isFollowing=false;
return this;
}
| Reset the fields in this class (but not the parent) to their default values. |
public static Validator<CharSequence> iri(@NonNull final Context context,@StringRes final int resourceId){
return new IRIValidator(context,resourceId);
}
| Creates and returns a validator, which allows to validate texts to ensure, that they represent valid IRIs. IRIs are internationalized URLs according to RFC 3987, which are for example used as internet addresses. Empty texts are also accepted. |
private void drawVerticalDividers(Canvas canvas,RecyclerView parent){
int parentLeft=parent.getPaddingLeft();
int parentRight=parent.getWidth() - parent.getPaddingRight();
int childCount=parent.getChildCount();
int numChildrenOnLastRow=childCount % mNumColumns;
int numRows=childCount / mNumColumns;
if (numChildrenOnLastRow == 0) {
numRows--;
}
for (int i=0; i < numRows; i++) {
View child=parent.getChildAt(i * mNumColumns);
RecyclerView.LayoutParams params=(RecyclerView.LayoutParams)child.getLayoutParams();
int parentTop=child.getBottom() + params.bottomMargin;
int parentBottom=parentTop + mVerticalDivider.getIntrinsicHeight();
mVerticalDivider.setBounds(parentLeft,parentTop,parentRight,parentBottom);
mVerticalDivider.draw(canvas);
}
}
| Adds vertical dividers to a RecyclerView with a GridLayoutManager or its subclass. |
public ModpackDescriptionPanel(WizardController controller,Map wizardData){
initComponents();
this.controller=controller;
this.wizardData=wizardData;
}
| Creates new form ModpackDescriptionPanel |
private void ensureCapacity(int n){
if (n <= 0) {
return;
}
int max;
if (data == null || data.length == 0) {
max=25;
}
else if (data.length >= n * 5) {
return;
}
else {
max=data.length;
}
while (max < n * 5) {
max*=2;
}
String newData[]=new String[max];
if (length > 0) {
System.arraycopy(data,0,newData,0,length * 5);
}
data=newData;
}
| Ensure the internal array's capacity. |
public static int[] copyOfRange(int[] original,int from,int to){
int newLength=to - from;
if (newLength < 0) throw new IllegalArgumentException(from + " > " + to);
int[] copy=new int[newLength];
System.arraycopy(original,from,copy,0,Math.min(original.length - from,newLength));
return copy;
}
| Copies the specified range of the specified array into a new array. The initial index of the range (<tt>from</tt>) must lie between zero and <tt>original.length</tt>, inclusive. The value at <tt>original[from]</tt> is placed into the initial element of the copy (unless <tt>from == original.length</tt> or <tt>from == to</tt>). Values from subsequent elements in the original array are placed into subsequent elements in the copy. The final index of the range (<tt>to</tt>), which must be greater than or equal to <tt>from</tt>, may be greater than <tt>original.length</tt>, in which case <tt>0</tt> is placed in all elements of the copy whose index is greater than or equal to <tt>original.length - from</tt>. The length of the returned array will be <tt>to - from</tt>. |
@SuppressWarnings("unchecked") public final void testSetConstraints(){
Constraint<Object> constraint1=new ConstraintImplementation(true);
Constraint<Object> constraint2=new ConstraintImplementation(true);
Constraint<Object>[] constraints1=new Constraint[1];
constraints1[0]=constraint1;
Constraint<Object>[] constraints2=new Constraint[2];
constraints2[0]=constraint1;
constraints2[1]=constraint2;
DisjunctiveConstraint<Object> disjunctiveConstraint=new DisjunctiveConstraint<>(constraints1);
disjunctiveConstraint.setConstraints(constraints2);
assertEquals(constraints2,disjunctiveConstraint.getConstraints());
}
| Tests the functionality of the method, which allows to set the constraints. |
public String greetServer(String input) throws IllegalArgumentException {
return "";
}
| Method with param and exception |
public static TrueTypeTable createTable(TrueTypeFont ttf,String tagString,ByteBuffer data){
TrueTypeTable outTable=null;
int tag=stringToTag(tagString);
switch (tag) {
case CMAP_TABLE:
outTable=new CmapTable();
break;
case GLYF_TABLE:
outTable=new GlyfTable(ttf);
break;
case HEAD_TABLE:
outTable=new HeadTable();
break;
case HHEA_TABLE:
outTable=new HheaTable();
break;
case HMTX_TABLE:
outTable=new HmtxTable(ttf);
break;
case LOCA_TABLE:
outTable=new LocaTable(ttf);
break;
case MAXP_TABLE:
outTable=new MaxpTable();
break;
case NAME_TABLE:
outTable=new NameTable();
break;
case POST_TABLE:
outTable=new PostTable();
break;
default :
outTable=new TrueTypeTable(tag);
break;
}
if (data != null) {
outTable.setData(data);
}
return outTable;
}
| Get a new instance of a table with provided data |
public URIBuilder addParameter(final String param,final String value){
if (this.queryParams == null) {
this.queryParams=new ArrayList<NameValuePair>();
}
this.queryParams.add(new BasicNameValuePair(param,value));
this.encodedQuery=null;
this.encodedSchemeSpecificPart=null;
return this;
}
| Adds parameter to URI query. The parameter name and value are expected to be unescaped and may contain non ASCII characters. |
private PsiElement findBestResult(Multimap<Integer,PsiElement> results,boolean firstResult,PsiElement referenceElement){
if (!hasResults()) {
return null;
}
if (firstResult) {
return Iterators.get(results.values().iterator(),0);
}
int referenceLevel=preferNeigbourhood && (referenceElement != null) ? BashPsiUtils.blockNestingLevel(referenceElement) : 0;
int bestRating=Integer.MAX_VALUE;
int bestDelta=Integer.MAX_VALUE;
for ( int rating : results.keySet()) {
final int delta=Math.abs(referenceLevel - rating);
if (delta < bestDelta) {
bestDelta=delta;
bestRating=rating;
}
}
if (preferNeigbourhood) {
return Iterators.getLast(results.get(bestRating).iterator());
}
else {
long smallestOffset=Integer.MAX_VALUE;
PsiElement bestElement=null;
for ( PsiElement e : results.get(bestRating)) {
int textOffset=e.getTextOffset();
if (BashPsiUtils.isInjectedElement(e)) {
PsiLanguageInjectionHost injectionHost=InjectedLanguageManager.getInstance(e.getProject()).getInjectionHost(e);
if (injectionHost != null) {
textOffset=textOffset + injectionHost.getTextOffset();
}
}
if (textOffset < smallestOffset) {
smallestOffset=textOffset;
bestElement=e;
}
}
return bestElement;
}
}
| Returns the best results. It takes all the elements which have been rated the best and returns the first / last, depending on the parameter. |
protected void drawArcForInterval(Graphics2D g2,Rectangle2D meterArea,MeterInterval interval){
double minValue=interval.getRange().getLowerBound();
double maxValue=interval.getRange().getUpperBound();
Paint outlinePaint=interval.getOutlinePaint();
Stroke outlineStroke=interval.getOutlineStroke();
Paint backgroundPaint=interval.getBackgroundPaint();
if (backgroundPaint != null) {
fillArc(g2,meterArea,minValue,maxValue,backgroundPaint,false);
}
if (outlinePaint != null) {
if (outlineStroke != null) {
drawArc(g2,meterArea,minValue,maxValue,outlinePaint,outlineStroke);
}
drawTick(g2,meterArea,minValue,true);
drawTick(g2,meterArea,maxValue,true);
}
}
| Draws the arc to represent an interval. |
public static String convertCalendarToStr(Calendar cal) throws Exception {
SimpleDateFormat format=new SimpleDateFormat(ScheduleInfo.FULL_DAYTIME_FORMAT);
String formatted=format.format(cal.getTime());
log.debug("converted calendar time:{}",formatted);
return formatted;
}
| Convert a Calendar to a readable time string. |
private void validateSourcePolicy(ProtectionSourcePolicy sourcePolicy){
if (sourcePolicy != null) {
if (sourcePolicy.getJournalSize() != null) {
if (!isParsableToDouble(sourcePolicy.getJournalSize()) && !sourcePolicy.getJournalSize().matches(JOURNAL_REGEX_1) && !sourcePolicy.getJournalSize().matches(JOURNAL_REGEX_2)&& !sourcePolicy.getJournalSize().equals(JOURNAL_MIN)) {
throw APIException.badRequests.protectionVirtualPoolJournalSizeInvalid("source",sourcePolicy.getJournalSize());
}
}
if (sourcePolicy.getRemoteCopyMode() != null) {
if (VirtualPool.RPCopyMode.lookup(sourcePolicy.getRemoteCopyMode()) == null) {
throw APIException.badRequests.protectionVirtualPoolRemoteCopyModeInvalid(sourcePolicy.getRemoteCopyMode());
}
}
if (sourcePolicy.getRpoType() != null) {
if (VirtualPool.RPOType.lookup(sourcePolicy.getRpoType()) == null) {
throw APIException.badRequests.protectionVirtualPoolRPOTypeInvalid(sourcePolicy.getRpoType());
}
}
if (sourcePolicy.getRpoValue() != null && sourcePolicy.getRpoType() == null) {
throw APIException.badRequests.protectionVirtualPoolRPOTypeNotSpecified(sourcePolicy.getRpoValue());
}
if (sourcePolicy.getRpoValue() == null && sourcePolicy.getRpoType() != null) {
throw APIException.badRequests.protectionVirtualPoolRPOValueNotSpecified(sourcePolicy.getRpoType());
}
}
}
| Validates the source policy to ensure valid values are specified. |
@Override protected void onStopLoading(){
cancelLoad();
}
| Handles a request to stop the Loader. |
@SuppressWarnings("deprecation") protected void stopClusterer(){
if (m_RunThread != null) {
m_RunThread.interrupt();
m_RunThread.stop();
}
}
| Stops the currently running clusterer (if any). |
public boolean check(int number){
return set.contains(number);
}
| Check if a number is available or not. |
public ViewSourceAction(Application app,@Nullable View view){
super(app,view);
ResourceBundleUtil labels=ResourceBundleUtil.getBundle("org.jhotdraw.samples.svg.Labels");
labels.configureAction(this,ID);
}
| Creates a new instance. |
protected final void moveToNextIndex(){
if ((_index=nextIndex()) < 0) {
throw new NoSuchElementException();
}
}
| Sets the internal <tt>index</tt> so that the `next' object can be returned. |
@DSComment("Package priviledge") @DSBan(DSCat.DEFAULT_MODIFIER) @DSGenerator(tool_name="Doppelganger",tool_version="2.0",generated_on="2013-12-30 12:56:32.734 -0500",hash_original_method="6CD3D0843AA30F3B07C5B27C93AA8456",hash_generated_method="6CD3D0843AA30F3B07C5B27C93AA8456") Reference(){
}
| Constructs a new instance of this class. |
protected void addItemToSection(FormToolkit toolkit,String sectionTitle,String text,Image image,int minColumnWidth){
if (sections.containsKey(sectionTitle)) {
FormText formText=toolkit.createFormText(sections.get(sectionTitle),false);
if (image != null) {
formText.setText("<form><p><img href=\"img\"/> " + text + "</p></form>",true,false);
formText.setImage("img",image);
}
else {
formText.setText("<form><p>" + text + "</p></form>",true,false);
}
formText.setLayoutData(new GridData(minColumnWidth,SWT.DEFAULT));
}
}
| Adds an item to the specified section. |
public void removeToTag(){
parameters.delete(ParameterNames.TO_TAG);
}
| remove Tag member |
public void add(T t,String id,double percentX,double percentY,double percentWidth,double percentHeight){
surface.addRelative(id,t,percentX,percentY,percentWidth,percentHeight,0,Double.MAX_VALUE,0,Double.MAX_VALUE);
content.getChildren().add(t);
}
| Called to add an object to be laid out, to the layout engine applying the specified String id. |
public static Stats of(long... values){
StatsAccumulator acummulator=new StatsAccumulator();
acummulator.addAll(values);
return acummulator.snapshot();
}
| Returns statistics over a dataset containing the given values. |
public double compute(Collection<? extends Number> dataset){
return computeInPlace(Doubles.toArray(dataset));
}
| Computes the quantile value of the given dataset. |
public Rational(){
this(BigInteger.ZERO,BigInteger.ONE);
}
| Construct a ratinoal with default properties |
@Override public void run(){
try {
Thread.sleep(2000);
}
catch ( InterruptedException e) {
e.printStackTrace();
}
RefreshUIActivity.this.runOnUiThread(RefreshUIActivity.this.uiRunnable);
}
| Calls the <code>run()</code> method of the Runnable object the receiver holds. If no Runnable is set, does nothing. |
public void fsyncImpl(){
MappedByteBuffer mmap=_mmap;
try {
if (mmap != null && _isDirty.compareAndSet(true,false)) {
ArrayList<Result<Boolean>> resultList=new ArrayList<>(_resultList);
_resultList.clear();
mmap.force();
for ( Result<Boolean> result : resultList) {
try {
result.ok(Boolean.TRUE);
}
catch ( Throwable e) {
e.printStackTrace();
}
}
}
else {
ArrayList<Result<Boolean>> resultList=new ArrayList<>(_resultList);
_resultList.clear();
for ( Result<Boolean> result : resultList) {
try {
result.ok(Boolean.TRUE);
}
catch ( Throwable e) {
e.printStackTrace();
}
}
}
}
catch ( Throwable e) {
e.printStackTrace();
}
}
| Syncs the buffer to the disk. |
public AuthenticatorException(String msg,List<String> messages,Throwable nested){
super(msg,messages,nested);
}
| Constructs an <code>GeneralException</code> with the specified detail message, list and nested Exception. |
public static int encodeToUtf8(char[] chars,int nchars,byte[] bytes,int off){
char c;
int j=off;
for (int i=0; i < nchars; i++) {
if ((c=chars[i]) < 0x80) {
bytes[j++]=(byte)c;
}
else if (c < 0x800) {
bytes[j++]=(byte)(0xC0 | ((c >> 6) & 0x1f));
bytes[j++]=(byte)(0x80 | (c & 0x3f));
}
else {
bytes[j++]=(byte)(0xE0 | ((c >> 12) & 0x0f));
bytes[j++]=(byte)(0x80 | ((c >> 6) & 0x3f));
bytes[j++]=(byte)(0x80 | (c & 0x3f));
}
}
return j - off;
}
| Encode the given Java string as UTF-8 bytes, writing the result to bytes starting at offset. <p> The string should be measured first with lengthAsUtf8 to make sure the given byte array is large enough. |
public Boolean visitTypeArgs(final AnnotatedDeclaredType subtype,final AnnotatedDeclaredType supertype,final VisitHistory visited,final boolean subtypeRaw,final boolean supertypeRaw){
final boolean ignoreTypeArgs=ignoreRawTypes && (subtypeRaw || supertypeRaw);
if (!ignoreTypeArgs) {
final List<? extends AnnotatedTypeMirror> subtypeTypeArgs=subtype.getTypeArguments();
final List<? extends AnnotatedTypeMirror> supertypeTypeArgs=supertype.getTypeArguments();
if (subtypeTypeArgs.isEmpty() || supertypeTypeArgs.isEmpty()) {
return true;
}
if (supertypeTypeArgs.size() > 0) {
for (int i=0; i < supertypeTypeArgs.size(); i++) {
final AnnotatedTypeMirror superTypeArg=supertypeTypeArgs.get(i);
final AnnotatedTypeMirror subTypeArg=subtypeTypeArgs.get(i);
if (!compareTypeArgs(subTypeArg,superTypeArg,supertypeRaw,subtypeRaw,visited)) {
return false;
}
}
}
}
return true;
}
| A helper class for visitDeclared_Declared. There are subtypes of DefaultTypeHierarchy that need to customize the handling of type arguments. This method provides a convenient extension point. |
static public InputSource fileInputSource(File file){
return new InputSource(UriOrFile.fileToUri(file));
}
| Returns an <code>InputSource</code> for a <code>File</code>. |
public GeneralSecurityException(){
super();
}
| Constructs a GeneralSecurityException with no detail message. |
public void testNumberOfGeneratedTokens(){
String s;
String[] result;
s="HOWEVER, the egg only got larger and larger, and more and more human";
try {
result=Tokenizer.tokenize(m_Tokenizer,new String[]{s});
assertEquals("number of tokens differ",13,result.length);
}
catch ( Exception e) {
fail("Error tokenizing string '" + s + "'!");
}
}
| tests the number of generated tokens |
private int measureWidth(int measureSpec){
float result;
int specMode=MeasureSpec.getMode(measureSpec);
int specSize=MeasureSpec.getSize(measureSpec);
if ((specMode == MeasureSpec.EXACTLY) || (mViewPager == null)) {
result=specSize;
}
else {
final int count=mViewPager.getAdapter().getCount();
result=getPaddingLeft() + getPaddingRight() + (count * mLineWidth)+ ((count - 1) * mGapWidth);
if (specMode == MeasureSpec.AT_MOST) {
result=Math.min(result,specSize);
}
}
return (int)FloatMath.ceil(result);
}
| Determines the width of this view |
public static void modifyPhysicalBTHForAdvantages(Entity attacker,Entity target,ToHitData toHit,IGame game){
if (attacker.getCrew().getOptions().booleanOption("melee_specialist") && (attacker instanceof Mech)) {
toHit.addModifier(-1,"melee specialist");
}
if (attacker.getCrew().getOptions().booleanOption("clan_pilot_training")) {
toHit.addModifier(1,"clan pilot training");
}
if ((target != null) && (target instanceof Mech) && target.getCrew().getOptions().booleanOption("dodge_maneuver")&& (target.dodging)) {
toHit.addModifier(2,"target is dodging");
}
}
| Modifier to physical attack BTH due to pilot advantages |
public static DomainApplication persistDeletedDomainApplication(String domainName,DateTime deletionTime){
return persistResource(newDomainApplication(domainName).asBuilder().setDeletionTime(deletionTime).build());
}
| Persists a domain application resource with the given domain name deleted at the specified time. |
private Source generateMainSource(CompilationUnit unit,String packageName,String className,FXGSymbolClass asset) throws IOException {
Source originalSource=unit.getSource();
String generatedName=getGeneratedFileName(packageName,className,"-generated.as");
if (generatedOutputDir != null) {
new File(generatedName).getParentFile().mkdirs();
FileUtil.writeFile(generatedName,asset.getGeneratedSource());
}
TextFile generatedFile=new TextFile(asset.getGeneratedSource(),generatedName,originalSource.getParent(),MimeMappings.AS,originalSource.getLastModified());
AssetInfo assetInfo=new AssetInfo(asset.getSymbol(),generatedFile,originalSource.getLastModified(),null);
unit.getAssets().add(asset.getQualifiedClassName(),assetInfo);
Source generatedSource=new Source(generatedFile,originalSource);
generatedSource.setAssetInfo(assetInfo);
return generatedSource;
}
| Generates the concrete ActionScript implementation for our FXG symbol and associate the DefineSprite asset with the CompilationUnit. |
public void createBackup(String backupTag,boolean force){
checkOnStandby();
if (backupTag == null) {
backupTag=createBackupName();
}
else {
validateBackupName(backupTag);
}
precheckForCreation(backupTag);
InterProcessLock backupLock=null;
InterProcessLock recoveryLock=null;
try {
backupLock=getLock(BackupConstants.BACKUP_LOCK,BackupConstants.LOCK_TIMEOUT,TimeUnit.MILLISECONDS);
recoveryLock=getLock(RecoveryConstants.RECOVERY_LOCK,BackupConstants.LOCK_TIMEOUT,TimeUnit.MILLISECONDS);
createBackupWithoutLock(backupTag,force);
}
finally {
releaseLock(recoveryLock);
releaseLock(backupLock);
}
}
| Create backup file on all nodes |
private NettyChannelContext selectHttp2Context(Operation request,NettyChannelGroup group,String link){
NettyChannelContext context=null;
NettyChannelContext badContext=null;
int limit=this.getConnectionLimitPerTag(group.getKey().connectionTag);
synchronized (group) {
if (!group.inUseChannels.isEmpty()) {
int index=Math.abs(link.hashCode() % group.inUseChannels.size());
NettyChannelContext ctx=group.inUseChannels.get(index);
if (ctx.isValid()) {
context=ctx;
}
else {
LOGGER.info(ctx.getLargestStreamId() + ":" + group.getKey());
}
}
if (context != null) {
if (context.isOpenInProgress() || !group.pendingRequests.isEmpty()) {
group.pendingRequests.add(request);
return null;
}
}
int activeChannelCount=group.inUseChannels.size();
if (context != null && context.hasActiveStreams() && activeChannelCount < limit) {
context=null;
}
else if (context == null) {
for ( NettyChannelContext ctx : group.inUseChannels) {
if (ctx.isValid()) {
context=ctx;
break;
}
}
}
if (context != null && context.getChannel() != null && !context.getChannel().isOpen()) {
badContext=context;
context=null;
}
if (context == null) {
context=new NettyChannelContext(group.getKey(),NettyChannelContext.Protocol.HTTP2);
context.setOpenInProgress(true);
group.inUseChannels.add(context);
}
}
closeBadChannelContext(badContext);
context.updateLastUseTime();
return context;
}
| Normally there is only one HTTP/2 context per host/port, unlike HTTP/1, which can have lots (we default to 128). However, when we exhaust the number of streams available to a connection, we have to switch to a new connection: that's why we have a list of contexts. We'll clean up the exhausted connection once it has no pending connections. That happens in handleMaintenance(). Note that this returns null if a HTTP/2 context isn't available. This happens when the channel is already being opened. The caller will queue the request to be sent after the connection is open. |
@AfterClass public static void tearDownAfterClass() throws Exception {
}
| Method tearDownAfterClass. |
public static boolean parseInterpolatedConstructs(PsiBuilder b,int l){
assert b instanceof PerlBuilder;
if (((PerlBuilder)b).isUseVarsContent()) {
PsiBuilder.Marker m=b.mark();
boolean r=PerlParserImpl.use_vars_interpolated_constructs(b,l);
if (r) {
LighterASTNode lastMarker=b.getLatestDoneMarker();
if (lastMarker != null) {
IElementType elementType=lastMarker.getTokenType();
if (elementType == SCALAR_VARIABLE || elementType == ARRAY_VARIABLE || elementType == HASH_VARIABLE) {
m.done(VARIABLE_DECLARATION_WRAPPER);
return true;
}
}
}
m.drop();
return r;
}
else {
return PerlParserImpl.interpolated_constructs(b,l);
}
}
| Hack for use vars parameter |
public static void validate(TechnicalProduct techProduct,String oldLicenseText,String newLicenseText){
if (techProduct == null) {
return;
}
if (oldLicenseText == null) {
return;
}
if (equalsContent(oldLicenseText,newLicenseText)) {
return;
}
if (oldLicenseText.equals(newLicenseText)) {
return;
}
}
| Checks that no "usable" subscription exists for a technical product if the oldLiceseText and the newLicenseText are not equal. If the old License is <code>null</code>, no license has been set for the current user's locale and an update is possible. Hence this will not cause an exception. |
public ByteArray(){
this(32);
}
| Creates a new byte array output stream. The buffer capacity is initially 32 bytes, though its size increases if necessary. |
public void paintTreeCellBackground(SynthContext context,Graphics g,int x,int y,int w,int h){
paintBackground(context,g,x,y,w,h,null);
}
| Paints the background of the row containing a cell in a tree. |
@Override public boolean isActive(){
return amIActive;
}
| Used by the Whitebox GUI to tell if this plugin is still running. |
protected void initializeWorld(){
this.world.setGravity(World.ZERO_GRAVITY);
SimulationBody circle=new SimulationBody();
circle.addFixture(Geometry.createCircle(0.5));
circle.setMass(MassType.NORMAL);
circle.translate(2.0,2.0);
circle.applyForce(new Vector2(-100.0,0.0));
circle.setLinearDamping(0.05);
this.world.addBody(circle);
SimulationBody rectangle=new SimulationBody();
rectangle.addFixture(Geometry.createRectangle(1,1));
rectangle.setMass(MassType.NORMAL);
rectangle.translate(0.0,2.0);
this.world.addBody(rectangle);
this.world.addListener(new StopContactListener(circle,rectangle));
}
| Creates game objects and adds them to the world. |
public static void assumeFalse(BooleanSupplier assumptionSupplier) throws TestAbortedException {
assumeFalse(assumptionSupplier,null);
}
| Validate the given assumption. |
public static List<RepositoryLocation> removeIntersectedLocations(List<RepositoryLocation> repositoryLocations){
List<RepositoryLocation> locations=new LinkedList<>(repositoryLocations);
try {
Set<RepositoryLocation> removeSet=new HashSet<>();
for ( RepositoryLocation locationA : locations) {
for ( RepositoryLocation locationB : locations) {
if (!locationA.equals(locationB) && locationA.getRepository().equals(locationB.getRepository())) {
String pathA=locationA.getPath();
String pathB=locationB.getPath();
if (pathA.startsWith(pathB) && pathA.substring(pathB.length(),pathB.length() + 1).equals(String.valueOf(SEPARATOR))) {
removeSet.add(locationA);
}
}
}
}
locations.removeAll(removeSet);
}
catch ( RepositoryException e) {
return repositoryLocations;
}
return locations;
}
| Removes locations from list, which are already included in others. If there are any problems requesting a repository, the input is returned. Example: [/1/2/3, /1, /1/2] becomes [/1] |
protected void SSE2_NCOP(Operator operator,Instruction s,Operand result,Operand val1,Operand val2){
if (VM.VerifyAssertions) opt_assert(result.isRegister());
if (result.similar(val1)) {
EMIT(MIR_BinaryAcc.mutate(s,operator,result,val2));
}
else if (!result.similar(val2)) {
EMIT(CPOS(s,MIR_Move.create(SSE2_MOVE(result),result.copy(),val1)));
EMIT(MIR_BinaryAcc.mutate(s,operator,result,val2));
}
else {
RegisterOperand temp=regpool.makeTemp(result);
EMIT(CPOS(s,MIR_Move.create(SSE2_MOVE(result),temp,val1)));
EMIT(MIR_BinaryAcc.mutate(s,operator,temp.copyRO(),val2));
EMIT(CPOS(s,MIR_Move.create(SSE2_MOVE(result),result,temp.copyRO())));
}
}
| BURS expansion of a non commutative SSE2 operation. |
public static Map<StreamKind,List<Map<String,String>>> snapshot(Path file) throws IOException {
MediaInfo mi=new MediaInfo();
try {
if (mi.open(file)) {
return mi.snapshot();
}
else {
throw new IOException("Failed to open file: " + file);
}
}
finally {
mi.close();
}
}
| Helper for easy usage. |
public static int countNonzeroPairs(final long x){
return Long.bitCount((x | x >>> 1) & 0x5555555555555555L);
}
| Counts the number of nonzero pairs of bits in a long. |
public void onDestroy(){
mBackgroundExecution.cancel(true);
return;
}
| Called when the service is destroyed. |
public static void f(String tag,String msg,Object... args){
if (sLevel > LEVEL_FATAL) {
return;
}
if (args.length > 0) {
msg=String.format(msg,args);
}
Log.wtf(tag,msg);
}
| Send a FATAL ERROR log message |
private void readObject(ObjectInputStream s) throws InvalidObjectException {
throw new InvalidObjectException("Deserialization via serialization delegate");
}
| Defend against malicious streams. |
private void processUsers(LocalContainer container,File configOverrides) throws IOException {
List<User> userList=getUsers();
if (userList != null) {
Map<String,List<String>> groups=new HashMap<String,List<String>>();
Map<String,String> users=new HashMap<String,String>();
for ( User u : userList) {
users.put(u.getName(),u.getPassword());
for ( String group : u.getRoles()) {
List<String> members=groups.get(group);
if (members == null) {
members=new ArrayList<String>();
groups.put(group,members);
}
members.add(u.getName());
}
}
writeUserRegistry(container,configOverrides,users,groups);
}
}
| Processes the users property and writes the server xml |
@DSComment("Package priviledge") @DSBan(DSCat.DEFAULT_MODIFIER) @DSGenerator(tool_name="Doppelganger",tool_version="2.0",generated_on="2013-12-30 12:59:01.393 -0500",hash_original_method="574EFAE567BAC054324E4789AB0ACA21",hash_generated_method="1670645142CBE11F3C7719961E4505B3") void onMMIDone(CdmaMmiCode mmi){
if (mPendingMmis.remove(mmi)) {
mMmiCompleteRegistrants.notifyRegistrants(new AsyncResult(null,mmi,null));
}
}
| Removes the given MMI from the pending list and notifies registrants that it is complete. |
public static void silence(){
System.setOut(nullout);
}
| Mutes stdout |
public static void main(String args[]){
long n=Long.parseLong(args[0]);
long N=Long.parseLong(args[1]);
long low=Long.parseLong(args[2]);
int chunkSize=Integer.parseInt(args[3]);
int times=Integer.parseInt(args[4]);
test(n,N,low,chunkSize,times);
}
| Tests this class. |
public void subtract(final Number operand){
this.value-=operand.intValue();
}
| Subtracts a value from the value of this instance. |
private double adjustTransform(){
double xMin=Double.POSITIVE_INFINITY;
double xMax=Double.NEGATIVE_INFINITY;
double yMin=Double.POSITIVE_INFINITY;
double yMax=Double.NEGATIVE_INFINITY;
for ( Variable var : csp.getVariables()) {
Point2D point=getPosition(var);
xMin=Math.min(xMin,point.getX());
xMax=Math.max(xMax,point.getX());
yMin=Math.min(yMin,point.getY());
yMax=Math.max(yMax,point.getY());
}
double scale=Math.min(pane.getWidth() / (xMax - xMin + 300),pane.getHeight() / (yMax - yMin + 150));
pane.setTranslateX((scale * (pane.getWidth() - xMin - xMax) / 2.0));
pane.setTranslateY((scale * (pane.getHeight() - yMin - yMax) / 2.0));
pane.setScaleX(scale);
pane.setScaleY(scale);
return scale;
}
| Computes transforms (translations and scaling) and applies them to the environment state view. Those transforms map logical positions to screen positions in the viewer pane. The purpose is to show the graphical state representation as large as possible. |
public Object jjtAccept(SyntaxTreeBuilderVisitor visitor,Object data) throws VisitorException {
return visitor.visit(this,data);
}
| Accept the visitor. |
public Address minus(int v){
return null;
}
| Subtract an integer from this <code>Address</code>, and return the result. |
public void visitTypeVariable(String name){
}
| Visits a signature corresponding to a type variable. |
public boolean hideCard(String tag){
final Card card=mVisibleCards.get(tag);
if (card != null) {
mVisibleCards.remove(tag);
mDismissibleCards.remove(tag);
mHiddenCards.put(tag,card);
mLayout.removeView(card.getView());
return true;
}
return mHiddenCards.containsValue(tag);
}
| Hides the card, returns false if the card could not be hidden. |
public final void yyreset(java.io.Reader reader){
zzReader=reader;
zzAtBOL=true;
zzAtEOF=false;
zzEndRead=zzStartRead=0;
zzCurrentPos=zzMarkedPos=zzPushbackPos=0;
yyline=yychar=yycolumn=0;
zzLexicalState=YYINITIAL;
}
| 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>ZZ_INITIAL</tt>. |
public boolean clean(){
try {
FileUtils.deleteDirectory(new File(Properties.CTG_DIR));
}
catch ( IOException e) {
logger.error("Cannot delete folder " + Properties.CTG_DIR + ": "+ e,e);
return false;
}
return true;
}
| Delete all CTG files |
public Properties loadProperties(String resourceName,String subDir){
Properties result=new Properties();
Resource resource=this.loadResource(resourceName,subDir);
try {
result.load(resource.getInputStream());
}
catch ( IOException e) {
String message=e.getLocalizedMessage();
message="Error cargando properties:" + subDir + File.separator+ resourceName+ "--- "+ message;
logger.error(message);
throw new RuntimeException(message);
}
return result;
}
| Metodo que carga un recurso de properties de configuracion externalizado |
private String createKey(UIComponent table){
return TableColumnCache.KEY + '_' + table.hashCode();
}
| Creates a unique key based on the provided <code>UIComponent</code> with which the TableColumnCache can be looked up. |
public void add(DurationFieldType field,int value){
super.addField(field,value);
}
| Adds to the value of one of the fields. <p> The field type specified must be one of those that is supported by the period. |
public void visitEnum(String name,String desc,String value){
if (av != null) {
av.visitEnum(name,desc,value);
}
}
| Visits an enumeration value of the annotation. |
private void updateProgress(String progressLabel,int progress){
if (myHost != null && ((progress != previousProgress) || (!progressLabel.equals(previousProgressLabel)))) {
myHost.updateProgress(progressLabel,progress);
}
previousProgress=progress;
previousProgressLabel=progressLabel;
}
| Used to communicate a progress update between a plugin tool and the main Whitebox user interface. |
public String prepareIt(){
log.info(toString());
m_processMsg=ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_PREPARE);
if (m_processMsg != null) return DocAction.STATUS_Invalid;
MPeriod.testPeriodOpen(getCtx(),getDateAcct(),getC_DocTypeTarget_ID(),getAD_Org_ID());
MInvoiceLine[] lines=getLines(true);
if (lines.length == 0) {
m_processMsg="@NoLines@";
return DocAction.STATUS_Invalid;
}
if (PAYMENTRULE_Cash.equals(getPaymentRule()) && MCashBook.get(getCtx(),getAD_Org_ID(),getC_Currency_ID()) == null) {
m_processMsg="@NoCashBook@";
return DocAction.STATUS_Invalid;
}
if (getC_DocType_ID() != getC_DocTypeTarget_ID()) setC_DocType_ID(getC_DocTypeTarget_ID());
if (getC_DocType_ID() == 0) {
m_processMsg="No Document Type";
return DocAction.STATUS_Invalid;
}
explodeBOM();
if (!calculateTaxTotal()) {
m_processMsg="Error calculating Tax";
return DocAction.STATUS_Invalid;
}
createPaySchedule();
if (isSOTrx() && !isReversal()) {
MBPartner bp=new MBPartner(getCtx(),getC_BPartner_ID(),null);
if (MBPartner.SOCREDITSTATUS_CreditStop.equals(bp.getSOCreditStatus())) {
m_processMsg="@BPartnerCreditStop@ - @TotalOpenBalance@=" + bp.getTotalOpenBalance() + ", @SO_CreditLimit@="+ bp.getSO_CreditLimit();
return DocAction.STATUS_Invalid;
}
}
if (!isSOTrx()) {
for (int i=0; i < lines.length; i++) {
MInvoiceLine line=lines[i];
String error=line.allocateLandedCosts();
if (error != null && error.length() > 0) {
m_processMsg=error;
return DocAction.STATUS_Invalid;
}
}
}
m_processMsg=ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_PREPARE);
if (m_processMsg != null) return DocAction.STATUS_Invalid;
m_justPrepared=true;
if (!DOCACTION_Complete.equals(getDocAction())) setDocAction(DOCACTION_Complete);
return DocAction.STATUS_InProgress;
}
| Prepare Document |
public void removeWallet(Wallet wallet){
wallets.remove(checkNotNull(wallet));
peerFilterProviders.remove(wallet);
wallet.removeCoinsReceivedEventListener(walletCoinsReceivedEventListener);
wallet.removeKeyChainEventListener(walletKeyEventListener);
wallet.removeScriptChangeEventListener(walletScriptEventListener);
wallet.setTransactionBroadcaster(null);
for ( Peer peer : peers) {
peer.removeWallet(wallet);
}
}
| Unlinks the given wallet so it no longer receives broadcast transactions or has its transactions announced. |
public TemplateBuffer updateBuffer() throws MalformedTreeException, BadLocationException {
checkState();
TemplateVariable[] variables=fBuffer.getVariables();
try {
removeRangeMarkers(fPositions,fDocument,variables);
}
catch ( BadPositionCategoryException x) {
Assert.isTrue(false);
}
fBuffer.setContent(fDocument.get(),variables);
fDocument=null;
return fBuffer;
}
| Restores any decorated regions and updates the buffer's variable offsets. |
public MyComparableObjectSeries(Comparable key,boolean autoSort,boolean allowDuplicateXValues){
super(key,autoSort,allowDuplicateXValues);
}
| Creates a new instance. |
@DSComment("Private Method") @DSBan(DSCat.PRIVATE_METHOD) @DSGenerator(tool_name="Doppelganger",tool_version="2.0",generated_on="2013-12-30 12:33:46.132 -0500",hash_original_method="AE2AC52C1B086D07AB414F4634EAA37E",hash_generated_method="DA3324DED8188362CBB4DD2028BC1249") private Data(){
}
| This utility class cannot be instantiated |
public static boolean equals(long[] array1,long[] 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++) {
if (array1[i] != array2[i]) {
return false;
}
}
return true;
}
| Compares the two arrays. |
public MBeanOperationInfo(String name,String description,MBeanParameterInfo[] signature,String type,int impact){
this(name,description,signature,type,impact,(Descriptor)null);
}
| Constructs an <CODE>MBeanOperationInfo</CODE> object. |
public boolean isProcessing(){
Object oo=get_Value(COLUMNNAME_Processing);
if (oo != null) {
if (oo instanceof Boolean) return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
}
| Get Process Now. |
@Override protected Bitmap decodeJPEGByteArrayAsPurgeable(CloseableReference<PooledByteBuffer> bytesRef,int length,BitmapFactory.Options options){
byte[] suffix=endsWithEOI(bytesRef,length) ? null : EOI;
final PooledByteBuffer pooledByteBuffer=bytesRef.get();
Preconditions.checkArgument(length <= pooledByteBuffer.size());
final CloseableReference<byte[]> encodedBytesArrayRef=mFlexByteArrayPool.get(length + 2);
try {
byte[] encodedBytesArray=encodedBytesArrayRef.get();
pooledByteBuffer.read(0,encodedBytesArray,0,length);
if (suffix != null) {
putEOI(encodedBytesArray,length);
length+=2;
}
Bitmap bitmap=BitmapFactory.decodeByteArray(encodedBytesArray,0,length,options);
return Preconditions.checkNotNull(bitmap,"BitmapFactory returned null");
}
finally {
CloseableReference.closeSafely(encodedBytesArrayRef);
}
}
| Decodes a byteArray containing jpeg encoded bytes into a purgeable bitmap <p> Adds a JFIF End-Of-Image marker if needed before decoding. |
private void createFieldAnnotation(CAS cas,String nodeTag,int begin,int end){
JCas jcas=null;
try {
jcas=cas.getJCas();
}
catch ( CASException e) {
throw new RuntimeException(e);
}
Field field=new Field(jcas,begin,end);
field.setName(nodeTag);
field.addToIndexes();
}
| Create and add to index a Field annotation with the given data |
public static void dropAllTables(SQLiteDatabase db,boolean ifExists){
UserDao.dropTable(db,ifExists);
}
| Drops underlying database table using DAOs. |
boolean isInternalURL(String serviceAccessURL){
if (serviceAccessURL == null || serviceAccessURL.length() == 0) {
return false;
}
return isMatch(serviceAccessURL,getApplicationBean().getServerBaseUrl()) || isMatch(serviceAccessURL,getApplicationBean().getServerBaseUrlHttps());
}
| Check if the given URL is external URL. External URL's are all URL which do not contain the BES-Base-URL |
public NetworkTopologyEventImpl(JmDNS jmDNS,InetAddress inetAddress){
super(jmDNS);
this._inetAddress=inetAddress;
}
| Constructs a Network Topology Event. |
public boolean roundXYToGrid(int index){
return ((getFlag(index) & ROUND_XY_TO_GRID) != 0);
}
| Determine whether to round XY values to the grid |
public Trie buildTrie(String[] data){
Trie result;
int i;
result=new Trie();
for (i=0; i < data.length; i++) result.add(data[i]);
return result;
}
| builds a new trie from the given data and returns it |
public void paint(java.awt.Graphics g){
if (Debug.debugging("location")) {
Debug.output(getName() + "|LocationLayer.paint()");
}
OMGraphicList omgList=getList();
if (omgList != null) {
for ( OMGraphic omg : omgList) {
if (omg instanceof Location) {
((Location)omg).renderLocation(g);
}
else {
omg.render(g);
}
}
for ( OMGraphic omg : omgList) {
if (omg instanceof Location) {
((Location)omg).renderName(g);
}
}
}
else {
if (Debug.debugging("location")) {
Debug.error(getName() + "|LocationLayer: paint(): Null list...");
}
}
}
| Paints the layer. |
public Object runSafely(Catbert.FastStack stack) throws Exception {
CaptureDevice capDev=getCapDev(stack);
return capDev == null ? null : capDev.getEncodingQualities();
}
| Returns the recording qualities which are supported by this CaptureDevice |
@Override public int hashCode(){
return key == null ? 0 : key.hashCode();
}
| Returns a hash code value for the object. |
public static void enableTraceCalls(){
traceCalls=true;
}
| <p> enableTraceCalls </p> |
public void hideWindow(){
doHide();
}
| Hides the window slowly using an animation. |
public void encode(DerOutputStream out) throws IOException {
DerOutputStream seq=new DerOutputStream();
for (int i=0, n=size(); i < n; i++) {
get(i).encode(seq);
}
out.write(DerValue.tag_Sequence,seq);
}
| Encode the GeneralSubtrees. |
public void encoding(String charset){
setEncoding(charset);
}
| Sets encoding to use (defaults to UTF_8). |
public void log(String tag,String message){
Log.d(tag,message);
}
| Send a debug log message |
public void resetStats(){
if (lock.tryLock()) {
try {
ensureInitialized();
updateStats();
}
finally {
lock.unlock();
}
}
}
| Thread-safe call to reset the disk stats. If we know that the free space has changed recently (for example, if we have deleted files), use this method to reset the internal state and start tracking disk stats afresh, resetting the internal timer for updating stats. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.