code
stringlengths 10
174k
| nl
stringlengths 3
129k
|
---|---|
public int hashCode(){
return this.value.hashCode() * 21;
}
| The hash of the Primitive is tied to the hash of the wrapped value but shifted so that they are not the same. |
public static String escapeXml(String s,boolean advanced,boolean recognizeUnicodeChars,boolean translateSpecialEntities,boolean isDomCreation,boolean transResCharsToNCR,boolean translateSpecialEntitiesToNCR){
return escapeXml(s,advanced,recognizeUnicodeChars,translateSpecialEntities,isDomCreation,transResCharsToNCR,translateSpecialEntitiesToNCR,false);
}
| change notes: 1) convert ascii characters encoded using &#xx; format to the ascii characters -- may be an attempt to slip in malicious html 2) convert &#xxx; format characters to " style representation if available for the character. 3) convert html special entities to xml &#xxx; when outputing in xml |
public synchronized boolean isStopped(){
return playerState == PlayerStates.STOPPED;
}
| Checks whether the player is currently stopped (not playing) |
public void dispose(){
if (t2 != null) {
t2.cancel();
}
t2=null;
}
| fix submitted by Niklas Matthies |
public LongsRef(int capacity){
longs=new long[capacity];
}
| Create a LongsRef pointing to a new array of size <code>capacity</code>. Offset and length will both be zero. |
public HeadPhaseBuilder<S> findFirst(S defaultValue,RError.Message message,Object... messageArgs){
pipelineBuilder().appendFindFirst(defaultValue,elementClass,null,message,messageArgs);
return new HeadPhaseBuilder<>(pipelineBuilder());
}
| The inserted cast node returns the default value if the input vector is empty. It also reports the warning message. |
public Pan(AbstractChart chart){
super(chart);
}
| Builds and instance of the pan tool. |
public DeviceAutomator checkForegroundAppIs(String packageName){
return checkForegroundAppIs(packageName,5000);
}
| Asserts that the foreground app has the given package name. Waits for up to 5 seconds for the given package to become the foreground app. |
public ActionEvent(Component dragged,Type type,Component drop,int x,int y){
this.source=dragged;
this.sourceComponent=drop;
this.keyEvent=x;
this.y=y;
this.trigger=type;
}
| Creates a new instance of ActionEvent for a drop operation |
public ServerConfiguration enableDurableWrite(boolean enabled){
setProperty(SERVER_DURABLE_WRITE_ENABLED,enabled);
return this;
}
| Set the flag to enable/disable durable write |
public static Matrix fromLocalOrientation(Vec4 origin,Vec4[] axes){
if (origin == null) {
String msg=Logging.getMessage("nullValue.OriginIsNull");
Logging.logger().severe(msg);
throw new IllegalArgumentException(msg);
}
if (axes == null) {
String msg=Logging.getMessage("nullValue.AxesIsNull");
Logging.logger().severe(msg);
throw new IllegalArgumentException(msg);
}
if (axes.length < 3) {
String msg=Logging.getMessage("generic.ArrayInvalidLength",axes.length);
Logging.logger().severe(msg);
throw new IllegalArgumentException(msg);
}
if (axes[0] == null || axes[1] == null || axes[2] == null) {
String msg=Logging.getMessage("nullValue.AxesIsNull");
Logging.logger().severe(msg);
throw new IllegalArgumentException(msg);
}
return fromTranslation(origin).multiply(fromAxes(axes));
}
| Returns a Cartesian transform <code>Matrix</code> that maps a local origin and orientation to model coordinates. The transform is specified by a local <code>origin</code> and an array of three <code>axes</code>. The <code>axes</code> array must contain three non-null vectors, which are interpreted in the following order: x-axis, y-axis, z-axis. This ensures that the axes in the returned <code>Matrix</code> have unit length and are orthogonal to each other. |
public AspectContainer load(@Nullable NBTTagCompound nbt,@Nullable List<Aspect> staticAspects){
List<InternalAspect> aspects=new ArrayList<InternalAspect>();
if (nbt != null) {
NBTTagList typesList=nbt.getTagList(ASPECTS_NBT_TAG,Constants.NBT.TAG_LIST);
int typesCount=typesList.tagCount();
for (int i=0; i < typesCount; i++) {
NBTTagList aspectsList=(NBTTagList)typesList.get(i);
int aspectsCount=aspectsList.tagCount();
for (int c=0; c < aspectsCount; c++) {
NBTTagCompound aspectNBT=aspectsList.getCompoundTagAt(c);
InternalAspect aspect=InternalAspect.readFromNBT(aspectNBT);
if (aspect != null) aspects.add(aspect);
}
}
}
if (staticAspects != null) {
for ( Aspect aspect : staticAspects) {
boolean hasStatic=false;
for ( InternalAspect internalAspect : aspects) {
if (!internalAspect.isDynamic && aspect.type == internalAspect.type) hasStatic=true;
}
if (!hasStatic) aspects.add(new InternalAspect(aspect.type,aspect.amount,false,false));
}
}
for ( InternalAspect aspect : aspects) {
List<InternalAspect> entries=this.getEntries(aspect.type);
entries.add(aspect);
}
return this;
}
| Reads the container from the specified NBT and adds the static aspects |
public void addDevices(Collection<IEspDevice> devices,int upgradeType){
for ( IEspDevice device : devices) {
addDevice(device,upgradeType);
}
}
| Add devices to upgrade |
public static void register(){
FilePath.register(new FilePathEncrypt());
}
| Register this file system. |
public static void updateBeforeLoad(final DigestURL url){
final String host=url.getHost();
if (host == null) return;
String hosthash=url.hosthash();
Host h=map.get(hosthash);
if (h == null) {
h=new Host(host,500,0);
if (map.size() > mapMaxSize || MemoryControl.shortStatus()) map.clear();
map.put(hosthash,h);
}
else {
h.update();
}
}
| update the latency entry before a host is accessed |
public RoleException(Throwable cause){
super(cause);
}
| Constructs an instance of <code>RoleException</code> with the specified cause. |
private CMemoryFunctions(){
}
| You are not supposed to instantiate this class. |
private void writeAttribute(java.lang.String namespace,java.lang.String attName,java.lang.String attValue,javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException {
if (namespace.equals("")) {
xmlWriter.writeAttribute(attName,attValue);
}
else {
registerPrefix(xmlWriter,namespace);
xmlWriter.writeAttribute(namespace,attName,attValue);
}
}
| Util method to write an attribute without the ns prefix |
public static <T>LtPredicate<T> lt(Property<T> property,T value){
return new LtPredicate<>(property(property),value);
}
| Create a new LESSER THAN specification for a Property. |
@Override public boolean isActive(){
return amIActive;
}
| Used by the Whitebox GUI to tell if this plugin is still running. |
public boolean poolMatchesCapacity(StoragePool pool,long requiredCapacity,long resourceSize,boolean checkPoolMaxSizeLimit,boolean supportsThinProvisioning,Long thinVolumePreAllocationResourceSize){
if (null == pool.getTotalCapacity() || pool.getTotalCapacity() == 0) {
return false;
}
long preAllocationSizeInKB=0;
long sizeInKB=getSizeInKB(requiredCapacity);
long resourceSizeInKB=getSizeInKB(resourceSize);
if ((PoolServiceType.block.toString().equalsIgnoreCase(pool.getPoolServiceType()) || PoolServiceType.block_file.name().equalsIgnoreCase(pool.getPoolServiceType())) && checkPoolMaxSizeLimit) {
Long maxVolumeSizeLimit=getMaxVolumeSizeLimit(pool,supportsThinProvisioning);
if (maxVolumeSizeLimit == null || maxVolumeSizeLimit == 0) {
String errorMsg=String.format("Pool %s does not have maximum size limit for %s volumes set.",pool.getId(),pool.getSupportedResourceTypes());
_log.error(errorMsg);
return false;
}
if (null != pool.getPoolClassName() && (pool.getPoolClassName().equals(StoragePool.PoolClassNames.Clar_UnifiedStoragePool.toString()) || pool.getPoolClassName().equals(StoragePool.PoolClassNames.VNXe_Pool.name())) && resourceSizeInKB > maxVolumeSizeLimit) {
_log.info(String.format("Pool %s is not matching as the pool's maximum volume size (%s KB) is below the requested volume size %s KB.",pool.getId(),maxVolumeSizeLimit,resourceSizeInKB));
return false;
}
}
if (pool.getSupportedResourceTypes() != null && pool.getSupportedResourceTypes().equals(StoragePool.SupportedResourceTypes.THICK_ONLY.name()) || !supportsThinProvisioning) {
return isPoolMatchesCapacityForThickProvisioning(pool,sizeInKB);
}
if (null != thinVolumePreAllocationResourceSize) {
preAllocationSizeInKB=getSizeInKB(thinVolumePreAllocationResourceSize);
}
return isPoolMatchesCapacityForThinProvisioning(pool,sizeInKB,preAllocationSizeInKB,_coordinator);
}
| Decision is made as following: 1. Check volume size against maximum volume size limit of storage pool (if required). 2. --- Thick pool: solely based on the pool utilization capacity including the current request & the requested capacity < pool freeCapacity. --- Thin pool: It depends on two factors. 1. pool utilization -> Pool should be less utilized 2. pool subscribedCapacity -> pool should subscribed less than user configured. |
@Override public void update(){
if (block != null) {
((Updater)block).update(0.05);
}
}
| Updates the block. |
private void updateProgress(int progress){
if (myHost != null && progress != previousProgress) {
myHost.updateProgress(progress);
}
previousProgress=progress;
}
| Used to communicate a progress update between a plugin tool and the main Whitebox user interface. |
public synchronized void warning(String s,Parameter p1){
println("WARNING:\n" + s,ALL_MESSAGE_LOGS,true);
if (p1 != null) println("PARAMETER: " + p1,ALL_MESSAGE_LOGS,true);
}
| Posts a warning. |
private void zzScanError(int errorCode){
String message;
try {
message=ZZ_ERROR_MSG[errorCode];
}
catch ( ArrayIndexOutOfBoundsException e) {
message=ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
}
throw new Error(message);
}
| Reports an error that occured while scanning. In a wellformed scanner (no or only correct usage of yypushback(int) and a match-all fallback rule) this method will only be called with things that "Can't Possibly Happen". If this method is called, something is seriously wrong (e.g. a JFlex bug producing a faulty scanner etc.). Usual syntax/scanner level error handling should be done in error fallback rules. |
public void print(final String str){
if ((str != null) && (str.length() > 0)) {
_append(str);
}
}
| Print text to the console |
static void propertiesComments(StringBuffer result,long val){
result.append(" ");
switch ((int)(val & maskType)) {
case UnicodeSpec.CONTROL:
result.append("Cc");
break;
case UnicodeSpec.FORMAT:
result.append("Cf");
break;
case UnicodeSpec.PRIVATE_USE:
result.append("Co");
break;
case UnicodeSpec.SURROGATE:
result.append("Cs");
break;
case UnicodeSpec.LOWERCASE_LETTER:
result.append("Ll");
break;
case UnicodeSpec.MODIFIER_LETTER:
result.append("Lm");
break;
case UnicodeSpec.OTHER_LETTER:
result.append("Lo");
break;
case UnicodeSpec.TITLECASE_LETTER:
result.append("Lt");
break;
case UnicodeSpec.UPPERCASE_LETTER:
result.append("Lu");
break;
case UnicodeSpec.COMBINING_SPACING_MARK:
result.append("Mc");
break;
case UnicodeSpec.ENCLOSING_MARK:
result.append("Me");
break;
case UnicodeSpec.NON_SPACING_MARK:
result.append("Mn");
break;
case UnicodeSpec.DECIMAL_DIGIT_NUMBER:
result.append("Nd");
break;
case UnicodeSpec.LETTER_NUMBER:
result.append("Nl");
break;
case UnicodeSpec.OTHER_NUMBER:
result.append("No");
break;
case UnicodeSpec.CONNECTOR_PUNCTUATION:
result.append("Pc");
break;
case UnicodeSpec.DASH_PUNCTUATION:
result.append("Pd");
break;
case UnicodeSpec.END_PUNCTUATION:
result.append("Pe");
break;
case UnicodeSpec.OTHER_PUNCTUATION:
result.append("Po");
break;
case UnicodeSpec.START_PUNCTUATION:
result.append("Ps");
break;
case UnicodeSpec.CURRENCY_SYMBOL:
result.append("Sc");
break;
case UnicodeSpec.MODIFIER_SYMBOL:
result.append("Sk");
break;
case UnicodeSpec.MATH_SYMBOL:
result.append("Sm");
break;
case UnicodeSpec.OTHER_SYMBOL:
result.append("So");
break;
case UnicodeSpec.LINE_SEPARATOR:
result.append("Zl");
break;
case UnicodeSpec.PARAGRAPH_SEPARATOR:
result.append("Zp");
break;
case UnicodeSpec.SPACE_SEPARATOR:
result.append("Zs");
break;
case UnicodeSpec.UNASSIGNED:
result.append("unassigned");
break;
}
switch ((int)((val & maskBidi) >> shiftBidi)) {
case UnicodeSpec.DIRECTIONALITY_LEFT_TO_RIGHT:
result.append(", L");
break;
case UnicodeSpec.DIRECTIONALITY_RIGHT_TO_LEFT:
result.append(", R");
break;
case UnicodeSpec.DIRECTIONALITY_EUROPEAN_NUMBER:
result.append(", EN");
break;
case UnicodeSpec.DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR:
result.append(", ES");
break;
case UnicodeSpec.DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR:
result.append(", ET");
break;
case UnicodeSpec.DIRECTIONALITY_ARABIC_NUMBER:
result.append(", AN");
break;
case UnicodeSpec.DIRECTIONALITY_COMMON_NUMBER_SEPARATOR:
result.append(", CS");
break;
case UnicodeSpec.DIRECTIONALITY_PARAGRAPH_SEPARATOR:
result.append(", B");
break;
case UnicodeSpec.DIRECTIONALITY_SEGMENT_SEPARATOR:
result.append(", S");
break;
case UnicodeSpec.DIRECTIONALITY_WHITESPACE:
result.append(", WS");
break;
case UnicodeSpec.DIRECTIONALITY_OTHER_NEUTRALS:
result.append(", ON");
break;
}
if ((val & maskUpperCase) != 0) {
result.append(", hasUpper (subtract ");
result.append((val & maskCaseOffset) >> shiftCaseOffset).append(")");
}
if ((val & maskLowerCase) != 0) {
result.append(", hasLower (add ");
result.append((val & maskCaseOffset) >> shiftCaseOffset).append(")");
}
if ((val & maskTitleCase) != 0) {
result.append(", hasTitle");
}
if ((val & maskIdentifierInfo) == valueIgnorable) {
result.append(", ignorable");
}
if ((val & maskIdentifierInfo) == valueJavaUnicodePart) {
result.append(", identifier part");
}
if ((val & maskIdentifierInfo) == valueJavaStartUnicodePart) {
result.append(", underscore");
}
if ((val & maskIdentifierInfo) == valueJavaWhitespace) {
result.append(", whitespace");
}
if ((val & maskIdentifierInfo) == valueJavaOnlyStart) {
result.append(", currency");
}
if ((val & maskIdentifierInfo) == valueJavaUnicodeStart) {
result.append(", identifier start");
}
if ((val & maskNumericType) == valueDigit) {
result.append(", decimal ");
result.append((val & maskDigitOffset) >> shiftDigitOffset);
}
if ((val & maskNumericType) == valueStrangeNumeric) {
result.append(", strange");
}
if ((val & maskNumericType) == valueJavaSupradecimal) {
result.append(", supradecimal ");
result.append((val & maskDigitOffset) >> shiftDigitOffset);
}
}
| The propertiesComments method generates comments describing encoded character properties. |
public SocketTimeoutException(String detailMessage,Throwable cause){
super(detailMessage,cause);
}
| Constructs a new instance with given detail message and cause. |
static ZipFile buildProjectFromSources(Path sourcesPath,String artifactNamePattern) throws IOException, InterruptedException {
final String[] command;
if (SystemInfo.isWindows()) {
command=new String[]{"CMD","/C","mvn","clean","package"};
}
else {
command=new String[]{MavenUtils.getMavenExecCommand(),"clean","package"};
}
ProcessBuilder processBuilder=new ProcessBuilder(command).directory(sourcesPath.toFile()).redirectErrorStream(true);
Process process=processBuilder.start();
ListLineConsumer consumer=new ListLineConsumer();
ProcessUtil.process(process,consumer,LineConsumer.DEV_NULL);
process.waitFor();
if (process.exitValue() != 0) {
throw new IOException(consumer.getText());
}
return new ZipFile(IoUtil.findFile(artifactNamePattern,sourcesPath.resolve("target").toFile()));
}
| Builds project with Maven from the specified sources. |
public static int root(int value){
if (value < 0) {
TestBase.logError("function called but should not",null);
}
return (int)Math.sqrt(value);
}
| This method is called via reflection from the database. |
@Override public void registerOutParameter(String parameterName,int sqlType,int scale) throws SQLException {
registerOutParameter(getIndexForName(parameterName),sqlType,scale);
}
| Registers the given OUT parameter. |
protected void describe(String description){
SwiftTestUtils.noteAction(description);
}
| Describe the test, combining some logging with details for people reading the code |
public boolean fireMapMouseDragged(MouseEvent evt){
if (DEBUG_DETAIL) {
logger.finer("MapMouseSupport: fireMapMouseDragged");
}
clickHappened=false;
boolean consumed=false;
if (proxy == null || evt.isShiftDown() || (proxyDistributionMask & PROXY_DISTRIB_MOUSE_DRAGGED) > 0) {
evt=new MapMouseEvent(getParentMode(),evt);
Iterator<MapMouseListener> it=iterator();
while (it.hasNext() && !consumed) {
consumed=it.next().mouseDragged(evt) && consumeEvents;
}
}
boolean ignoreConsumed=!consumed || (consumed && ((proxyDistributionMask & PROXY_ACK_CONSUMED_MOUSE_DRAGGED) == 0));
if (proxy != null && ignoreConsumed && !evt.isShiftDown()) {
proxy.mouseDragged(evt);
consumed=true;
}
return consumed;
}
| Handle a mouseDragged MouseListener event. |
static int findDisplayedMnemonicIndex(String text,int mnemonic){
if (text == null || mnemonic == '\0') {
return -1;
}
char uc=Character.toUpperCase((char)mnemonic);
char lc=Character.toLowerCase((char)mnemonic);
int uci=text.indexOf(uc);
int lci=text.indexOf(lc);
if (uci == -1) {
return lci;
}
else if (lci == -1) {
return uci;
}
else {
return (lci < uci) ? lci : uci;
}
}
| Returns index of the first occurrence of <code>mnemonic</code> within string <code>text</code>. Matching algorithm is not case-sensitive. |
public void useProgram(int programId){
if (this.programId != programId) {
this.programId=programId;
GLES20.glUseProgram(programId);
}
}
| Makes an OpenGL program object active as part of current rendering state. This has no effect if the specified program object is already active. The default is program 0, indicating that no program is active. |
private void parse() throws IOException {
int majorVersion=readByte();
int minorVersion=readByte();
int hdrsz=readByte();
int offsize=readByte();
int fnames=hdrsz;
int topdicts=fnames + getIndexSize(fnames);
int theNames=topdicts + getIndexSize(topdicts);
gsubrbase=theNames + getIndexSize(theNames);
gsubrsoffset=calcoffset(gsubrbase);
readNames(theNames);
pos=topdicts;
if (readInt(2) != 1) {
printData();
throw new RuntimeException("More than one font in this file!");
}
Range r=getIndexEntry(fnames,0);
fontname=new String(data,r.getStart(),r.getLen());
readDict(getIndexEntry(topdicts,0));
readDict(new Range(privatebase,privatesize));
pos=charstringbase;
nglyphs=readInt(2);
readGlyphNames(charsetbase);
readEncodingData(encodingbase);
}
| parse the font data. |
private void pushPacket(IOFSwitch sw,Match match,OFPacketIn pi,OFPort outport){
if (pi == null) {
return;
}
OFPort inPort=(pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT));
if (inPort.equals(outport)) {
if (log.isDebugEnabled()) {
log.debug("Attempting to do packet-out to the same " + "interface as packet-in. Dropping packet. " + " SrcSwitch={}, match = {}, pi={}",new Object[]{sw,match,pi});
return;
}
}
if (log.isTraceEnabled()) {
log.trace("PacketOut srcSwitch={} match={} pi={}",new Object[]{sw,match,pi});
}
OFPacketOut.Builder pob=sw.getOFFactory().buildPacketOut();
List<OFAction> actions=new ArrayList<OFAction>();
actions.add(sw.getOFFactory().actions().buildOutput().setPort(outport).setMaxLen(Integer.MAX_VALUE).build());
pob.setActions(actions);
if (sw.getBuffers() == 0) {
pi=pi.createBuilder().setBufferId(OFBufferId.NO_BUFFER).build();
pob.setBufferId(OFBufferId.NO_BUFFER);
}
else {
pob.setBufferId(pi.getBufferId());
}
pob.setInPort(inPort);
if (pi.getBufferId() == OFBufferId.NO_BUFFER) {
byte[] packetData=pi.getData();
pob.setData(packetData);
}
counterPacketOut.increment();
sw.write(pob.build());
}
| Pushes a packet-out to a switch. The assumption here is that the packet-in was also generated from the same switch. Thus, if the input port of the packet-in and the outport are the same, the function will not push the packet-out. |
public int decrement(int offset){
return increment(-offset);
}
| Decrement the numeric badge label. If the current badge label cannot be converted to an integer value, its label will be set to "0". |
public NetworkComponent(final String name,final Network network){
super(name);
this.network=network;
init();
}
| Create a new network component. |
public Scanner(Context cx,InputBuffer input){
init(cx,true);
this.input=input;
cx.input=input;
}
| This contructor is used by Flex direct AST generation. It allows Flex to pass in a specialized InputBuffer. |
public void stopProxy(int hostNumber){
proxySet.get(currentType)[hostNumber - 1].stop();
}
| Stop proxy. |
public static PKIXCertPathValidatorResult validate(CertPath path,PKIXParameters params) throws Exception {
CertPathValidator validator=CertPathValidator.getInstance("PKIX");
return (PKIXCertPathValidatorResult)validator.validate(path,params);
}
| Perform a PKIX validation. On failure, throw an exception. |
public boolean isSslClientAuth(){
return sslClientAuth;
}
| Gets a flag indicating whether or not remote clients will be required to have a valid SSL certificate which validity will be verified with trust manager. |
public SPFRecord(Name name,int dclass,long ttl,List strings){
super(name,Type.SPF,dclass,ttl,strings);
}
| Creates a SPF Record from the given data |
void putObject(int offset,NativeObject ob){
switch (addressSize()) {
case 8:
putLong(offset,ob.address);
break;
case 4:
putInt(offset,(int)(ob.address & 0x00000000FFFFFFFF));
break;
default :
throw new InternalError("Address size not supported");
}
}
| Writes the base address of the given native object at the given offset of this native object. |
public JsonWriter endArray() throws IOException {
return close(JsonScope.EMPTY_ARRAY,JsonScope.NONEMPTY_ARRAY,"]");
}
| Ends encoding the current array. |
public void add(int index,E element){
rangeCheckForAdd(index);
ensureCapacity(size + 1);
System.arraycopy(elementData,index,elementData,index + 1,size - index);
elementData[index]=element;
size++;
}
| Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices). |
public void mouseEntered(MouseEvent event){
initiateToolTip(event);
}
| Called when the mouse enters the region of a component. This determines whether the tool tip should be shown. |
public JobDefinitionEntity createJobDefinitionEntity(String namespaceCode,String jobName,String description,String activitiId){
NamespaceEntity namespaceEntity=namespaceDao.getNamespaceByCd(namespaceCode);
if (namespaceEntity == null) {
namespaceEntity=namespaceDaoTestHelper.createNamespaceEntity(namespaceCode);
}
return createJobDefinitionEntity(namespaceEntity,jobName,description,activitiId);
}
| Creates and persists a new job definition entity. |
public boolean contains(double x,double y,double w,double h){
if (npoints <= 0 || !bounds.intersects(x,y,w,h)) {
return false;
}
updateComputingPath();
return closedPath.contains(x,y,w,h);
}
| Tests if the interior of this <code>Polygon</code> entirely contains the specified set of rectangular coordinates. |
public List<Poi> queryForAllWays(){
return poiDao.queryForAllWays();
}
| Query for all POIs who are ways. |
public boolean containsAll(float[] array){
for (int i=array.length; i-- > 0; ) {
if (!contains(array[i])) {
return false;
}
}
return true;
}
| Tests the set to determine if all of the elements in <tt>array</tt> are present. |
@Ignore public static LongArray instance(long[] value){
throw Util.makeJavaArrayWrapperException();
}
| The size of the new array. |
private void deleteBV(Matrix alpha,Matrix C,Matrix Q,double[][] basisVectors,int d,int index){
int inputDim=basisVectors[0].length;
int dMax=basisVectors.length;
double[] t_row;
double t_scalar=0;
t_scalar=alpha.getArray()[index][0];
alpha.getArray()[index][0]=alpha.getArray()[d][0];
alpha.getArray()[d][0]=t_scalar;
swapRowsAndColumns(C.getArray(),index,d);
swapRowsAndColumns(Q.getArray(),index,d);
t_row=basisVectors[index];
basisVectors[index]=basisVectors[d];
basisVectors[d]=t_row;
double alpha_star=alpha.getArray()[d][0];
double c_star=C.getArray()[d][d];
double q_star=Q.getArray()[d][d];
double[][] C_star=new double[dMax][1];
Matrix vector_C_star=new Matrix(C_star);
double[][] Q_star=new double[dMax][1];
Matrix vector_Q_star=new Matrix(Q_star);
for (int j=0; j < d; j++) {
C_star[j][0]=C.getArray()[j][d];
Q_star[j][0]=Q.getArray()[j][d];
}
alpha.minusEquals((vector_Q_star.plus(vector_C_star)).times(alpha_star / (c_star + q_star)));
C.plusEquals((vector_Q_star.times(vector_Q_star.transpose())).times(1.0 / q_star));
C.minusEquals(((vector_Q_star.plus(vector_C_star)).times((vector_Q_star.plus(vector_C_star)).transpose())).times(1.0 / (q_star + c_star)));
Q.minusEquals((vector_Q_star.times(vector_Q_star.transpose())).times(1.0 / q_star));
alpha.getArray()[d][0]=0;
for (int j=0; j <= d; j++) {
Q.getArray()[d][j]=0;
C.getArray()[d][j]=0;
Q.getArray()[j][d]=0;
C.getArray()[j][d]=0;
}
}
| Delete the given BV from the BV set by adjusting the parametrisation of the GP using eqs. (3.19), (3.21) and (3.22): alpha_t+1 = alpha^{(r)} - alpha^star / (c^star + q^star) * (Q^star + C^star) C_t+1 = C^{(r)} + Q^star * Q^star^T / q^star - (Q^star + C^star) * (Q^star + C^star)^T / (q^star + c^star) Q_t+1 = Q^{(r)} - Q^star * Q^star^T / q^star |
private byte[] crypt_raw(byte password[],byte salt[],int log_rounds){
int rounds, i, j;
int cdata[]=(int[])bf_crypt_ciphertext.clone();
int clen=cdata.length;
byte ret[];
if (log_rounds < 4 || log_rounds > 31) throw new IllegalArgumentException("Bad number of rounds");
rounds=1 << log_rounds;
if (salt.length != BCRYPT_SALT_LEN) throw new IllegalArgumentException("Bad salt length");
init_key();
ekskey(salt,password);
for (i=0; i < rounds; i++) {
key(password);
key(salt);
}
for (i=0; i < 64; i++) {
for (j=0; j < (clen >> 1); j++) encipher(cdata,j << 1);
}
ret=new byte[clen * 4];
for (i=0, j=0; i < clen; i++) {
ret[j++]=(byte)((cdata[i] >> 24) & 0xff);
ret[j++]=(byte)((cdata[i] >> 16) & 0xff);
ret[j++]=(byte)((cdata[i] >> 8) & 0xff);
ret[j++]=(byte)(cdata[i] & 0xff);
}
return ret;
}
| Perform the central password hashing step in the bcrypt scheme |
public boolean more() throws JSONException {
this.next();
if (this.end()) {
return false;
}
this.back();
return true;
}
| Determine if the source string still contains characters that next() can consume. |
@Override public boolean isActive(){
return amIActive;
}
| Used by the Whitebox GUI to tell if this plugin is still running. |
@Override public SurfaceBuilder<T> cornerClickRadius(double radius){
cornerClickRadius=radius;
return this;
}
| Sets the radius which forms a circle around a given corner, within which a corner drag gesture will be recognized. |
final void internalSetModifiers(int pmodifiers){
supportedOnlyIn2();
preValueChange(MODIFIERS_PROPERTY);
this.modifierFlags=pmodifiers;
postValueChange(MODIFIERS_PROPERTY);
}
| Internal synonym for deprecated method. Used to avoid deprecation warnings. |
public static int interleave(int x,int y){
if (((x | y) & 0xFFFF0000) != 0) throw new IllegalArgumentException("Overflow");
return part1by1(x) | (part1by1(y) << 1);
}
| Interleaves the bits of the two specified integer values (Morton code). |
public PopulationIterator(){
super();
nextIndex=0;
currentIndex=-1;
expectedModCount=modCount;
}
| Constructs a population iterator. |
public void addFooterView(View v){
addFooterView(v,null,true);
}
| Add a fixed view to appear at the bottom of the list. If addFooterView is called more than once, the views will appear in the order they were added. Views added using this call can take focus if they want. <p>NOTE: Call this before calling setAdapter. This is so ListView can wrap the supplied cursor with one that will also account for header and footer views. |
public static Range visibleRange(ContourDataset data,Range x,Range y){
Range range=null;
range=((DefaultContourDataset)data).getZValueRange(x,y);
return range;
}
| Returns the visible z-range. |
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException {
s.defaultReadObject();
}
| 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. |
public Instance calcPivot(TempNode node1,TempNode node2,Instances insts) throws Exception {
int classIdx=m_Instances.classIndex();
double[] attrVals=new double[insts.numAttributes()];
Instance temp;
double anchr1Ratio=(double)node1.points.length / (node1.points.length + node2.points.length), anchr2Ratio=(double)node2.points.length / (node1.points.length + node2.points.length);
for (int k=0; k < node1.anchor.numValues(); k++) {
if (node1.anchor.index(k) == classIdx) continue;
attrVals[k]+=node1.anchor.valueSparse(k) * anchr1Ratio;
}
for (int k=0; k < node2.anchor.numValues(); k++) {
if (node2.anchor.index(k) == classIdx) continue;
attrVals[k]+=node2.anchor.valueSparse(k) * anchr2Ratio;
}
temp=new DenseInstance(1.0,attrVals);
return temp;
}
| Calculates the centroid pivot of a node based on its two child nodes. |
private void calcMaxTextOffset(Rectangle viewRect){
if (!isColumnLayout || !isLeftToRight) {
return;
}
int offset=viewRect.x + leadingGap + checkSize.maxWidth+ afterCheckIconGap+ iconSize.maxWidth+ gap;
if (checkSize.maxWidth == 0) {
offset-=afterCheckIconGap;
}
if (iconSize.maxWidth == 0) {
offset-=gap;
}
if (offset < minTextOffset) {
offset=minTextOffset;
}
calcMaxValue(SwingUtilities2.BASICMENUITEMUI_MAX_TEXT_OFFSET,offset);
}
| Calculates maximal text offset. It is required for some L&Fs (ex: Vista L&F). The offset is meaningful only for L2R column layout. |
@Override public void onCreate(){
super.onCreate();
mConnectivityManager=(ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
}
| What to do when the application starts |
public boolean hasDebugInfo(){
for ( AbstractBlockBase<?> b : linearScanOrder()) {
for ( LIRInstruction op : getLIRforBlock(b)) {
if (op.hasState()) {
return true;
}
}
}
return false;
}
| Determines if any instruction in the LIR has debug info associated with it. |
public RealMatrix create(){
RealMatrix rotation=newIdentityMatrix();
for ( Plane plane : planes) {
double theta=plane.getTheta();
if (Double.isNaN(theta)) {
continue;
}
rotation=rotation.multiply(newRotationMatrix(plane.getFirstAxis(),plane.getSecondAxis(),theta));
}
return rotation;
}
| Returns the rotation matrix resulting from applying all 2D rotation planes and angles added to this builder. |
@Override public boolean contains(Object object){
if (object == null) {
return false;
}
for (int i=0; i < size; i++) {
if (object.equals(elements[i])) {
return true;
}
}
return false;
}
| Answers if there is an element in this queue equals to the object. |
public static boolean isNullConversion(MethodType call,MethodType recv,boolean keepInterfaces){
if (call == recv) return true;
int len=call.parameterCount();
if (len != recv.parameterCount()) return false;
for (int i=0; i < len; i++) if (!isNullConversion(call.parameterType(i),recv.parameterType(i),keepInterfaces)) return false;
return isNullConversion(recv.returnType(),call.returnType(),keepInterfaces);
}
| True if a method handle can receive a call under a slightly different method type, without moving or reformatting any stack elements. |
protected ResourceInfo newElement(int type){
ResourceInfo result=null;
switch (type) {
case IResource.FILE:
case IResource.FOLDER:
result=new ResourceInfo(type);
break;
case IResource.PROJECT:
result=new ResourceInfo(type);
break;
case IResource.ROOT:
result=new ResourceInfo(type);
break;
}
return result;
}
| Create and return a new tree element of the given type. |
boolean isYoung(){
return mYoung;
}
| Tell whether this node is consumed since last layout. |
public InlineQueryResultCachedPhotoBuilder caption(String caption){
this.caption=caption;
return this;
}
| *Optional Sets the caption to the provided value. This can be 0-200 characters in length |
public ClusterTopologyCheckedException(String msg){
super(msg);
}
| Creates new topology exception with given error message. |
public ForumPostConfig update(ForumPostConfig config){
config.addCredentials(this);
String xml=POST(this.url + "/update-forum-post",config.toXML());
Element root=parse(xml);
if (root == null) {
return null;
}
try {
config=new ForumPostConfig();
config.parseXML(root);
return config;
}
catch ( Exception exception) {
this.exception=SDKException.parseFailure(exception);
throw this.exception;
}
}
| Update the forum post. |
public void translate(final double offsetX,final double offsetY){
for ( Neuron neuron : this.getFlatNeuronList()) {
neuron.setX(neuron.getX() + offsetX);
neuron.setY(neuron.getY() + offsetY);
}
}
| Translate all neurons (the only objects with position information). |
public void saveBooleanToPreference(String key,Boolean value){
if (value == null) {
mSharedPreference.edit().remove(key).apply();
}
else {
mSharedPreference.edit().putBoolean(key,value).apply();
}
}
| Saves a boolean value under the provided key in the preference manager. If <code>value</code> is <code>null</code>, then the provided key will be removed from the preferences. |
public StateMachineTestPlanStepBuilder expectVariable(Object key,Object value){
this.expectVariables.put(key,value);
return this;
}
| Expect variable to exist in extended state variables and match with the value. |
public static Network createTestNetwork(){
double freespeed=2.7;
double capacity=500.;
double numLanes=1.;
MutableScenario scenario=(MutableScenario)ScenarioUtils.createScenario(ConfigUtils.createConfig());
Network network=(Network)scenario.getNetwork();
Node node1=NetworkUtils.createAndAddNode(network,Id.create(1,Node.class),new Coord((double)0,(double)100));
Node node2=NetworkUtils.createAndAddNode(network,Id.create(2,Node.class),new Coord((double)0,(double)200));
Node node3=NetworkUtils.createAndAddNode(network,Id.create(3,Node.class),new Coord((double)0,(double)0));
Node node4=NetworkUtils.createAndAddNode(network,Id.create(4,Node.class),new Coord((double)100,(double)100));
Node node5=NetworkUtils.createAndAddNode(network,Id.create(5,Node.class),new Coord((double)100,(double)200));
Node node6=NetworkUtils.createAndAddNode(network,Id.create(6,Node.class),new Coord((double)100,(double)0));
Node node7=NetworkUtils.createAndAddNode(network,Id.create(7,Node.class),new Coord((double)200,(double)100));
Node node8=NetworkUtils.createAndAddNode(network,Id.create(8,Node.class),new Coord((double)200,(double)200));
Node node9=NetworkUtils.createAndAddNode(network,Id.create(9,Node.class),new Coord((double)200,(double)0));
final Node fromNode=node1;
final Node toNode=node2;
final double freespeed1=freespeed;
final double capacity1=capacity;
final double numLanes1=numLanes;
NetworkUtils.createAndAddLink(network,Id.create(1,Link.class),fromNode,toNode,(double)100,freespeed1,capacity1,numLanes1);
final Node fromNode1=node2;
final Node toNode1=node1;
final double freespeed2=freespeed;
final double capacity2=capacity;
final double numLanes2=numLanes;
NetworkUtils.createAndAddLink(network,Id.create(2,Link.class),fromNode1,toNode1,(double)100,freespeed2,capacity2,numLanes2);
final Node fromNode2=node1;
final Node toNode2=node3;
final double freespeed3=freespeed;
final double capacity3=capacity;
final double numLanes3=numLanes;
NetworkUtils.createAndAddLink(network,Id.create(3,Link.class),fromNode2,toNode2,(double)100,freespeed3,capacity3,numLanes3);
final Node fromNode3=node3;
final Node toNode3=node1;
final double freespeed4=freespeed;
final double capacity4=capacity;
final double numLanes4=numLanes;
NetworkUtils.createAndAddLink(network,Id.create(4,Link.class),fromNode3,toNode3,(double)100,freespeed4,capacity4,numLanes4);
final Node fromNode4=node1;
final Node toNode4=node4;
final double freespeed5=freespeed;
final double capacity5=capacity;
final double numLanes5=numLanes;
NetworkUtils.createAndAddLink(network,Id.create(5,Link.class),fromNode4,toNode4,(double)100,freespeed5,capacity5,numLanes5);
final Node fromNode5=node4;
final Node toNode5=node1;
final double freespeed6=freespeed;
final double capacity6=capacity;
final double numLanes6=numLanes;
NetworkUtils.createAndAddLink(network,Id.create(6,Link.class),fromNode5,toNode5,(double)100,freespeed6,capacity6,numLanes6);
final Node fromNode6=node4;
final Node toNode6=node5;
final double freespeed7=freespeed;
final double capacity7=capacity;
final double numLanes7=numLanes;
NetworkUtils.createAndAddLink(network,Id.create(7,Link.class),fromNode6,toNode6,(double)100,freespeed7,capacity7,numLanes7);
final Node fromNode7=node5;
final Node toNode7=node4;
final double freespeed8=freespeed;
final double capacity8=capacity;
final double numLanes8=numLanes;
NetworkUtils.createAndAddLink(network,Id.create(8,Link.class),fromNode7,toNode7,(double)100,freespeed8,capacity8,numLanes8);
final Node fromNode8=node4;
final Node toNode8=node6;
final double freespeed9=freespeed;
final double capacity9=capacity;
final double numLanes9=numLanes;
NetworkUtils.createAndAddLink(network,Id.create(9,Link.class),fromNode8,toNode8,(double)100,freespeed9,capacity9,numLanes9);
final Node fromNode9=node6;
final Node toNode9=node4;
final double freespeed10=freespeed;
final double capacity10=capacity;
final double numLanes10=numLanes;
NetworkUtils.createAndAddLink(network,Id.create(10,Link.class),fromNode9,toNode9,(double)100,freespeed10,capacity10,numLanes10);
final Node fromNode10=node4;
final Node toNode10=node7;
final double freespeed11=freespeed;
final double capacity11=capacity;
final double numLanes11=numLanes;
NetworkUtils.createAndAddLink(network,Id.create(11,Link.class),fromNode10,toNode10,(double)100,freespeed11,capacity11,numLanes11);
final Node fromNode11=node7;
final Node toNode11=node4;
final double freespeed12=freespeed;
final double capacity12=capacity;
final double numLanes12=numLanes;
NetworkUtils.createAndAddLink(network,Id.create(12,Link.class),fromNode11,toNode11,(double)100,freespeed12,capacity12,numLanes12);
final Node fromNode12=node5;
final Node toNode12=node8;
final double freespeed13=freespeed;
final double capacity13=capacity;
final double numLanes13=numLanes;
NetworkUtils.createAndAddLink(network,Id.create(13,Link.class),fromNode12,toNode12,(double)100,freespeed13,capacity13,numLanes13);
final Node fromNode13=node8;
final Node toNode13=node5;
final double freespeed14=freespeed;
final double capacity14=capacity;
final double numLanes14=numLanes;
NetworkUtils.createAndAddLink(network,Id.create(14,Link.class),fromNode13,toNode13,(double)100,freespeed14,capacity14,numLanes14);
final Node fromNode14=node6;
final Node toNode14=node9;
final double freespeed15=freespeed;
final double capacity15=capacity;
final double numLanes15=numLanes;
NetworkUtils.createAndAddLink(network,Id.create(15,Link.class),fromNode14,toNode14,(double)100,freespeed15,capacity15,numLanes15);
final Node fromNode15=node9;
final Node toNode15=node6;
final double freespeed16=freespeed;
final double capacity16=capacity;
final double numLanes16=numLanes;
NetworkUtils.createAndAddLink(network,Id.create(16,Link.class),fromNode15,toNode15,(double)100,freespeed16,capacity16,numLanes16);
return network;
}
| This method creates a test network. It is used for example in PtMatrixTest.java to test the pt simulation in MATSim. The network has 9 nodes and 8 links (see the sketch below). |
public static <T>Set<T> emptySet(){
return java.util.Collections.emptySet();
}
| Create an empty immutable set. |
@Override public void connectionStateChanged(State state){
log.info("Site info connection state changed to {}",state);
if (state.equals(State.CONNECTED)) {
log.info("Curator (re)connected. Waking up the vdc manager...");
wakeup();
}
}
| called when connection state changed. |
@Inline @Interruptible public static int[] newContiguousIntArray(int n){
return new int[n];
}
| Allocate a contiguous int array |
public static boolean ignoreWARCRecord(WARCWritable value) throws IOException {
int contentLength=value.getRecord().getHeader().getContentLength();
if (contentLength >= 10000000) {
return true;
}
if (!value.getRecord().isContentApplicationHttpResponse()) {
return true;
}
String httpHeaderText=value.getRecord().getHTTPHeaders();
if (httpHeaderText == null) {
return true;
}
String contentType=WARCRecord.extractHTTPHeaderContentType(httpHeaderText);
if (!ALLOWED_CONTENT_TYPES.contains(contentType)) {
return true;
}
return false;
}
| Checks whether the given WARC record should be ignored; this applies for documents longer than 10 MB and documents that are not text/html |
public void back(){
if (--pos == -1) {
pos=0;
}
}
| Unreads the most recent character of input. If no input characters have been read, the input is unchanged. |
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
this.thermometerStroke=SerialUtilities.readStroke(stream);
this.thermometerPaint=SerialUtilities.readPaint(stream);
this.valuePaint=SerialUtilities.readPaint(stream);
this.mercuryPaint=SerialUtilities.readPaint(stream);
this.subrangeIndicatorStroke=SerialUtilities.readStroke(stream);
this.rangeIndicatorStroke=SerialUtilities.readStroke(stream);
this.subrangePaint=new Paint[3];
for (int i=0; i < 3; i++) {
this.subrangePaint[i]=SerialUtilities.readPaint(stream);
}
if (this.rangeAxis != null) {
this.rangeAxis.addChangeListener(this);
}
}
| Provides serialization support. |
private void generatePrivacyKeyPair(boolean clientMode) throws IOException, UnsupportedEncodingException, NoSuchAlgorithmException, SaslException {
byte[] ccmagic=CLIENT_CONF_MAGIC.getBytes(encoding);
byte[] scmagic=SVR_CONF_MAGIC.getBytes(encoding);
MessageDigest md5=MessageDigest.getInstance("MD5");
int n;
if (negotiatedCipher.equals(CIPHER_TOKENS[RC4_40])) {
n=5;
}
else if (negotiatedCipher.equals(CIPHER_TOKENS[RC4_56])) {
n=7;
}
else {
n=16;
}
byte[] keyBuffer=new byte[n + ccmagic.length];
System.arraycopy(H_A1,0,keyBuffer,0,n);
System.arraycopy(ccmagic,0,keyBuffer,n,ccmagic.length);
md5.update(keyBuffer);
byte[] Kcc=md5.digest();
System.arraycopy(scmagic,0,keyBuffer,n,scmagic.length);
md5.update(keyBuffer);
byte[] Kcs=md5.digest();
if (logger.isLoggable(Level.FINER)) {
traceOutput(DP_CLASS_NAME,"generatePrivacyKeyPair","DIGEST24:Kcc: ",Kcc);
traceOutput(DP_CLASS_NAME,"generatePrivacyKeyPair","DIGEST25:Kcs: ",Kcs);
}
byte[] myKc;
byte[] peerKc;
if (clientMode) {
myKc=Kcc;
peerKc=Kcs;
}
else {
myKc=Kcs;
peerKc=Kcc;
}
try {
SecretKey encKey;
SecretKey decKey;
if (negotiatedCipher.indexOf(CIPHER_TOKENS[RC4]) > -1) {
encCipher=Cipher.getInstance("RC4");
decCipher=Cipher.getInstance("RC4");
encKey=new SecretKeySpec(myKc,"RC4");
decKey=new SecretKeySpec(peerKc,"RC4");
encCipher.init(Cipher.ENCRYPT_MODE,encKey);
decCipher.init(Cipher.DECRYPT_MODE,decKey);
}
else if ((negotiatedCipher.equals(CIPHER_TOKENS[DES])) || (negotiatedCipher.equals(CIPHER_TOKENS[DES3]))) {
String cipherFullname, cipherShortname;
if (negotiatedCipher.equals(CIPHER_TOKENS[DES])) {
cipherFullname="DES/CBC/NoPadding";
cipherShortname="des";
}
else {
cipherFullname="DESede/CBC/NoPadding";
cipherShortname="desede";
}
encCipher=Cipher.getInstance(cipherFullname);
decCipher=Cipher.getInstance(cipherFullname);
encKey=makeDesKeys(myKc,cipherShortname);
decKey=makeDesKeys(peerKc,cipherShortname);
IvParameterSpec encIv=new IvParameterSpec(myKc,8,8);
IvParameterSpec decIv=new IvParameterSpec(peerKc,8,8);
encCipher.init(Cipher.ENCRYPT_MODE,encKey,encIv);
decCipher.init(Cipher.DECRYPT_MODE,decKey,decIv);
if (logger.isLoggable(Level.FINER)) {
traceOutput(DP_CLASS_NAME,"generatePrivacyKeyPair","DIGEST26:" + negotiatedCipher + " IVcc: ",encIv.getIV());
traceOutput(DP_CLASS_NAME,"generatePrivacyKeyPair","DIGEST27:" + negotiatedCipher + " IVcs: ",decIv.getIV());
traceOutput(DP_CLASS_NAME,"generatePrivacyKeyPair","DIGEST28:" + negotiatedCipher + " encryption key: ",encKey.getEncoded());
traceOutput(DP_CLASS_NAME,"generatePrivacyKeyPair","DIGEST29:" + negotiatedCipher + " decryption key: ",decKey.getEncoded());
}
}
}
catch ( InvalidKeySpecException e) {
throw new SaslException("DIGEST-MD5: Unsupported key " + "specification used.",e);
}
catch ( InvalidAlgorithmParameterException e) {
throw new SaslException("DIGEST-MD5: Invalid cipher " + "algorithem parameter used to create cipher instance",e);
}
catch ( NoSuchPaddingException e) {
throw new SaslException("DIGEST-MD5: Unsupported " + "padding used for chosen cipher",e);
}
catch ( InvalidKeyException e) {
throw new SaslException("DIGEST-MD5: Invalid data " + "used to initialize keys",e);
}
}
| Generates client-server and server-client keys to encrypt and decrypt messages. Also generates IVs for DES ciphers. |
public static double calculateKilometers(double meters){
double kilometers=meters * 0.001;
return kilometers;
}
| The calculateKilometers method displays the kilometers that are equivalent to a specified number of meters. |
protected void hitOrDraw(Graphics2D graphics,DrawInfo2D info,Bag putInHere){
}
| Instead of overriding the draw and hitObjects methods, you can optionally override this method to provide <i>both</i> the draw(...) and hitObjects(...) functionality in a single method, as it's common that these two methods have nearly identical code. You should test which operation to do based on whether or not graphics is null (if it is, you're hitting, else you're drawing). |
public static void v(String tag,String msg,Object... args){
if (sLevel > LEVEL_VERBOSE) {
return;
}
if (args.length > 0) {
msg=String.format(msg,args);
}
Log.v(tag,msg);
}
| Send a VERBOSE log message. |
@SuppressWarnings("unchecked") public void updateStory(final String message,final String name,final String caption,final String description,final String link,final String picture,final SocialAuthListener<Integer> listener) throws UnsupportedEncodingException {
try {
if (getCurrentProvider().getProviderId().equalsIgnoreCase("facebook")) {
final Map<String,String> params=new HashMap<>();
params.put("name",name);
params.put("caption",caption);
params.put("description",description);
params.put("link",link);
params.put("picture",picture);
storyResult="message=" + URLEncoder.encode(message,Constants.ENCODING) + "&access_token"+ "="+ getCurrentProvider().getAccessGrant().getKey();
new StoryTask(listener).execute(params);
}
else {
Log.d("SocialAuthAdapter","Provider Not Supported");
}
}
catch ( NullPointerException e) {
e.printStackTrace();
Log.d("SocialAuthAdapter","Provider Not Supported");
}
}
| Method to share message with link preview on facebook only |
public BitVector(int size){
this.size=size;
if ((size % 8) > 0) {
size=(size / 8) + 1;
}
else {
size=(size / 8);
}
data=new byte[size];
}
| Constructs a new <tt>BitVector</tt> instance with a given size. <p> |
public static boolean isPowerOfTwo(int value){
return value != 0 && (value & (value - 1)) == 0;
}
| Indicates whether a specified value is a power of two. |
public User checkEmailOrLoginAndPsw(String loginOrEmail,String psw) throws NotActivatedUserException, BannedUserException, Exception {
UserExt user=universal.selectOne(new SelectUserByLoginOrEmail(loginOrEmail));
if (user == null) return null;
checkStatus(user,loginOrEmail);
return equalsPsw(user,psw) ? user.getUser() : null;
}
| Try find user by login or email and check status and psw |
public static final byte[] decodeUrl(byte[] bytes) throws DecoderException {
if (bytes == null) {
return null;
}
ByteArrayOutputStream buffer=new ByteArrayOutputStream();
for (int i=0; i < bytes.length; i++) {
int b=bytes[i];
if (b == '+') {
buffer.write(' ');
}
else if (b == '%') {
try {
int u=Character.digit((char)bytes[++i],16);
int l=Character.digit((char)bytes[++i],16);
if (u == -1 || l == -1) {
throw new DecoderException("Invalid URL encoding");
}
buffer.write((char)((u << 4) + l));
}
catch ( ArrayIndexOutOfBoundsException e) {
throw new DecoderException("Invalid URL encoding");
}
}
else {
buffer.write(b);
}
}
return buffer.toByteArray();
}
| Decodes an array of URL safe 7-bit characters into an array of original bytes. Escaped characters are converted back to their original representation. |
public void addAnimation(ComponentAnimation an){
anims.add(an);
Display.getInstance().notifyDisplay();
}
| Adds the animation to the end to the animation queue |
public static String buildSuccessOutput(AsicContainerVerifier verifier){
StringBuilder builder=new StringBuilder();
builder.append("Verification successful.\n");
builder.append("Signer\n");
builder.append(" Certificate:\n");
appendCert(builder,verifier.getSignerCert());
builder.append(" ID: " + verifier.getSignerName() + "\n");
builder.append("OCSP response\n");
builder.append(" Signed by:\n");
appendCert(builder,verifier.getOcspCert());
builder.append(" Produced at: " + verifier.getOcspDate() + "\n");
builder.append("Timestamp\n");
builder.append(" Signed by:\n");
appendCert(builder,verifier.getTimestampCert());
builder.append(" Date: " + verifier.getTimestampDate() + "\n");
verifier.getAttachmentHashes().forEach(null);
return builder.toString();
}
| Generates the output in case of successful verification. |
private boolean compareString(Object valueObj,String value1S,String value2S){
m_numeric=false;
String valueObjS=String.valueOf(valueObj);
String op=getOperation();
if (OPERATION_Eq.equals(op)) return valueObjS.compareTo(value1S) == 0;
else if (OPERATION_Gt.equals(op)) return valueObjS.compareTo(value1S) > 0;
else if (OPERATION_GtEq.equals(op)) return valueObjS.compareTo(value1S) >= 0;
else if (OPERATION_Le.equals(op)) return valueObjS.compareTo(value1S) < 0;
else if (OPERATION_LeEq.equals(op)) return valueObjS.compareTo(value1S) <= 0;
else if (OPERATION_Like.equals(op)) return valueObjS.compareTo(value1S) == 0;
else if (OPERATION_NotEq.equals(op)) return valueObjS.compareTo(value1S) != 0;
else if (OPERATION_Sql.equals(op)) throw new IllegalArgumentException("SQL not Implemented");
else if (OPERATION_X.equals(op)) {
if (valueObjS.compareTo(value1S) < 0) return false;
return valueObjS.compareTo(value2S) <= 0;
}
throw new IllegalArgumentException("Unknown Operation=" + op);
}
| Compare String |
static private String readFromFile(final File file) throws IOException {
final LineNumberReader r=new LineNumberReader(new FileReader(file));
try {
final StringBuilder sb=new StringBuilder();
String s;
while ((s=r.readLine()) != null) {
if (r.getLineNumber() > 1) sb.append("\n");
sb.append(s);
}
return sb.toString();
}
finally {
r.close();
}
}
| Read the contents of a file. <p> Note: This makes default platform assumptions about the encoding of the file. |
public void destroy(){
log.fine("");
}
| Clean up resources |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.