code
stringlengths 10
174k
| nl
stringlengths 3
129k
|
---|---|
protected void tearDown(){
}
| Tears down the fixture, for example, close a network connection. This method is called after a test is executed. |
@KnownFailure("Fixed on DonutBurger, Wrong Exception thrown") public void test_unwrap_ByteBuffer$ByteBuffer_02(){
String host="new host";
int port=8080;
ByteBuffer bbs=ByteBuffer.allocate(10);
ByteBuffer bbR=ByteBuffer.allocate(100).asReadOnlyBuffer();
ByteBuffer[] bbA={bbR,ByteBuffer.allocate(10),ByteBuffer.allocate(100)};
SSLEngine sse=getEngine(host,port);
sse.setUseClientMode(true);
try {
sse.unwrap(bbs,bbA);
fail("ReadOnlyBufferException wasn't thrown");
}
catch ( ReadOnlyBufferException iobe) {
}
catch ( Exception e) {
fail(e + " was thrown instead of ReadOnlyBufferException");
}
}
| javax.net.ssl.SSLEngine#unwrap(ByteBuffer src, ByteBuffer[] dsts) ReadOnlyBufferException should be thrown. |
public static CstFloat make(int bits){
return new CstFloat(bits);
}
| Makes an instance for the given value. This may (but does not necessarily) return an already-allocated instance. |
public long size(){
long size=0;
if (parsedGeneExpressions == null) parseGenes();
for (int i=0; i < parsedGeneExpressions.length; i++) size+=parsedGeneExpressions[i].numberOfNodes();
return size;
}
| Returns the "size" of the chromosome, namely, the number of nodes in all of its parsed genes -- does not include the linking functions. |
public void increment(View view){
if (quantity == 100) {
return;
}
quantity=quantity + 1;
displayQuantity(quantity);
}
| This method is called when the plus button is clicked. |
public void trimToSize(){
++modCount;
if (size < elementData.length) {
elementData=Arrays.copyOf(elementData,size);
}
}
| Trims the capacity of this <tt>ArrayHashList</tt> instance to be the list's current size. An application can use this operation to minimize the storage of an <tt>ArrayHashList</tt> instance. |
public SyncValueResponseMessage(SyncValueResponseMessage other){
__isset_bitfield=other.__isset_bitfield;
if (other.isSetHeader()) {
this.header=new AsyncMessageHeader(other.header);
}
this.count=other.count;
}
| Performs a deep copy on <i>other</i>. |
public void clearParsers(){
if (parserManager != null) {
parserManager.clearParsers();
}
}
| Removes all parsers from this text area. |
@Override public void run(){
while (doWork) {
deliverLock();
while (tomLayer.isRetrievingState()) {
System.out.println("-- Retrieving State");
canDeliver.awaitUninterruptibly();
if (tomLayer.getLastExec() == -1) System.out.println("-- Ready to process operations");
}
try {
ArrayList<Decision> decisions=new ArrayList<Decision>();
decidedLock.lock();
if (decided.isEmpty()) {
notEmptyQueue.await();
}
decided.drainTo(decisions);
decidedLock.unlock();
if (!doWork) break;
if (decisions.size() > 0) {
TOMMessage[][] requests=new TOMMessage[decisions.size()][];
int[] consensusIds=new int[requests.length];
int[] leadersIds=new int[requests.length];
int[] regenciesIds=new int[requests.length];
CertifiedDecision[] cDecs;
cDecs=new CertifiedDecision[requests.length];
int count=0;
for ( Decision d : decisions) {
requests[count]=extractMessagesFromDecision(d);
consensusIds[count]=d.getConsensusId();
leadersIds[count]=d.getLeader();
regenciesIds[count]=d.getRegency();
CertifiedDecision cDec=new CertifiedDecision(this.controller.getStaticConf().getProcessId(),d.getConsensusId(),d.getValue(),d.getDecisionEpoch().proof);
cDecs[count]=cDec;
if (requests[count][0].equals(d.firstMessageProposed)) {
long time=requests[count][0].timestamp;
long seed=requests[count][0].seed;
int numOfNonces=requests[count][0].numOfNonces;
requests[count][0]=d.firstMessageProposed;
requests[count][0].timestamp=time;
requests[count][0].seed=seed;
requests[count][0].numOfNonces=numOfNonces;
}
count++;
}
Decision lastDecision=decisions.get(decisions.size() - 1);
if (requests != null && requests.length > 0) {
deliverMessages(consensusIds,regenciesIds,leadersIds,cDecs,requests);
if (controller.hasUpdates()) {
processReconfigMessages(lastDecision.getConsensusId());
tomLayer.setLastExec(lastDecision.getConsensusId());
tomLayer.setInExec(-1);
}
}
int cid=lastDecision.getConsensusId();
if (cid > 2) {
int stableConsensus=cid - 3;
tomLayer.execManager.removeConsensus(stableConsensus);
}
}
}
catch ( Exception e) {
e.printStackTrace(System.err);
}
deliverUnlock();
}
java.util.logging.Logger.getLogger(DeliveryThread.class.getName()).log(Level.INFO,"DeliveryThread stopped.");
}
| This is the code for the thread. It delivers decisions to the TOM request receiver object (which is the application) |
private byte[] calculateUValue(byte[] generalKey,byte[] firstDocIdValue,int revision) throws GeneralSecurityException, EncryptionUnsupportedByProductException {
if (revision == 2) {
Cipher rc4=createRC4Cipher();
SecretKey key=createRC4Key(generalKey);
initEncryption(rc4,key);
return crypt(rc4,PW_PADDING);
}
else if (revision >= 3) {
MessageDigest md5=createMD5Digest();
md5.update(PW_PADDING);
if (firstDocIdValue != null) {
md5.update(firstDocIdValue);
}
final byte[] hash=md5.digest();
Cipher rc4=createRC4Cipher();
SecretKey key=createRC4Key(generalKey);
initEncryption(rc4,key);
final byte[] v=crypt(rc4,hash);
rc4shuffle(v,generalKey,rc4);
assert v.length == 16;
final byte[] entryValue=new byte[32];
System.arraycopy(v,0,entryValue,0,v.length);
System.arraycopy(v,0,entryValue,16,v.length);
return entryValue;
}
else {
throw new EncryptionUnsupportedByProductException("Unsupported standard security handler revision " + revision);
}
}
| Calculate what the U value should consist of given a particular key and document configuration. Correponds to Algorithms 3.4 and 3.5 of the PDF Reference version 1.7 |
private void assign(HashMap<String,DBIDs> labelMap,String label,DBIDRef id){
if (labelMap.containsKey(label)) {
DBIDs exist=labelMap.get(label);
if (exist instanceof DBID) {
ModifiableDBIDs n=DBIDUtil.newHashSet();
n.add((DBID)exist);
n.add(id);
labelMap.put(label,n);
}
else {
assert (exist instanceof HashSetModifiableDBIDs);
assert (exist.size() > 1);
((ModifiableDBIDs)exist).add(id);
}
}
else {
labelMap.put(label,DBIDUtil.deref(id));
}
}
| Assigns the specified id to the labelMap according to its label |
private void showFeedback(String message){
if (myHost != null) {
myHost.showFeedback(message);
}
else {
System.out.println(message);
}
}
| Used to communicate feedback pop-up messages between a plugin tool and the main Whitebox user-interface. |
public CDeleteAction(final BackEndDebuggerProvider debuggerProvider,final int[] rows){
super(rows.length == 1 ? "Remove Breakpoint" : "Remove Breakpoints");
m_debuggerProvider=Preconditions.checkNotNull(debuggerProvider,"IE01344: Debugger provider argument can not be null");
m_rows=rows.clone();
}
| Creates a new action object. |
public Yaml(BaseConstructor constructor,Representer representer,DumperOptions dumperOptions,Resolver resolver){
if (!constructor.isExplicitPropertyUtils()) {
constructor.setPropertyUtils(representer.getPropertyUtils());
}
else if (!representer.isExplicitPropertyUtils()) {
representer.setPropertyUtils(constructor.getPropertyUtils());
}
this.constructor=constructor;
representer.setDefaultFlowStyle(dumperOptions.getDefaultFlowStyle());
representer.setDefaultScalarStyle(dumperOptions.getDefaultScalarStyle());
representer.getPropertyUtils().setAllowReadOnlyProperties(dumperOptions.isAllowReadOnlyProperties());
representer.setTimeZone(dumperOptions.getTimeZone());
this.representer=representer;
this.dumperOptions=dumperOptions;
this.resolver=resolver;
this.name="Yaml:" + System.identityHashCode(this);
}
| Create Yaml instance. It is safe to create a few instances and use them in different Threads. |
public void testHitEndAfterFind(){
hitEndTest(true,"#01.0","r((ege)|(geg))x","regexx",false);
hitEndTest(true,"#01.1","r((ege)|(geg))x","regex",false);
hitEndTest(true,"#01.2","r((ege)|(geg))x","rege",true);
hitEndTest(true,"#01.2","r((ege)|(geg))x","xregexx",false);
hitEndTest(true,"#02.0","regex","rexreger",true);
hitEndTest(true,"#02.1","regex","raxregexr",false);
String floatRegex=getHexFloatRegex();
hitEndTest(true,"#03.0",floatRegex,Double.toHexString(-1.234d),true);
hitEndTest(true,"#03.1",floatRegex,"1 ABC" + Double.toHexString(Double.NaN) + "buhuhu",false);
hitEndTest(true,"#03.2",floatRegex,Double.toHexString(-0.0) + "--",false);
hitEndTest(true,"#03.3",floatRegex,"--" + Double.toHexString(Double.MIN_VALUE) + "--",false);
hitEndTest(true,"#04.0","(\\d+) fish (\\d+) fish (\\w+) fish (\\d+)","1 fish 2 fish red fish 5",true);
hitEndTest(true,"#04.1","(\\d+) fish (\\d+) fish (\\w+) fish (\\d+)","----1 fish 2 fish red fish 5----",false);
}
| Regression test for HARMONY-4396 |
public void add(Individual individual){
individuals.add(individual);
}
| Adds a single individual. |
public boolean removeSession(IgniteUuid sesId){
GridTaskSessionImpl ses=sesMap.get(sesId);
assert ses == null || ses.isFullSupport();
if (ses != null && ses.release()) {
sesMap.remove(sesId,ses);
return true;
}
return false;
}
| Removes session for a given session ID. |
public static Bitmap loadBitmapOptimized(Uri uri,Context context,int limit) throws ImageLoadException {
return loadBitmapOptimized(new UriSource(uri,context){
}
,limit);
}
| Loading bitmap with optimized loaded size less than specific pixels count |
protected BasePeriod(long duration){
super();
iType=PeriodType.standard();
int[] values=ISOChronology.getInstanceUTC().get(DUMMY_PERIOD,duration);
iValues=new int[8];
System.arraycopy(values,0,iValues,4,4);
}
| Creates a period from the given millisecond duration with the standard period type and ISO rules, ensuring that the calculation is performed with the time-only period type. <p> The calculation uses the hour, minute, second and millisecond fields. |
public FlatBufferBuilder(){
this(1024);
}
| Start with a buffer of 1KiB, then grow as required. |
public PbrpcConnectionException(String arg0,Throwable arg1){
super(arg0,arg1);
}
| Creates a new instance of PbrpcConnectionException. |
public void uninstallUI(JComponent a){
for (int i=0; i < uis.size(); i++) {
((ComponentUI)(uis.elementAt(i))).uninstallUI(a);
}
}
| Invokes the <code>uninstallUI</code> method on each UI handled by this object. |
public static void shutdown(){
if (instance != null) {
instance.save();
}
}
| Saves the configuration file. |
public boolean GE(Word w2){
return value.GE(w2.value);
}
| Greater-than or equal comparison |
public static UnionCoder of(List<Coder<?>> elementCoders){
return new UnionCoder(elementCoders);
}
| Builds a union coder with the given list of element coders. This list corresponds to a mapping of union tag to Coder. Union tags start at 0. |
public void testFileDeletion() throws Exception {
File testDir=createTestDir("testFileDeletion");
String prefix1="testFileDeletion1";
File[] files1=createFiles(testDir,prefix1,5);
String prefix2="testFileDeletion2";
File[] files2=createFiles(testDir,prefix2,5);
FileCommands.deleteFiles(files1,true);
assertNotExists(files1);
FileCommands.deleteFiles(files2,false);
Thread.sleep(1000);
assertNotExists(files2);
}
| Verify ability to delete a list of files. |
public boolean isOnClasspath(String classpath){
return this.classpath.equals(classpath);
}
| Evaluates if the Dependency is targeted for a classpath type. |
protected void source(String ceylon){
String providerPreSrc="provider/" + ceylon + "_pre.ceylon";
String providerPostSrc="provider/" + ceylon + "_post.ceylon";
String clientSrc="client/" + ceylon + "_client.ceylon";
compile(providerPreSrc,providerModuleSrc,providerPackageSrc);
compile(clientSrc,clientModuleSrc);
compile(providerPostSrc,providerModuleSrc,providerPackageSrc);
compile(clientSrc,clientModuleSrc);
}
| Checks that we can still compile a client after a change |
public PerformanceMonitor(){
initComponents();
if (Display.getInstance().getCurrent() != null) {
refreshFrameActionPerformed(null);
}
resultData.setModel(new Model());
performanceLog.setLineWrap(true);
resultData.setRowSorter(new TableRowSorter<Model>((Model)resultData.getModel()));
}
| Creates new form PerformanceMonitor |
@DSGenerator(tool_name="Doppelganger",tool_version="2.0",generated_on="2014-09-03 15:01:15.190 -0400",hash_original_method="F262A3A18BABECF7EC492736953EAF6E",hash_generated_method="94A4545C167C029CC38AACEACF2087E9") private void unparkSuccessor(Node node){
int ws=node.waitStatus;
if (ws < 0) compareAndSetWaitStatus(node,ws,0);
Node s=node.next;
if (s == null || s.waitStatus > 0) {
s=null;
for (Node t=tail; t != null && t != node; t=t.prev) if (t.waitStatus <= 0) s=t;
}
if (s != null) LockSupport.unpark(s.thread);
}
| Wakes up node's successor, if one exists. |
@DSComment("From safe class list") @DSSafe(DSCat.SAFE_LIST) @DSGenerator(tool_name="Doppelganger",tool_version="2.0",generated_on="2013-12-30 13:02:44.364 -0500",hash_original_method="EA3734ADDEB20313C9CAB09B48812C54",hash_generated_method="4858AFE909DDE63867ACB561D5449C13") static public void assertFalse(String message,boolean condition){
assertTrue(message,!condition);
}
| Asserts that a condition is false. If it isn't it throws an AssertionFailedError with the given message. |
@Override protected void initData(){
Intent intent=new Intent(this,PushMessageService.class);
this.startService(intent);
this.bindService(intent,this.connection,Context.BIND_AUTO_CREATE);
}
| Initialize the Activity data |
public static Date parseDateDay(String dateString) throws ParseException {
return getSimplDateFormat(DF_DEF).parse(dateString);
}
| Returns date parsed from string in format: yyyy.MM.dd. |
private boolean doesStoragePortExistsInVArray(StoragePort umfsStoragePort,VirtualArray virtualArray){
List<URI> virtualArrayPorts=returnAllPortsInVArray(virtualArray.getId());
if (virtualArrayPorts.contains(umfsStoragePort.getId())) {
return true;
}
return false;
}
| Checks if the given storage port is part of VArray |
public SpringVaadinServletService(VaadinServlet servlet,DeploymentConfiguration deploymentConfiguration,String serviceUrl) throws ServiceException {
super(servlet,deploymentConfiguration);
this.serviceUrl=serviceUrl;
}
| Create a servlet service instance that allows the use of a custom service URL. |
private static List<TranslationResult> translateChildrenOfNode(final ITranslationEnvironment environment,final IOperandTreeNode expression,OperandSize size,final boolean loadOperand,Long baseOffset) throws InternalTranslationException {
final List<TranslationResult> partialResults=new ArrayList<>();
final List<? extends IOperandTreeNode> children=expression.getChildren();
Collections.sort(children,comparator);
for ( final IOperandTreeNode child : children) {
final TranslationResult nextResult=loadOperand(environment,baseOffset,child,isSegmentExpression(expression.getValue()) ? expression : null,size,loadOperand);
partialResults.add(nextResult);
baseOffset+=nextResult.getInstructions().size();
}
return partialResults;
}
| Iterates over the children of a node in the operand tree and generates translations for them. |
public void removeShutdownLatch(final CountDownLatch latch){
removeShutdownLatch(latch,false);
}
| Releases the latch and removes it from the latches being handled by this handler. |
public Version(){
this(CommonReflection.getVersionTag());
}
| Constructs a new Version from the current server version running |
public static void startActivity(Context context,String chatId){
Intent intent=new Intent(context,SendGroupFile.class);
intent.putExtra(EXTRA_CHAT_ID,chatId);
context.startActivity(intent);
}
| Start SendGroupFile activity |
public Index excludedDataCenters(String excludedDataCenters){
this.excludedDataCenters=excludedDataCenters;
return this;
}
| Sets the list of excluded data centers. |
public final int read() throws IOException {
int result=src.read();
if (result != -1) {
++pointer;
}
return result;
}
| Forwards the request to the real <code>InputStream</code>. |
public static boolean compareAndSwapInt(Object obj,long off,int exp,int upd){
return UNSAFE.compareAndSwapInt(obj,off,exp,upd);
}
| Integer CAS. |
public static String dec2Bin(int value){
String result="";
return dec2Bin(value,result);
}
| Methods converts a decimal number into a binary number as a string |
public void apply(RecyclerView recyclerView,Iterable<Item> items){
if (items != null) {
HashMap<Integer,Stack<RecyclerView.ViewHolder>> cache=new HashMap<>();
for ( Item d : items) {
if (!cache.containsKey(d.getType())) {
cache.put(d.getType(),new Stack<RecyclerView.ViewHolder>());
}
if (mCacheSize == -1 || cache.get(d.getType()).size() <= mCacheSize) {
cache.get(d.getType()).push(d.getViewHolder(recyclerView));
}
RecyclerView.RecycledViewPool recyclerViewPool=new RecyclerView.RecycledViewPool();
for ( Map.Entry<Integer,Stack<RecyclerView.ViewHolder>> entry : cache.entrySet()) {
recyclerViewPool.setMaxRecycledViews(entry.getKey(),mCacheSize);
for ( RecyclerView.ViewHolder holder : entry.getValue()) {
recyclerViewPool.putRecycledView(holder);
}
entry.getValue().clear();
}
cache.clear();
recyclerView.setRecycledViewPool(recyclerViewPool);
}
}
}
| init the cache on your own. |
public void incNumOverflowOnDisk(long delta){
this.stats.incLong(numOverflowOnDiskId,delta);
}
| Increments the current number of entries whose value has been overflowed to disk by a given amount. |
public void paint(Graphics a,JComponent b){
for (int i=0; i < uis.size(); i++) {
((ComponentUI)(uis.elementAt(i))).paint(a,b);
}
}
| Invokes the <code>paint</code> method on each UI handled by this object. |
public void updateUI(){
setUI((TableHeaderUI)UIManager.getUI(this));
TableCellRenderer renderer=getDefaultRenderer();
if (renderer instanceof Component) {
SwingUtilities.updateComponentTreeUI((Component)renderer);
}
}
| Notification from the <code>UIManager</code> that the look and feel (L&F) has changed. Replaces the current UI object with the latest version from the <code>UIManager</code>. |
public static RefactoringStatus create(IStatus status){
if (status.isOK()) return new RefactoringStatus();
if (!status.isMultiStatus()) {
switch (status.getSeverity()) {
case IStatus.OK:
return new RefactoringStatus();
case IStatus.INFO:
return RefactoringStatus.createWarningStatus(status.getMessage());
case IStatus.WARNING:
return RefactoringStatus.createErrorStatus(status.getMessage());
case IStatus.ERROR:
return RefactoringStatus.createFatalErrorStatus(status.getMessage());
case IStatus.CANCEL:
return RefactoringStatus.createFatalErrorStatus(status.getMessage());
default :
return RefactoringStatus.createFatalErrorStatus(status.getMessage());
}
}
else {
IStatus[] children=status.getChildren();
RefactoringStatus result=new RefactoringStatus();
for (int i=0; i < children.length; i++) {
result.merge(RefactoringStatus.create(children[i]));
}
return result;
}
}
| Creates a new <code>RefactoringStatus</code> from the given <code>IStatus</code>. An OK status is mapped to an OK refactoring status, an information status is mapped to a warning refactoring status, a warning status is mapped to an error refactoring status and an error or cancel status is mapped to a fatal refactoring status. An unknown status is converted into a fatal error status as well. If the status is a <code>MultiStatus </code> then the first level of children of the status will be added as refactoring status entries to the created refactoring status. |
public void debug(String msg){
debugLogger.debug(msg);
}
| Log a Setup and/or administrative log message for log4jdbc. |
public int size(){
return codon.length;
}
| Returns the length of the integer codon representation of this grammar. |
public Diff decode() throws UnsupportedEncodingException, DecodingException {
int header=r.read(3);
if (DiffAction.parse(header) != DiffAction.DECODER_DATA) {
throw new DecodingException("Invalid codecData code: " + header);
}
int blockSize_C=3;
int blockSize_S=r.read(5);
int blockSize_E=r.read(5);
int blockSize_B=r.read(5);
int blockSize_L=r.read(5);
r.read(1);
if (blockSize_S < 0 || blockSize_S > 31) {
throw new DecodingException("blockSize_S out of range: " + blockSize_S);
}
if (blockSize_E < 0 || blockSize_E > 31) {
throw new DecodingException("blockSize_E out of range: " + blockSize_E);
}
if (blockSize_B < 0 || blockSize_B > 31) {
throw new DecodingException("blockSize_B out of range: " + blockSize_B);
}
if (blockSize_L < 0 || blockSize_L > 31) {
throw new DecodingException("blockSize_L out of range: " + blockSize_L);
}
return decode(blockSize_C,blockSize_S,blockSize_E,blockSize_B,blockSize_L);
}
| Decodes the information and returns the Diff. |
public FontSizeLocator(){
}
| Creates a new instance. |
@SuppressWarnings({"unchecked","rawtypes"}) static <E extends Comparable<E>>AutoSortedCollection<E> createAutoSortedCollection(Collection<? extends E> values){
return createAutoSortedCollection(null,values);
}
| Construct new auto sorted collection using natural order. |
@Override public String toString(){
return super.toString();
}
| Returns the super class implementation of toString(). |
public boolean useLayoutEditor(SignalMast destination){
if (!destList.containsKey(destination)) {
return false;
}
return destList.get(destination).useLayoutEditor();
}
| Query if we are using the layout editor panels to build the signal mast logic, blocks, turnouts . |
private static String unescapePathComponent(String name){
return name.replaceAll("\\\\(.)","$1");
}
| Convert a path component that contains backslash escape sequences to a literal string. This is necessary when you want to explicitly refer to a path that contains globber metacharacters. |
public AbstractExampleTable(List<Attribute> attributes){
addAttributes(attributes);
}
| Creates a new ExampleTable. |
public void zoomOut(){
Matrix save=mViewPortHandler.zoomOut(getWidth() / 2f,-(getHeight() / 2f));
mViewPortHandler.refresh(save,this,true);
}
| Zooms out by 0.7f, from the charts center. center. |
public Media createBackgroundMedia(String uri) throws IOException {
return impl.createBackgroundMedia(uri);
}
| Creates an audio media that can be played in the background. |
private boolean hasNextTlsMode(){
return nextTlsMode != TLS_MODE_NULL;
}
| Returns true if there's another TLS mode to try. |
protected void copyToOpsw(){
opsw[1]=fullmode.isSelected();
opsw[2]=twoaspects.isSelected();
opsw[11]=semaphore.isSelected();
opsw[12]=pulsed.isSelected();
opsw[13]=disableDS.isSelected();
opsw[14]=fromloconet.isSelected();
opsw[15]=disablelocal.isSelected();
opsw[17]=sigaddress.isSelected();
opsw[18]=bcastaddress.isSelected();
opsw[19]=semaddress.isSelected();
opsw[20]=setdefault.isSelected();
opsw[21]=exercise.isSelected();
int value=section1to4mode.getSelectedIndex();
if ((value & 0x01) != 0) {
opsw[5]=true;
}
else {
opsw[5]=false;
}
if ((value & 0x02) != 0) {
opsw[4]=true;
}
else {
opsw[4]=false;
}
if ((value & 0x04) != 0) {
opsw[3]=true;
}
else {
opsw[3]=false;
}
value=section5to8mode.getSelectedIndex();
if ((value & 0x01) != 0) {
opsw[8]=true;
}
else {
opsw[8]=false;
}
if ((value & 0x02) != 0) {
opsw[7]=true;
}
else {
opsw[7]=false;
}
if ((value & 0x04) != 0) {
opsw[6]=true;
}
else {
opsw[6]=false;
}
value=fourthAspect.getSelectedIndex();
if ((value & 0x01) != 0) {
opsw[10]=true;
}
else {
opsw[10]=false;
}
if ((value & 0x02) != 0) {
opsw[9]=true;
}
else {
opsw[9]=false;
}
}
| Copy from the GUI to the opsw array. <p> Used before write operations start |
@Override public void onRequestPermissionsResult(int requestCode,@NonNull String[] permissions,@NonNull int[] grantResults){
if (requestCode == ALLOW_PERMISSIONS && grantResults.length > 0) {
List<String> permissionsNotAllowed=new ArrayList<>();
for (int i=0; i < permissions.length; i++) {
if (grantResults[i] == PackageManager.PERMISSION_DENIED) {
permissionsNotAllowed.add(permissions[i]);
}
}
if (permissionsNotAllowed.isEmpty()) {
initEvent();
}
else {
permissionNotEnabled();
}
}
else {
permissionNotEnabled();
}
}
| This method is a callback. Check the user's answer after requesting permission. |
public String rowGet(String key){
String resolvedKey=resolveRowKey(key);
String cachedValue=rowMapCache.get(resolvedKey);
if (cachedValue != null) {
return cachedValue;
}
String value=rowMap.get(resolvedKey);
if (value == null && parent != null) {
value=parent.rowGet(resolvedKey);
}
if (value == null) {
return null;
}
String expandedString=expand(value,false);
rowMapCache.put(resolvedKey,expandedString);
return expandedString;
}
| Looks up and returns the RowSpec associated with the given key. First looks for an association in this LayoutMap. If there's no association, the lookup continues with the parent map - if any. |
public void postEvaluationStatistics(final EvolutionState state){
super.postEvaluationStatistics(state);
state.output.println("\nGeneration: " + state.generation,Output.V_NO_GENERAL,statisticslog);
for (int x=0; x < state.population.subpops.length; x++) for (int y=1; y < state.population.subpops[x].individuals.length; y++) state.population.subpops[x].individuals[y].printIndividualForHumans(state,statisticslog,Output.V_NO_GENERAL);
}
| Logs the best individual of the generation. |
private void checkUserExists(String entidad) throws Exception {
int count;
UsersTable table=new UsersTable();
DbConnection dbConn=new DbConnection();
try {
dbConn.open(DBSessionManager.getSession());
if (_id == ISicresAdminDefsKeys.NULL_ID) count=DbSelectFns.selectCount(dbConn,table.getBaseTableName(),table.getCountNameQual(_name));
else count=DbSelectFns.selectCount(dbConn,table.getBaseTableName(),table.getCountNameIdQual(_id,_name));
if (count > 0) ISicresAdminBasicException.throwException(ISicresAdminUserKeys.EC_USER_EXISTS_NAME);
}
catch ( Exception e) {
_logger.error(e);
throw e;
}
finally {
dbConn.close();
}
}
| Comprueba que el usuario tiene distinto nombre a los que ya existen. |
@Transactional public Role createRoleWithPermissions(Role role,Set<Long> permissionIds){
Role current=findRoleByRoleName(role.getRoleName());
Preconditions.checkState(current == null,"Role %s already exists!",role.getRoleName());
Role createdRole=roleRepository.save(role);
if (!CollectionUtils.isEmpty(permissionIds)) {
Iterable<RolePermission> rolePermissions=FluentIterable.from(permissionIds).transform(null);
rolePermissionRepository.save(rolePermissions);
}
return createdRole;
}
| Create role with permissions, note that role name should be unique |
protected void generateNewCursorBox(){
if ((old_m_x2 != -1) || (old_m_y2 != -1) || (Math.abs(commonValues.m_x2 - old_m_x2) > 5)|| (Math.abs(commonValues.m_y2 - old_m_y2) > 5)) {
int top_x=commonValues.m_x1;
if (commonValues.m_x1 > commonValues.m_x2) {
top_x=commonValues.m_x2;
}
int top_y=commonValues.m_y1;
if (commonValues.m_y1 > commonValues.m_y2) {
top_y=commonValues.m_y2;
}
final int w=Math.abs(commonValues.m_x2 - commonValues.m_x1);
final int h=Math.abs(commonValues.m_y2 - commonValues.m_y1);
final int[] currentRectangle={top_x,top_y,w,h};
decode_pdf.updateCursorBoxOnScreen(currentRectangle,DecoderOptions.highlightColor.getRGB());
if (!currentCommands.extractingAsImage) {
final int[] r={commonValues.m_x1,commonValues.m_y1,commonValues.m_x2 - commonValues.m_x1,commonValues.m_y2 - commonValues.m_y1};
decode_pdf.getTextLines().addHighlights(new int[][]{r},false,commonValues.getCurrentPage());
}
old_m_x2=commonValues.m_x2;
old_m_y2=commonValues.m_y2;
}
decode_pdf.repaintPane(commonValues.getCurrentPage());
}
| generate new cursorBox and highlight extractable text, if hardware acceleration off and extraction on<br> and update current cursor box displayed on screen |
public OMGraphicList(int initialCapacity){
graphics=Collections.synchronizedList(new ArrayList<OMGraphic>(initialCapacity));
}
| Construct an OMGraphicList with an initial capacity. |
private void saveToSettings(){
List<String> dataToSave=new LinkedList<>();
for ( UsercolorItem item : data) {
dataToSave.add(item.getId() + "," + HtmlColors.getColorString(item.getColor()));
}
settings.putList("usercolors",dataToSave);
}
| Copy the current data to the settings. |
public static boolean isArrayForName(String value){
return ARRAY_FOR_NAME_PATTERN.matcher(value).matches();
}
| Returns true if the given string looks like a Java array name. |
public double length(){
return Math.sqrt(this.x * this.x + this.y * this.y);
}
| Calculates the length of the vector. |
public String toString(){
return schema;
}
| Returns this' media-type (a MIME content-type category) (previously returned a description key) |
public void restoreStarting(int numPackages){
}
| The restore operation has begun. |
private boolean resourceIsGwtXmlAndInGwt(IResource resource) throws CoreException {
return GWTNature.isGWTProject(resource.getProject()) && resource.getName().endsWith(".gwt.xml");
}
| If the resource is a .gwt.xml file and we're in a gwt-enabled project, return true. |
public GlowCreature(Location location,EntityType type,double maxHealth){
super(location,maxHealth);
this.type=type;
}
| Creates a new monster. |
public CacheLayer(){
}
| Construct a default CacheLayer. |
protected Address buildAndroidAddress(JSONObject jResult) throws JSONException {
Address gAddress=new Address(mLocale);
gAddress.setLatitude(jResult.getDouble("lat"));
gAddress.setLongitude(jResult.getDouble("lng"));
int addressIndex=0;
if (jResult.has("streetName")) {
gAddress.setAddressLine(addressIndex++,jResult.getString("streetName"));
gAddress.setThoroughfare(jResult.getString("streetName"));
}
if (jResult.has("zipCode")) {
gAddress.setAddressLine(addressIndex++,jResult.getString("zipCode"));
gAddress.setPostalCode(jResult.getString("zipCode"));
}
if (jResult.has("city")) {
gAddress.setAddressLine(addressIndex++,jResult.getString("city"));
gAddress.setLocality(jResult.getString("city"));
}
if (jResult.has("state")) {
gAddress.setAdminArea(jResult.getString("state"));
}
if (jResult.has("country")) {
gAddress.setAddressLine(addressIndex++,jResult.getString("country"));
gAddress.setCountryName(jResult.getString("country"));
}
if (jResult.has("countrycode")) gAddress.setCountryCode(jResult.getString("countrycode"));
return gAddress;
}
| Build an Android Address object from the Gisgraphy address in JSON format. |
public JDBCCategoryDataset(Connection connection,String query) throws SQLException {
this(connection);
executeQuery(query);
}
| Creates a new dataset with the given database connection, and executes the supplied query to populate the dataset. |
public static Map<String,Object> generateReqsFromCancelledPOItems(DispatchContext dctx,Map<String,? extends Object> context){
Delegator delegator=dctx.getDelegator();
LocalDispatcher dispatcher=dctx.getDispatcher();
GenericValue userLogin=(GenericValue)context.get("userLogin");
Locale locale=(Locale)context.get("locale");
String orderId=(String)context.get("orderId");
String facilityId=(String)context.get("facilityId");
try {
GenericValue orderHeader=EntityQuery.use(delegator).from("OrderHeader").where("orderId",orderId).queryOne();
if (UtilValidate.isEmpty(orderHeader)) {
String errorMessage=UtilProperties.getMessage(resource_error,"OrderErrorOrderIdNotFound",UtilMisc.toMap("orderId",orderId),locale);
Debug.logError(errorMessage,module);
return ServiceUtil.returnError(errorMessage);
}
if (!"PURCHASE_ORDER".equals(orderHeader.getString("orderTypeId"))) {
String errorMessage=UtilProperties.getMessage(resource_error,"ProductErrorOrderNotPurchaseOrder",UtilMisc.toMap("orderId",orderId),locale);
Debug.logError(errorMessage,module);
return ServiceUtil.returnError(errorMessage);
}
Map<String,Object> productRequirementQuantities=new HashMap<String,Object>();
List<GenericValue> orderItems=orderHeader.getRelated("OrderItem",null,null,false);
for ( GenericValue orderItem : orderItems) {
if (!"PRODUCT_ORDER_ITEM".equals(orderItem.getString("orderItemTypeId"))) continue;
BigDecimal orderItemCancelQuantity=BigDecimal.ZERO;
if (!UtilValidate.isEmpty(orderItem.get("cancelQuantity"))) {
orderItemCancelQuantity=orderItem.getBigDecimal("cancelQuantity");
}
if (orderItemCancelQuantity.compareTo(BigDecimal.ZERO) <= 0) continue;
String productId=orderItem.getString("productId");
if (productRequirementQuantities.containsKey(productId)) {
orderItemCancelQuantity=orderItemCancelQuantity.add((BigDecimal)productRequirementQuantities.get(productId));
}
productRequirementQuantities.put(productId,orderItemCancelQuantity);
}
for ( String productId : productRequirementQuantities.keySet()) {
BigDecimal requiredQuantity=(BigDecimal)productRequirementQuantities.get(productId);
Map<String,Object> createRequirementResult=dispatcher.runSync("createRequirement",UtilMisc.<String,Object>toMap("requirementTypeId","PRODUCT_REQUIREMENT","facilityId",facilityId,"productId",productId,"quantity",requiredQuantity,"userLogin",userLogin));
if (ServiceUtil.isError(createRequirementResult)) return createRequirementResult;
}
}
catch ( GenericEntityException e) {
Debug.logError(e,module);
return ServiceUtil.returnError(e.getMessage());
}
catch ( GenericServiceException se) {
Debug.logError(se,module);
return ServiceUtil.returnError(se.getMessage());
}
return ServiceUtil.returnSuccess();
}
| Generates a product requirement for the total cancelled quantity over all order items for each product |
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException {
s.defaultReadObject();
if (bayesIm == null) {
throw new NullPointerException();
}
if (variables == null) {
throw new NullPointerException();
}
}
| Adds semantic checks to the default deserialization method. This method must have the standard signature for a readObject method, and the body of the method must begin with "s.defaultReadObject();". Other than that, any semantic checks can be specified and do not need to stay the same from version to version. A readObject method of this form may be added to any class, even if Tetrad sessions were previously saved out using a version of the class that didn't include it. (That's what the "s.defaultReadObject();" is for. See J. Bloch, Effective Java, for help. |
boolean contains(ProtocolVersion protocolVersion){
if (protocolVersion == ProtocolVersion.SSL20Hello) {
return false;
}
return protocols.contains(protocolVersion);
}
| Return whether this list contains the specified protocol version. SSLv2Hello is not a real protocol version we support, we always return false for it. |
@Override protected EClass eStaticClass(){
return DatatypePackage.Literals.OBJECT_PROPERTY_TYPE;
}
| <!-- begin-user-doc --> <!-- end-user-doc --> |
@DSGenerator(tool_name="Doppelganger",tool_version="2.0",generated_on="2013-12-30 12:34:35.806 -0500",hash_original_method="E14DF72F5869874CC38AD67447F5264E",hash_generated_method="127365361841BB38033FE96228DFD635") public final Iterator<String> typesIterator(){
return mDataTypes != null ? mDataTypes.iterator() : null;
}
| Return an iterator over the filter's data types. |
public void registerGUI(final ConfigGUI gui){
this.gui=gui;
}
| Sets the reference of the GUI. |
public IntersectionMatrix(IntersectionMatrix other){
this();
matrix[Location.INTERIOR][Location.INTERIOR]=other.matrix[Location.INTERIOR][Location.INTERIOR];
matrix[Location.INTERIOR][Location.BOUNDARY]=other.matrix[Location.INTERIOR][Location.BOUNDARY];
matrix[Location.INTERIOR][Location.EXTERIOR]=other.matrix[Location.INTERIOR][Location.EXTERIOR];
matrix[Location.BOUNDARY][Location.INTERIOR]=other.matrix[Location.BOUNDARY][Location.INTERIOR];
matrix[Location.BOUNDARY][Location.BOUNDARY]=other.matrix[Location.BOUNDARY][Location.BOUNDARY];
matrix[Location.BOUNDARY][Location.EXTERIOR]=other.matrix[Location.BOUNDARY][Location.EXTERIOR];
matrix[Location.EXTERIOR][Location.INTERIOR]=other.matrix[Location.EXTERIOR][Location.INTERIOR];
matrix[Location.EXTERIOR][Location.BOUNDARY]=other.matrix[Location.EXTERIOR][Location.BOUNDARY];
matrix[Location.EXTERIOR][Location.EXTERIOR]=other.matrix[Location.EXTERIOR][Location.EXTERIOR];
}
| Creates an <code>IntersectionMatrix</code> with the same elements as <code>other</code>. |
public long readUnsignedInt(){
long result=shiftIntoLong(data,position,4);
position+=4;
return result;
}
| Reads the next four bytes as an unsigned value. |
public void emit(final SpannableStringBuilder out,final Block root){
root.removeSurroundingEmptyLines();
switch (root.type) {
case NONE:
break;
case PARAGRAPH:
this.config.decorator.openParagraph(out);
break;
case BLOCKQUOTE:
this.config.decorator.openBlockquote(out);
break;
case UNORDERED_LIST:
this.config.decorator.openUnorderedList(out);
break;
case ORDERED_LIST:
this.config.decorator.openOrderedList(out);
break;
case UNORDERED_LIST_ITEM:
this.config.decorator.openUnOrderedListItem(out);
break;
case ORDERED_LIST_ITEM:
this.config.decorator.openOrderedListItem(out);
break;
}
if (root.hasLines()) {
this.emitLines(out,root);
}
else {
Block block=root.blocks;
while (block != null) {
this.emit(out,block);
block=block.next;
}
}
switch (root.type) {
case NONE:
break;
case PARAGRAPH:
this.config.decorator.closeParagraph(out);
break;
case BLOCKQUOTE:
this.config.decorator.closeBlockquote(out);
break;
case UNORDERED_LIST:
this.config.decorator.closeUnorderedList(out);
break;
case ORDERED_LIST:
this.config.decorator.closeOrderedList(out);
break;
case UNORDERED_LIST_ITEM:
this.config.decorator.closeUnOrderedListItem(out);
break;
case ORDERED_LIST_ITEM:
this.config.decorator.closeOrderedListItem(out);
break;
}
}
| Transforms the given block recursively into HTML. |
public boolean isInternable(){
return (classAnnotations != null) && (fieldAnnotations == null) && (methodAnnotations == null)&& (parameterAnnotations == null);
}
| Returns whether this item is a candidate for interning. The only interning candidates are ones that <i>only</i> have a non-null set of class annotations, with no other lists. |
public URI(final String scheme,final String userinfo,final String host,final int port,final String path,final String query,final String fragment) throws URIException {
this(scheme,(host == null) ? null : ((userinfo != null) ? userinfo + '@' : "") + host + ((port != -1) ? ":" + port : ""),path,query,fragment);
}
| Construct a general URI from the given components. |
public void addUser(User user){
users.addElement(user);
}
| Add a user |
protected void engineUpdate(byte b) throws SignatureException {
msgDigest.update(b);
}
| Updates data to sign or to verify. |
public RqMtFake(final Request req,final Request... dispositions) throws IOException {
this.fake=new RqMtBase(new RqMtFake.FakeMultipartRequest(req,dispositions));
}
| Fake ctor. |
public static Video randomVideo(){
String id=UUID.randomUUID().toString();
String title="Video-" + id;
String url="http://coursera.org/some/video-" + id;
long duration=60 * (int)Math.rint(Math.random() * 60) * 1000;
return new Video(title,url,duration);
}
| Construct and return a Video object with a rnadom name, url, and duration. |
public void addHeader(String header,String value){
clientHeaderMap.put(header,value);
}
| Sets headers that will be added to all requests this client makes (before sending). |
public void addPostalAddress(PostalAddress postalAddress){
getPostalAddresses().add(postalAddress);
}
| Adds a new contact postal address. |
public CaughtExceptionRef newCaughtExceptionRef(){
return new JCaughtExceptionRef();
}
| Constructs a CaughtExceptionRef() grammar chunk. |
public void actionPerformed(ActionEvent e){
if (e.getSource() instanceof PerformanceIndicator) {
PerformanceIndicator pi=(PerformanceIndicator)e.getSource();
log.info(pi.getName());
MGoal goal=pi.getGoal();
if (goal.getMeasure() != null) new PerformanceDetail(goal);
}
}
| Action Listener for Drill Down |
public Iterator<AbstractNode> childIterator(final boolean dirtyNodesOnly){
if (dirtyNodesOnly) {
return new DirtyChildIterator(this);
}
else {
return new ChildIterator(this);
}
}
| Iterator visits the direct child nodes in the external key ordering. |
public static int maxIndex(double[] doubles){
double maximum=0;
int maxIndex=0;
for (int i=0; i < doubles.length; i++) {
if ((i == 0) || (doubles[i] > maximum)) {
maxIndex=i;
maximum=doubles[i];
}
}
return maxIndex;
}
| Returns index of maximum element in a given array of doubles. First maximum is returned. |
private List<PreferenceIndex> crawlSingleIndexableResource(IndexableFragment indexableFragment){
List<PreferenceIndex> indexablePreferences=new ArrayList<>();
XmlPullParser parser=mContext.getResources().getXml(indexableFragment.xmlRes);
int type;
try {
while ((type=parser.next()) != XmlPullParser.END_DOCUMENT && type != XmlPullParser.START_TAG) {
}
String nodeName=parser.getName();
if (!NODE_NAME_PREFERENCE_SCREEN.equals(nodeName)) {
throw new RuntimeException("XML document must start with <PreferenceScreen> tag; found" + nodeName + " at "+ parser.getPositionDescription());
}
final int outerDepth=parser.getDepth();
final AttributeSet attrs=Xml.asAttributeSet(parser);
while ((type=parser.next()) != XmlPullParser.END_DOCUMENT && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
continue;
}
nodeName=parser.getName();
String key=PreferenceXmlUtil.getDataKey(mContext,attrs);
String title=PreferenceXmlUtil.getDataTitle(mContext,attrs);
if (NODE_NAME_PREFERENCE_CATEGORY.equals(nodeName) || TextUtils.isEmpty(key) || TextUtils.isEmpty(title)) {
continue;
}
PreferenceIndex indexablePreference=new PreferenceIndex(key,title,indexableFragment.fragmentName);
indexablePreferences.add(indexablePreference);
}
}
catch ( XmlPullParserException|IOException|ReflectiveOperationException ex) {
Log.e(TAG,"Error in parsing a preference xml file, skip it",ex);
}
return indexablePreferences;
}
| Skim through the xml preference file. |
End of preview. Expand
in Dataset Viewer.
README.md exists but content is empty.
Use the Edit dataset card button to edit it.
- Downloads last month
- 45