code
stringlengths 10
174k
| nl
stringlengths 3
129k
|
---|---|
public JFXSpinner(){
super();
getStyleClass().add(DEFAULT_STYLE_CLASS);
initialize();
}
| creates a spinner node |
public static PlatformUser createAdmin(DataService mgr,String userId,Organization org) throws NonUniqueBusinessKeyException {
PlatformUser user=Organizations.createUserForOrg(mgr,org,true,userId);
return user;
}
| Creates a new platform user with the given user id. The user is assigned the administrator role. |
public static DirichletBayesImWrapper serializableInstance(){
return new DirichletBayesImWrapper(BayesPmWrapper.serializableInstance(),new Parameters());
}
| Generates a simple exemplar of this class to test serialization. |
public String applyMask(String value){
return formatter.applyMask(displayHints.getMask(),value);
}
| Applies mask on a given string |
private static boolean hasMatchingAncestor(Context context,AccessibilityNodeInfoCompat node,NodeFilter filter){
if (node == null) {
return false;
}
final AccessibilityNodeInfoCompat result=getMatchingAncestor(context,node,filter);
if (result == null) {
return false;
}
result.recycle();
return true;
}
| Check whether a given node has a scrollable ancestor. |
private boolean doesUserNotHavePasswordAndNeedsIt(final User editedUser){
return !editedUser.getIsSingleUser() && editedUser.getPassword() == null;
}
| Returns true if the user does not have a password and needs it. |
public SwingTerminal(TerminalSize initialTerminalSize,TerminalEmulatorDeviceConfiguration deviceConfiguration,SwingTerminalFontConfiguration fontConfiguration,TerminalEmulatorColorConfiguration colorConfiguration,TerminalScrollController scrollController){
if (deviceConfiguration == null) {
deviceConfiguration=TerminalEmulatorDeviceConfiguration.getDefault();
}
if (fontConfiguration == null) {
fontConfiguration=SwingTerminalFontConfiguration.getDefault();
}
if (colorConfiguration == null) {
colorConfiguration=TerminalEmulatorColorConfiguration.getDefault();
}
terminalImplementation=new SwingTerminalImplementation(this,fontConfiguration,initialTerminalSize,deviceConfiguration,colorConfiguration,scrollController);
}
| Creates a new SwingTerminal component using custom settings and a custom scroll controller. The scrolling controller will be notified when the terminal's history size grows and will be called when this class needs to figure out the current scrolling position. |
public Double2D tv(final Double2D d1,final Double2D d2){
return new Double2D(tdx(d1.x,d2.x),tdy(d1.y,d2.y));
}
| Minimum Toroidal difference vector between two points. This subtracts the second point from the first and produces the minimum-length such subtractive vector, considering wrap-around possibilities as well |
static public String normalizeToEncoding(String origString_,Charset encoding_){
String normString=origString_;
CharsetEncoder encoder=encoding_.newEncoder();
if (!encoder.canEncode(origString_)) {
final int length=origString_.length();
char[] normSeq=new char[(origString_.length())];
int charNum=0;
for (int offset=0; offset < length; ) {
Pair<Character,Integer> replacement=normalizeCodepoint(origString_,encoding_,offset);
Character replacedChar=replacement.getFirst();
int codepoint=replacement.getSecond();
if (null != replacedChar) {
normSeq[charNum]=replacedChar;
charNum++;
}
offset+=Character.charCount(codepoint);
}
normString=new String(normSeq);
}
return normString;
}
| tries to normalize string to specified encoding. The number of characters returned should be the same, and tokens should remain contiguous in the output; non-recognized characters will be substituted for *something*. |
@DSGenerator(tool_name="Doppelganger",tool_version="2.0",generated_on="2014-03-24 16:07:26.282 -0400",hash_original_method="3DD1F54AED9C9361A6A54B10F128DAE9",hash_generated_method="3FB8B09BDF3878CD331AF8E6EEE97886") public boolean isTetheringOn(){
mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM,"Need BLUETOOTH permission");
synchronized (mBluetoothPanProfileHandler) {
return mBluetoothPanProfileHandler.isTetheringOn();
}
}
| Handlers for PAN Profile |
@Override public final void release(final K ctx){
if (ctx.usage == USAGE_CLQ) {
ctxQueue.offer(getOrCreateReference(ctx));
}
}
| Restore the given ReentrantContext instance for reuse |
@Override protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec){
super.onMeasure(widthMeasureSpec,heightMeasureSpec);
int widthMode=MeasureSpec.getMode(widthMeasureSpec);
int widthSize=MeasureSpec.getSize(widthMeasureSpec);
int heightMode=MeasureSpec.getMode(heightMeasureSpec);
int heightSize=MeasureSpec.getSize(heightMeasureSpec);
if (widthMode == MeasureSpec.AT_MOST && heightMode == MeasureSpec.AT_MOST) {
setMeasuredDimension(defaultWidth,defaultWidth);
}
else if (widthMode == MeasureSpec.AT_MOST) {
setMeasuredDimension(defaultWidth,heightSize);
}
else if (heightMode == MeasureSpec.AT_MOST) {
setMeasuredDimension(widthSize,defaultWidth);
}
}
| ColorButton is not support self-define padding |
public ZoneRulesBuilder addWindow(ZoneOffset standardOffset,LocalDateTime until,TimeDefinition untilDefinition){
Objects.requireNonNull(standardOffset,"standardOffset");
Objects.requireNonNull(until,"until");
Objects.requireNonNull(untilDefinition,"untilDefinition");
TZWindow window=new TZWindow(standardOffset,until,untilDefinition);
if (windowList.size() > 0) {
TZWindow previous=windowList.get(windowList.size() - 1);
window.validateWindowOrder(previous);
}
windowList.add(window);
return this;
}
| Adds a window to the builder that can be used to filter a set of rules. <p> This method defines and adds a window to the zone where the standard offset is specified. The window limits the effect of subsequent additions of transition rules or fixed savings. If neither rules or fixed savings are added to the window then the window will default to no savings. <p> Each window must be added sequentially, as the start instant of the window is derived from the until instant of the previous window. |
public void storePersistentState(Editor editor,String prefix){
editor.putString(prefix + ".hash",String.valueOf(mEditText.getText().toString().hashCode()));
editor.putInt(prefix + ".maxSize",mEditHistory.mmMaxHistorySize);
editor.putInt(prefix + ".position",mEditHistory.mmPosition);
editor.putInt(prefix + ".size",mEditHistory.mmHistory.size());
int i=0;
for ( EditItem ei : mEditHistory.mmHistory) {
String pre=prefix + "." + i;
editor.putInt(pre + ".start",ei.mmStart);
editor.putString(pre + ".before",ei.mmBefore.toString());
editor.putString(pre + ".after",ei.mmAfter.toString());
i++;
}
}
| Store preferences. |
public CoordinateSystem(double minX,double maxX,double minY,double maxY){
this(minX,maxX,minY,maxY,AxisDirection.EAST,AxisDirection.SOUTH);
}
| Uses Java graphics default axis orientation: x increases to the right, y increases to the bottom. |
public static ErThrowableInformation fromThrowableProxy(ThrowableProxy tp){
ErThrowableInformation ert=new ErThrowableInformation();
ert.setThrowable(ErThrowable.fromThrowableProxy(tp));
String[] rep=new String[tp.getExtendedStackTrace().length + 1];
rep[0]=tp.toString();
for (int i=0; i < rep.length - 1; i++) {
rep[i + 1]=tp.getExtendedStackTrace()[i].toString();
}
ert.setRep(rep);
return ert;
}
| Make from org.apache.logging.log4j.core.impl.ThrowableProxy (Log4j 2.x) |
public static boolean isNotEmpty(final short[] array){
return array != null && array.length != 0;
}
| <p>Checks if an array of primitive shorts is not empty or not <code>null</code>.</p> |
public TextDrawable(TextView tv,boolean bindToViewsText,boolean bindToViewsPaint){
this(tv,tv.getText().toString(),false,false);
}
| Create a TextDrawable. This uses the given TextView to initialize paint and the text that will be drawn. |
@Override public boolean equals(Object itemSet){
if ((itemSet == null) || !(itemSet.getClass().equals(this.getClass()))) {
return false;
}
if (m_items.length != ((ItemSet)itemSet).m_items.length) {
return false;
}
for (int i=0; i < m_items.length; i++) {
if (m_items[i] != ((ItemSet)itemSet).m_items[i]) {
return false;
}
}
return true;
}
| Tests if two item sets are equal. |
public static void main(final String[] args){
DOMTestCase.doMain(textsplittextnomodificationallowederr.class,args);
}
| Runs this test from the command line. |
private void assertResultSet(boolean ordered,ResultSet rs,String[][] data) throws SQLException {
int len=rs.getMetaData().getColumnCount();
int rows=data.length;
if (rows == 0) {
if (rs.next()) {
fail("testResultSet expected rowCount:" + rows + " got:0");
}
}
int len2=data[0].length;
if (len < len2) {
fail("testResultSet expected columnCount:" + len2 + " got:"+ len);
}
for (int i=0; i < rows; i++) {
if (!rs.next()) {
fail("testResultSet expected rowCount:" + rows + " got:"+ i);
}
String[] row=getData(rs,len);
if (ordered) {
String[] good=data[i];
if (!testRow(good,row,good.length)) {
fail("testResultSet row not equal, got:\n" + formatRow(row) + "\n"+ formatRow(good));
}
}
else {
boolean found=false;
for (int j=0; j < rows; j++) {
String[] good=data[i];
if (testRow(good,row,good.length)) {
found=true;
break;
}
}
if (!found) {
fail("testResultSet no match for row:" + formatRow(row));
}
}
}
if (rs.next()) {
String[] row=getData(rs,len);
fail("testResultSet expected rowcount:" + rows + " got:>="+ (rows + 1)+ " data:"+ formatRow(row));
}
}
| Check if a result set contains the expected data. |
public static String convertSystemNameToAlternate(String systemName){
if (!validSystemNameFormat(systemName,systemName.charAt(1))) {
return "";
}
Matcher matcher=getAllPattern().matcher(systemName);
matcher.matches();
if (matcher.group(7) != null) {
int num=Integer.valueOf(matcher.group(7)).intValue();
return matcher.group(1) + matcher.group(2) + (num / 1000)+ "B"+ (num % 1000);
}
else {
int node=Integer.valueOf(matcher.group(4)).intValue();
int bit=Integer.valueOf(matcher.group(6)).intValue();
return matcher.group(1) + matcher.group(2) + node+ "B"+ bit;
}
}
| Public static method to convert any format system name for the alternate format (nnBnn) If the supplied system name does not have a valid format, or if there is no representation in the alternate naming scheme, an empty string is returned. |
@Override public void run(){
amIActive=true;
String inputFile;
String outputHeader;
String fieldName;
int fieldNum=0;
String assignmentType;
String baseFileHeader="not specified";
double backgroundValue=0;
int row, col;
double xCoord, yCoord, value, z;
int progress;
double cellSize=-1.0;
int rows;
int cols;
double noData=-32768.0;
double east;
double west;
double north;
double south;
DataType dataType=WhiteboxRasterBase.DataType.INTEGER;
Object[] data;
boolean useRecID=false;
if (args.length <= 0) {
showFeedback("Plugin parameters have not been set.");
return;
}
inputFile=args[0];
outputHeader=args[1];
fieldName=args[2];
assignmentType=args[3].toLowerCase();
if (args[4].toLowerCase().contains("nodata")) {
backgroundValue=noData;
}
else {
backgroundValue=Double.parseDouble(args[4]);
}
if (!args[5].toLowerCase().contains("not specified")) {
cellSize=Double.parseDouble(args[5]);
}
baseFileHeader=args[6];
if ((inputFile == null) || (outputHeader == null)) {
showFeedback("One or more of the input parameters have not been set properly.");
return;
}
try {
ShapeFile input=new ShapeFile(inputFile);
if (input.getShapeType() != ShapeType.POINT && input.getShapeType() != ShapeType.POINTZ && input.getShapeType() != ShapeType.POINTM && input.getShapeType() != ShapeType.MULTIPOINT && input.getShapeType() != ShapeType.MULTIPOINTZ && input.getShapeType() != ShapeType.MULTIPOINTM) {
showFeedback("The input shapefile must be of a 'point' data type.");
return;
}
AttributeTable reader=input.getAttributeTable();
int numberOfFields=reader.getFieldCount();
for (int i=0; i < numberOfFields; i++) {
DBFField field=reader.getField(i);
if (field.getName().equals(fieldName)) {
fieldNum=i;
if (field.getDataType() == DBFField.DBFDataType.NUMERIC || field.getDataType() == DBFField.DBFDataType.FLOAT) {
if (field.getDecimalCount() == 0) {
dataType=WhiteboxRasterBase.DataType.INTEGER;
}
else {
dataType=WhiteboxRasterBase.DataType.FLOAT;
}
}
else {
useRecID=true;
}
}
}
if (fieldNum < 0) {
useRecID=true;
}
WhiteboxRaster output;
if ((cellSize > 0) || ((cellSize < 0) & (baseFileHeader.toLowerCase().contains("not specified")))) {
if ((cellSize < 0) & (baseFileHeader.toLowerCase().contains("not specified"))) {
cellSize=Math.min((input.getyMax() - input.getyMin()) / 500.0,(input.getxMax() - input.getxMin()) / 500.0);
}
north=input.getyMax() + cellSize / 2.0;
south=input.getyMin() - cellSize / 2.0;
east=input.getxMax() + cellSize / 2.0;
west=input.getxMin() - cellSize / 2.0;
rows=(int)(Math.ceil((north - south) / cellSize));
cols=(int)(Math.ceil((east - west) / cellSize));
east=west + cols * cellSize;
south=north - rows * cellSize;
output=new WhiteboxRaster(outputHeader,north,south,east,west,rows,cols,WhiteboxRasterBase.DataScale.CONTINUOUS,dataType,backgroundValue,noData);
}
else {
output=new WhiteboxRaster(outputHeader,"rw",baseFileHeader,dataType,backgroundValue);
rows=output.getNumberRows();
cols=output.getNumberColumns();
}
double[][] geometry;
if (assignmentType.equals("minimum")) {
for ( ShapeFileRecord record : input.records) {
data=reader.nextRecord();
geometry=getXYFromShapefileRecord(record);
for (int i=0; i < geometry.length; i++) {
xCoord=geometry[i][0];
yCoord=geometry[i][1];
row=output.getRowFromYCoordinate(yCoord);
col=output.getColumnFromXCoordinate(xCoord);
if (row < rows && row >= 0 && col < cols && col >= 0) {
row=output.getRowFromYCoordinate(yCoord);
col=output.getColumnFromXCoordinate(xCoord);
value=Double.valueOf(data[fieldNum].toString());
z=output.getValue(row,col);
if (z == backgroundValue || z < value) {
output.setValue(row,col,value);
}
}
}
if (cancelOp) {
cancelOperation();
return;
}
progress=(int)((100.0 * record.getRecordNumber()) / input.getNumberOfRecords());
updateProgress(progress);
}
}
else if (assignmentType.equals("maximum")) {
for ( ShapeFileRecord record : input.records) {
data=reader.nextRecord();
geometry=getXYFromShapefileRecord(record);
for (int i=0; i < geometry.length; i++) {
xCoord=geometry[i][0];
yCoord=geometry[i][1];
row=output.getRowFromYCoordinate(yCoord);
col=output.getColumnFromXCoordinate(xCoord);
if (row < rows && row >= 0 && col < cols && col >= 0) {
row=output.getRowFromYCoordinate(yCoord);
col=output.getColumnFromXCoordinate(xCoord);
if (!useRecID) {
value=Double.valueOf(data[fieldNum].toString());
}
else {
value=record.getRecordNumber();
}
z=output.getValue(row,col);
if (z == backgroundValue || z > value) {
output.setValue(row,col,value);
}
}
}
if (cancelOp) {
cancelOperation();
return;
}
progress=(int)((100.0 * record.getRecordNumber()) / input.getNumberOfRecords());
updateProgress(progress);
}
}
else if (assignmentType.equals("sum")) {
for ( ShapeFileRecord record : input.records) {
data=reader.nextRecord();
geometry=getXYFromShapefileRecord(record);
for (int i=0; i < geometry.length; i++) {
xCoord=geometry[i][0];
yCoord=geometry[i][1];
row=output.getRowFromYCoordinate(yCoord);
col=output.getColumnFromXCoordinate(xCoord);
if (row < rows && row >= 0 && col < cols && col >= 0) {
row=output.getRowFromYCoordinate(yCoord);
col=output.getColumnFromXCoordinate(xCoord);
if (!useRecID) {
value=Double.valueOf(data[fieldNum].toString());
}
else {
value=record.getRecordNumber();
}
z=output.getValue(row,col);
if (z == backgroundValue) {
output.setValue(row,col,value);
}
else {
output.setValue(row,col,value + z);
}
}
}
if (cancelOp) {
cancelOperation();
return;
}
progress=(int)((100.0 * record.getRecordNumber()) / input.getNumberOfRecords());
updateProgress(progress);
}
}
else if (assignmentType.equals("first")) {
for ( ShapeFileRecord record : input.records) {
data=reader.nextRecord();
geometry=getXYFromShapefileRecord(record);
for (int i=0; i < geometry.length; i++) {
xCoord=geometry[i][0];
yCoord=geometry[i][1];
row=output.getRowFromYCoordinate(yCoord);
col=output.getColumnFromXCoordinate(xCoord);
if (row < rows && row >= 0 && col < cols && col >= 0) {
row=output.getRowFromYCoordinate(yCoord);
col=output.getColumnFromXCoordinate(xCoord);
if (!useRecID) {
value=Double.valueOf(data[fieldNum].toString());
}
else {
value=record.getRecordNumber();
}
z=output.getValue(row,col);
if (z == backgroundValue) {
output.setValue(row,col,value);
}
}
}
if (cancelOp) {
cancelOperation();
return;
}
progress=(int)((100.0 * record.getRecordNumber()) / input.getNumberOfRecords());
updateProgress(progress);
}
}
else if (assignmentType.equals("last")) {
for ( ShapeFileRecord record : input.records) {
data=reader.nextRecord();
geometry=getXYFromShapefileRecord(record);
for (int i=0; i < geometry.length; i++) {
xCoord=geometry[i][0];
yCoord=geometry[i][1];
row=output.getRowFromYCoordinate(yCoord);
col=output.getColumnFromXCoordinate(xCoord);
if (row < rows && row >= 0 && col < cols && col >= 0) {
row=output.getRowFromYCoordinate(yCoord);
col=output.getColumnFromXCoordinate(xCoord);
if (!useRecID) {
value=Double.valueOf(data[fieldNum].toString());
}
else {
value=record.getRecordNumber();
}
output.setValue(row,col,value);
}
}
if (cancelOp) {
cancelOperation();
return;
}
progress=(int)((100.0 * record.getRecordNumber()) / input.getNumberOfRecords());
updateProgress(progress);
}
}
else if (assignmentType.equals("mean")) {
}
else if (assignmentType.equals("range")) {
}
output.addMetadataEntry("Created by the " + getDescriptiveName() + " tool.");
output.addMetadataEntry("Created on " + new Date());
output.flush();
output.close();
returnData(outputHeader);
}
catch ( OutOfMemoryError oe) {
myHost.showFeedback("An out-of-memory error has occurred during operation.");
}
catch ( Exception e) {
myHost.showFeedback("An error has occurred during operation. See log file for details.");
myHost.logException("Error in " + getDescriptiveName(),e);
}
finally {
updateProgress("Progress: ",0);
amIActive=false;
myHost.pluginComplete();
}
}
| Used to execute this plugin tool. |
static protected void runWatchDog(){
boolean warned=false;
logFine(WATCHDOG_NAME,"Starting");
try {
basicLoadEmergencyClasses();
}
catch ( ExceptionInInitializerError e) {
boolean noSurprise=false;
Throwable cause=e.getCause();
if (cause != null) {
if (cause instanceof IllegalStateException) {
String msg=cause.getMessage();
if (msg.indexOf("Shutdown in progress") >= 0) {
noSurprise=true;
}
}
}
if (!noSurprise) {
logWarning(WATCHDOG_NAME,"Unable to load GemFire classes: ",e);
}
return;
}
catch ( CancelException e) {
}
catch ( Throwable t) {
logWarning(WATCHDOG_NAME,"Unable to initialize watchdog",t);
return;
}
for (; ; ) {
if (stopping) {
return;
}
try {
if (isCacheClosing) {
break;
}
synchronized (failureSync) {
if (stopping) {
return;
}
logFine(WATCHDOG_NAME,"Waiting for disaster");
try {
failureSync.wait(WATCHDOG_WAIT * 1000);
}
catch ( InterruptedException e) {
}
if (stopping) {
return;
}
}
if (failureActionCompleted) {
logInfo(WATCHDOG_NAME,"all actions completed; exiting");
}
if (failure == null) {
logFine(WATCHDOG_NAME,"no failure detected");
continue;
}
if (!warned) {
warned=logWarning(WATCHDOG_NAME,"failure detected",failure);
}
if (!gemfireCloseCompleted) {
logInfo(WATCHDOG_NAME,"closing GemFire");
try {
emergencyClose();
}
catch ( Throwable t) {
logWarning(WATCHDOG_NAME,"trouble closing GemFire",t);
continue;
}
gemfireCloseCompleted=true;
}
if (!failureActionCompleted) {
Runnable r=failureAction;
if (r != null) {
logInfo(WATCHDOG_NAME,"running user's runnable");
try {
r.run();
}
catch ( Throwable t) {
logWarning(WATCHDOG_NAME,"trouble running user's runnable",t);
continue;
}
}
failureActionCompleted=true;
}
stopping=true;
stopProctor();
if (exitOK) {
logWarning(WATCHDOG_NAME,CALLING_SYSTEM_EXIT,exitExcuse);
System.exit(1);
}
logInfo(WATCHDOG_NAME,"exiting");
return;
}
catch ( Throwable t) {
logWarning(WATCHDOG_NAME,"thread encountered a problem: " + t,t);
}
}
}
| This is the run loop for the watchdog thread. |
public PotentialProducer createPotentialProducer(final Object baseObject,final AttributeType type){
String methodName=type.getMethodName();
Class<?> dataType=type.getDataType();
PotentialProducer producer=createPotentialProducer(baseObject,methodName,dataType);
String description=type.getBaseDescription();
producer.setCustomDescription(description);
return producer;
}
| Create a potential producer using an attribute type. |
public boolean isTextureInitializationFailed(){
return this.textureInitializationFailed;
}
| Indicates whether an attempt was made to retrieve and read the texture but it failed. If this flag is true, this texture should not be used. |
@Override public boolean stopSelfResultForPlugin(int startId){
if (mPluginHostService != null) {
return mPluginHostService.stopSelfResult(startId);
}
return false;
}
| ApiLevel: 27 |
public QuickAdapter(Context context,int layoutResId){
super(context,layoutResId);
}
| Create a QuickAdapter. |
public int numSquares2(int n){
int[] res=new int[n + 1];
Arrays.fill(res,Integer.MAX_VALUE);
res[0]=0;
for (int i=0; i <= n; i++) {
for (int j=1; j * j <= i; j++) {
res[i]=Math.min(res[i],res[i - j * j] + 1);
}
}
return res[n];
}
| DP, bottom-up |
private void fetchStats(NetworkTemplate template){
INetworkStatsSession session=null;
try {
mStatsService.forceUpdate();
session=mStatsService.openSession();
final NetworkStats stats=session.getSummaryForAllUid(template,Long.MIN_VALUE,Long.MAX_VALUE,false);
reportStats(stats);
}
catch ( RemoteException e) {
Log.w(LOG_TAG,"Failed to fetch network stats.");
}
finally {
TrafficStats.closeQuietly(session);
}
}
| Helper method that fetches all the network stats available and reports it to instrumentation out. |
public int readVarInt() throws IOException {
int b=readByte();
if (b >= 0) {
return b;
}
int x=b & 0x7f;
b=readByte();
if (b >= 0) {
return x | (b << 7);
}
x|=(b & 0x7f) << 7;
b=readByte();
if (b >= 0) {
return x | (b << 14);
}
x|=(b & 0x7f) << 14;
b=readByte();
if (b >= 0) {
return x | b << 21;
}
return x | ((b & 0x7f) << 21) | (readByte() << 28);
}
| Read a variable size integer. |
public TsFciRunner(GraphSource graphWrapper,Parameters params,KnowledgeBoxModel knowledgeBoxModel){
super(graphWrapper.getGraph(),params,knowledgeBoxModel);
}
| Constucts a wrapper for the given EdgeListGraph. |
@LargeTest public void testCameraPairwiseScenario16() throws Exception {
genericPairwiseTestCase(Flash.AUTO,Exposure.MIN,WhiteBalance.AUTO,SceneMode.PARTY,PictureSize.SMALL,Geotagging.OFF);
}
| Flash: Auto / Exposure: Min / WB: Auto Scene: Party / Pic: Small / Geo: off |
public void runButtonActionPerformed(java.awt.event.ActionEvent e){
if (!mRunButton.isSelected()) {
return;
}
boolean ok=false;
for (int i=0; i < MAXSEQUENCE; i++) {
if (mUseField[i].isSelected()) {
ok=true;
}
}
if (!ok) {
mRunButton.setSelected(false);
return;
}
mNextSequenceElement=0;
sendNextItem();
}
| Run button pressed down, start the sequence operation |
public RoundedBitmapBuilder cornerRadiusDp(int corner,float radius){
return cornerRadius(corner,TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,radius,mDisplayMetrics));
}
| Set corner radius for a specific corner in density independent pixels. |
private static String linkToHtml(Link l){
if (l == null) {
return "null";
}
StringBuilder result=new StringBuilder();
result.append("<div class=\"Link\"><b class=\"Link\">Link:</b>" + l.getType() + ": \""+ convertTags(l.getText())+ "\" -> \""+ convertTags(l.getTarget())+ "\"");
if (l.getParameters().size() != 0) {
for ( String parameter : l.getParameters()) {
result.append("<br/>\nPARAMETER: \"" + convertTags(parameter) + "\"");
}
}
result.append("</div>\n");
return result.toString();
}
| Generates HTML Output for a Link. |
public X509Ext(ASN1ObjectIdentifier oid,byte[] value,boolean critical){
this.oid=oid;
this.value=new byte[value.length];
System.arraycopy(value,0,this.value,0,this.value.length);
this.critical=critical;
name=lookupFriendlyName();
}
| Construct a new immutable X509Ext. |
@SmallTest public void testCreateSpeechRules_metadata() throws Exception {
final String strategy="<ss:rule>" + " <ss:metadata>" + " <ss:queuing>UNINTERRUPTIBLE</ss:queuing>"+ " </ss:metadata>"+ "</ss:rule>";
final AccessibilityEvent event=AccessibilityEvent.obtain();
final EventSpeechRuleProcessor processor=createProcessorWithStrategy(strategy,1);
final Utterance utterance=new Utterance();
final boolean processed=processor.processEvent(event,utterance);
assertTrue("The event must match the filter",processed);
assertEquals("The meta-data must have its queuing poperty set",2,utterance.getMetadata().get(Utterance.KEY_METADATA_QUEUING));
}
| Test that the meta-data of a speech rule is properly parsed and passed to a formatted utterance. |
public boolean isServiceRegistered(){
return ServerApiUtils.isImsConnected();
}
| Returns true if the service is registered to the platform, else returns false |
public Builder mutable(){
return new Builder(this);
}
| Gets a mutable Builder instance. |
public void afterQuadrantMove(Quadrant newQuadrant){
Raptor.getInstance().getPreferences().setValue(service.getConnector().getShortName() + "-" + PreferenceKeys.BUG_WHO_QUADRANT,newQuadrant);
}
| Invoked after this control is moved to a new quadrant. |
public void appendToLog(String s){
append("\n" + s);
}
| Outputs the string as a new line of log data in the LogView. |
public Object runSafely(Catbert.FastStack stack) throws Exception {
String qual=getString(stack);
return new Long(MMC.getInstance().getQualityOverallBitrate(qual));
}
| Gets the estimated overall bitrate for a given recording quality. The returned value is in Megabits per second. |
public int capacity(){
return value.length;
}
| Returns the number of characters that can be held without growing. |
public static String toUnitbytes(long bytes){
if (bytes < 0) {
return "? " + GENERAL_UNIT_KILOBYTES;
}
long unitValue;
String unitName;
if (bytes < 0xA00000) {
unitValue=0x400;
unitName=GENERAL_UNIT_KILOBYTES;
}
else if (bytes < 0x280000000L) {
unitValue=0x100000;
unitName=GENERAL_UNIT_MEGABYTES;
}
else if (bytes < 0xA0000000000L) {
unitValue=0x40000000;
unitName=GENERAL_UNIT_GIGABYTES;
}
else {
unitValue=0x10000000000L;
unitName=GENERAL_UNIT_TERABYTES;
}
NumberFormat numberFormat;
if ((double)bytes * 100 / unitValue < 99995) numberFormat=NUMBER_FORMAT1;
else numberFormat=NUMBER_FORMAT0;
try {
return numberFormat.format((double)bytes / unitValue) + " " + unitName;
}
catch ( ArithmeticException ae) {
return "0 " + unitName;
}
}
| Converts the passed in number of bytes into a byte-size string. Group digits with locale-dependant thousand separator if needed, but with "KB", or "MB" or "GB" or "TB" locale-dependant unit at the end, and a limited precision of 4 significant digits. |
public void testAllSystem(String trainnameNRC,String trainnameGUMLTLT,String trainnameKLUE) throws Exception {
SentimentSystemNRC nrcSystem=new SentimentSystemNRC(tweetList);
Map<String,ClassificationResult> nrcResult=nrcSystem.test(trainnameNRC);
SentimentSystemGUMLTLT gumltltSystem=new SentimentSystemGUMLTLT(tweetList);
Map<String,ClassificationResult> gumltltResult=gumltltSystem.test(trainnameGUMLTLT);
SentimentSystemKLUE klueSystem=new SentimentSystemKLUE(tweetList);
Map<String,ClassificationResult> klueResult=klueSystem.test(trainnameKLUE);
this.evalAllModels(nrcResult,gumltltResult,klueResult);
}
| Tests and evaluate all 3 systems |
public boolean observed(String form){
return table.containsKey(form);
}
| Indicates whether the input word was observed while training this learner. |
private void showFeedback(String feedback){
if (myHost != null) {
myHost.showFeedback(feedback);
}
else {
System.out.println(feedback);
}
}
| Used to communicate feedback pop-up messages between a plugin tool and the main Whitebox user-interface. |
private boolean startProcess(){
log.fine(m_pi.toString());
boolean started=false;
if (DB.isRemoteProcess()) {
Server server=CConnection.get().getServer();
try {
if (server != null) {
m_pi=server.process(m_wscctx,m_pi);
log.finest("server => " + m_pi);
started=true;
}
}
catch ( UndeclaredThrowableException ex) {
Throwable cause=ex.getCause();
if (cause != null) {
if (cause instanceof InvalidClassException) log.log(Level.SEVERE,"Version Server <> Client: " + cause.toString() + " - "+ m_pi,ex);
else log.log(Level.SEVERE,"AppsServer error(1b): " + cause.toString() + " - "+ m_pi,ex);
}
else log.log(Level.SEVERE," AppsServer error(1) - " + m_pi,ex);
started=false;
}
catch ( Exception ex) {
Throwable cause=ex.getCause();
if (cause == null) cause=ex;
log.log(Level.SEVERE,"AppsServer error - " + m_pi,cause);
started=false;
}
}
if (!started && !m_IsServerProcess) {
ProcessCall myObject=null;
try {
Class myClass=Class.forName(m_pi.getClassName());
myObject=(ProcessCall)myClass.newInstance();
if (myObject == null) m_pi.setSummary("No Instance for " + m_pi.getClassName(),true);
else myObject.startProcess(m_wscctx,m_pi,m_trx);
if (m_trx != null) {
m_trx.commit();
m_trx.close();
}
}
catch ( Exception e) {
if (m_trx != null) {
m_trx.rollback();
m_trx.close();
}
m_pi.setSummary("Error starting Class " + m_pi.getClassName(),true);
log.log(Level.SEVERE,m_pi.getClassName(),e);
}
}
return !m_pi.isError();
}
| Start Java Process Class. instanciate the class implementing the interface ProcessCall. The class can be a Server/Client class (when in Package org compiere.process or org.compiere.model) or a client only class (e.g. in org.compiere.report) |
public static Set notifyListeners(Set cacheOpReceivers,Set adjunctRecipients,FilterRoutingInfo filterInfo,PartitionedRegion r,EntryEventImpl event,boolean ifNew,boolean ifOld,DirectReplyProcessor processor,boolean sendDeltaWithFullValue){
PutMessage msg=new PutMessage(Collections.EMPTY_SET,true,r.getPRId(),processor,event,0,ifNew,ifOld,null,false);
msg.setInternalDs(r.getSystem());
msg.versionTag=event.getVersionTag();
msg.setSendDeltaWithFullValue(sendDeltaWithFullValue);
return msg.relayToListeners(cacheOpReceivers,adjunctRecipients,filterInfo,event,r,processor);
}
| send a notification-only message to a set of listeners. The processor id is passed with the message for reply message processing. This method does not wait on the processor. |
public void clearCache(){
if (cumulative) {
for ( Map.Entry<K,SumEntry> e : sums.entrySet()) {
SumEntry val=e.getValue();
val.changed=false;
}
}
else {
sums.clear();
}
}
| Clears the cache making this operator stateless on window boundary |
private static void arcToBezier(Path p,double cx,double cy,double a,double b,double e1x,double e1y,double theta,double start,double sweep){
int numSegments=Math.abs((int)Math.ceil(sweep * 4 / Math.PI));
double eta1=start;
double cosTheta=Math.cos(theta);
double sinTheta=Math.sin(theta);
double cosEta1=Math.cos(eta1);
double sinEta1=Math.sin(eta1);
double ep1x=(-a * cosTheta * sinEta1) - (b * sinTheta * cosEta1);
double ep1y=(-a * sinTheta * sinEta1) + (b * cosTheta * cosEta1);
double anglePerSegment=sweep / numSegments;
for (int i=0; i < numSegments; i++) {
double eta2=eta1 + anglePerSegment;
double sinEta2=Math.sin(eta2);
double cosEta2=Math.cos(eta2);
double e2x=cx + (a * cosTheta * cosEta2) - (b * sinTheta * sinEta2);
double e2y=cy + (a * sinTheta * cosEta2) + (b * cosTheta * sinEta2);
double ep2x=-a * cosTheta * sinEta2 - b * sinTheta * cosEta2;
double ep2y=-a * sinTheta * sinEta2 + b * cosTheta * cosEta2;
double tanDiff2=Math.tan((eta2 - eta1) / 2);
double alpha=Math.sin(eta2 - eta1) * (Math.sqrt(4 + (3 * tanDiff2 * tanDiff2)) - 1) / 3;
double q1x=e1x + alpha * ep1x;
double q1y=e1y + alpha * ep1y;
double q2x=e2x - alpha * ep2x;
double q2y=e2y - alpha * ep2y;
p.cubicTo((float)q1x,(float)q1y,(float)q2x,(float)q2y,(float)e2x,(float)e2y);
eta1=eta2;
e1x=e2x;
e1y=e2y;
ep1x=ep2x;
ep1y=ep2y;
}
}
| Converts an arc to cubic Bezier segments and records them in p. |
private String shortFQN(String fqn,String method,int size){
String line=fqn + "." + method;
if (line.length() > size) {
line="..." + line.substring(3,size);
}
return line;
}
| Shortens a full qualified class name if it exceeds the size. TODO: improve method to shorten middle packages first, maybe abbreviating the package by its first character. |
private byte adviseOp(byte requestedOpCode,EntryEventImpl event){
{
Object oldVal;
if (this.op == OP_NULL) {
oldVal=getOriginalValue();
}
else {
oldVal=getNearSidePendingValue();
}
Region region=event.getRegion();
boolean needOldValue=region instanceof HARegion || region instanceof BucketRegion;
event.setTXEntryOldValue(oldVal,needOldValue);
}
byte advisedOpCode=OP_NULL;
switch (requestedOpCode) {
case OP_L_DESTROY:
switch (this.op) {
case OP_NULL:
advisedOpCode=requestedOpCode;
break;
case OP_L_DESTROY:
case OP_CREATE_LD:
case OP_LLOAD_CREATE_LD:
case OP_NLOAD_CREATE_LD:
case OP_PUT_LD:
case OP_LLOAD_PUT_LD:
case OP_NLOAD_PUT_LD:
case OP_D_INVALIDATE_LD:
case OP_D_DESTROY:
throw new IllegalStateException(LocalizedStrings.TXEntryState_UNEXPECTED_CURRENT_OP_0_FOR_REQUESTED_OP_1.toLocalizedString(new Object[]{opToString(),opToString(requestedOpCode)}));
case OP_L_INVALIDATE:
advisedOpCode=requestedOpCode;
break;
case OP_PUT_LI:
advisedOpCode=OP_PUT_LD;
break;
case OP_LLOAD_PUT_LI:
advisedOpCode=OP_LLOAD_PUT_LD;
break;
case OP_NLOAD_PUT_LI:
advisedOpCode=OP_NLOAD_PUT_LD;
break;
case OP_D_INVALIDATE:
advisedOpCode=OP_D_INVALIDATE_LD;
break;
case OP_CREATE_LI:
advisedOpCode=OP_CREATE_LD;
break;
case OP_LLOAD_CREATE_LI:
advisedOpCode=OP_LLOAD_CREATE_LD;
break;
case OP_NLOAD_CREATE_LI:
advisedOpCode=OP_NLOAD_CREATE_LD;
break;
case OP_CREATE:
advisedOpCode=OP_CREATE_LD;
break;
case OP_SEARCH_CREATE:
advisedOpCode=requestedOpCode;
break;
case OP_LLOAD_CREATE:
advisedOpCode=OP_LLOAD_CREATE_LD;
break;
case OP_NLOAD_CREATE:
advisedOpCode=OP_NLOAD_CREATE_LD;
break;
case OP_LOCAL_CREATE:
advisedOpCode=requestedOpCode;
break;
case OP_PUT:
advisedOpCode=OP_PUT_LD;
break;
case OP_SEARCH_PUT:
advisedOpCode=requestedOpCode;
break;
case OP_LLOAD_PUT:
advisedOpCode=OP_LLOAD_PUT_LD;
break;
case OP_NLOAD_PUT:
advisedOpCode=OP_NLOAD_PUT_LD;
break;
default :
throw new IllegalStateException(LocalizedStrings.TXEntryState_UNHANDLED_0.toLocalizedString(opToString()));
}
break;
case OP_D_DESTROY:
Assert.assertTrue(!isOpDestroy(),"Transactional destroy assertion op=" + this.op);
advisedOpCode=requestedOpCode;
break;
case OP_L_INVALIDATE:
switch (this.op) {
case OP_NULL:
advisedOpCode=requestedOpCode;
break;
case OP_L_DESTROY:
case OP_CREATE_LD:
case OP_LLOAD_CREATE_LD:
case OP_NLOAD_CREATE_LD:
case OP_PUT_LD:
case OP_LLOAD_PUT_LD:
case OP_NLOAD_PUT_LD:
case OP_D_DESTROY:
case OP_D_INVALIDATE_LD:
throw new IllegalStateException(LocalizedStrings.TXEntryState_UNEXPECTED_CURRENT_OP_0_FOR_REQUESTED_OP_1.toLocalizedString(new Object[]{opToString(),opToString(requestedOpCode)}));
case OP_L_INVALIDATE:
advisedOpCode=requestedOpCode;
break;
case OP_LLOAD_PUT_LI:
case OP_NLOAD_PUT_LI:
case OP_LLOAD_CREATE_LI:
case OP_NLOAD_CREATE_LI:
advisedOpCode=this.op;
break;
case OP_PUT_LI:
advisedOpCode=OP_PUT_LI;
break;
case OP_CREATE_LI:
advisedOpCode=OP_CREATE_LI;
break;
case OP_D_INVALIDATE:
advisedOpCode=OP_D_INVALIDATE;
break;
case OP_CREATE:
advisedOpCode=OP_CREATE_LI;
break;
case OP_SEARCH_CREATE:
advisedOpCode=OP_LOCAL_CREATE;
break;
case OP_LLOAD_CREATE:
advisedOpCode=OP_LLOAD_CREATE_LI;
break;
case OP_NLOAD_CREATE:
advisedOpCode=OP_NLOAD_CREATE_LI;
break;
case OP_LOCAL_CREATE:
advisedOpCode=OP_LOCAL_CREATE;
break;
case OP_PUT:
advisedOpCode=OP_PUT_LI;
break;
case OP_SEARCH_PUT:
advisedOpCode=requestedOpCode;
break;
case OP_LLOAD_PUT:
advisedOpCode=OP_LLOAD_PUT_LI;
break;
case OP_NLOAD_PUT:
advisedOpCode=OP_NLOAD_PUT_LI;
break;
default :
throw new IllegalStateException(LocalizedStrings.TXEntryState_UNHANDLED_0.toLocalizedString(opToString()));
}
break;
case OP_D_INVALIDATE:
switch (this.op) {
case OP_NULL:
advisedOpCode=requestedOpCode;
break;
case OP_L_DESTROY:
case OP_CREATE_LD:
case OP_LLOAD_CREATE_LD:
case OP_NLOAD_CREATE_LD:
case OP_PUT_LD:
case OP_LLOAD_PUT_LD:
case OP_NLOAD_PUT_LD:
case OP_D_INVALIDATE_LD:
case OP_D_DESTROY:
throw new IllegalStateException(LocalizedStrings.TXEntryState_UNEXPECTED_CURRENT_OP_0_FOR_REQUESTED_OP_1.toLocalizedString(new Object[]{opToString(),opToString(requestedOpCode)}));
case OP_D_INVALIDATE:
case OP_L_INVALIDATE:
advisedOpCode=OP_D_INVALIDATE;
break;
case OP_PUT_LI:
case OP_LLOAD_PUT_LI:
case OP_NLOAD_PUT_LI:
case OP_CREATE_LI:
case OP_LLOAD_CREATE_LI:
case OP_NLOAD_CREATE_LI:
advisedOpCode=this.op;
break;
case OP_CREATE:
advisedOpCode=OP_CREATE;
break;
case OP_SEARCH_CREATE:
advisedOpCode=OP_LOCAL_CREATE;
break;
case OP_LLOAD_CREATE:
advisedOpCode=OP_CREATE;
break;
case OP_NLOAD_CREATE:
advisedOpCode=OP_CREATE;
break;
case OP_LOCAL_CREATE:
advisedOpCode=OP_LOCAL_CREATE;
break;
case OP_PUT:
case OP_SEARCH_PUT:
case OP_LLOAD_PUT:
case OP_NLOAD_PUT:
advisedOpCode=requestedOpCode;
break;
default :
throw new IllegalStateException(LocalizedStrings.TXEntryState_UNHANDLED_0.toLocalizedString(opToString()));
}
break;
case OP_CREATE:
case OP_SEARCH_CREATE:
case OP_LLOAD_CREATE:
case OP_NLOAD_CREATE:
advisedOpCode=requestedOpCode;
break;
case OP_PUT:
switch (this.op) {
case OP_CREATE:
case OP_SEARCH_CREATE:
case OP_LLOAD_CREATE:
case OP_NLOAD_CREATE:
case OP_LOCAL_CREATE:
case OP_CREATE_LI:
case OP_LLOAD_CREATE_LI:
case OP_NLOAD_CREATE_LI:
case OP_CREATE_LD:
case OP_LLOAD_CREATE_LD:
case OP_NLOAD_CREATE_LD:
case OP_PUT_LD:
case OP_LLOAD_PUT_LD:
case OP_NLOAD_PUT_LD:
case OP_D_INVALIDATE_LD:
case OP_L_DESTROY:
case OP_D_DESTROY:
advisedOpCode=OP_CREATE;
break;
default :
advisedOpCode=requestedOpCode;
break;
}
break;
case OP_SEARCH_PUT:
switch (this.op) {
case OP_NULL:
advisedOpCode=requestedOpCode;
break;
case OP_L_INVALIDATE:
advisedOpCode=requestedOpCode;
break;
case OP_PUT_LI:
advisedOpCode=OP_PUT;
break;
case OP_LLOAD_PUT_LI:
advisedOpCode=OP_LLOAD_PUT;
break;
case OP_NLOAD_PUT_LI:
advisedOpCode=OP_NLOAD_PUT;
break;
case OP_CREATE_LI:
advisedOpCode=OP_CREATE;
break;
case OP_LLOAD_CREATE_LI:
advisedOpCode=OP_LLOAD_CREATE;
break;
case OP_NLOAD_CREATE_LI:
advisedOpCode=OP_NLOAD_CREATE;
break;
default :
throw new IllegalStateException(LocalizedStrings.TXEntryState_PREVIOUS_OP_0_UNEXPECTED_FOR_REQUESTED_OP_1.toLocalizedString(new Object[]{opToString(),opToString(requestedOpCode)}));
}
break;
case OP_LLOAD_PUT:
case OP_NLOAD_PUT:
switch (this.op) {
case OP_NULL:
case OP_L_INVALIDATE:
case OP_PUT_LI:
case OP_LLOAD_PUT_LI:
case OP_NLOAD_PUT_LI:
case OP_D_INVALIDATE:
advisedOpCode=requestedOpCode;
break;
case OP_CREATE:
case OP_LOCAL_CREATE:
case OP_CREATE_LI:
case OP_LLOAD_CREATE_LI:
case OP_NLOAD_CREATE_LI:
if (requestedOpCode == OP_LLOAD_PUT) {
advisedOpCode=OP_LLOAD_CREATE;
}
else {
advisedOpCode=OP_NLOAD_CREATE;
}
break;
default :
throw new IllegalStateException(LocalizedStrings.TXEntryState_PREVIOUS_OP_0_UNEXPECTED_FOR_REQUESTED_OP_1.toLocalizedString(new Object[]{opToString(),opToString(requestedOpCode)}));
}
break;
default :
throw new IllegalStateException(LocalizedStrings.TXEntryState_OPCODE_0_SHOULD_NEVER_BE_REQUESTED.toLocalizedString(opToString(requestedOpCode)));
}
return advisedOpCode;
}
| Perform operation algebra |
protected void computeOffsets(DrawContext dc){
if (dc.getFrameTimeStamp() != this.frameNumber) {
final BasicWWTexture texture=this.getTexture();
final int viewportWidth=dc.getView().getViewport().width;
final int viewportHeight=dc.getView().getViewport().height;
if (texture != null) {
this.originalImageWidth=texture.getWidth(dc);
this.originalImageHeight=texture.getHeight(dc);
}
else if (this.getImageSource() == null) {
this.originalImageWidth=1;
this.originalImageHeight=1;
}
else {
this.frameNumber=dc.getFrameTimeStamp();
return;
}
if (this.size != null) {
Dimension d=this.size.compute(this.originalImageWidth,this.originalImageHeight,viewportWidth,viewportHeight);
this.width=d.width;
this.height=d.height;
}
else {
this.width=this.originalImageWidth;
this.height=this.originalImageHeight;
}
Offset rotationOffset=this.getRotationOffset();
if (rotationOffset != null) {
Point.Double pointD=rotationOffset.computeOffset(this.width,this.height,null,null);
rotationPoint=new Point((int)pointD.x,(int)pointD.y);
}
else {
this.rotationPoint=new Point(this.width,this.height);
}
if (this.screenOffset != null) {
Point.Double pointD=this.screenOffset.computeOffset(viewportWidth,viewportHeight,null,null);
this.screenLocation=new Point((int)pointD.x,(int)(pointD.y));
}
else {
this.screenLocation=new Point(viewportWidth / 2,viewportHeight / 2);
}
this.awtScreenLocation=new Point(this.screenLocation.x,viewportHeight - this.screenLocation.y);
Point.Double overlayPoint;
if (this.imageOffset != null) overlayPoint=this.imageOffset.computeOffset(this.width,this.height,null,null);
else overlayPoint=new Point.Double(this.originalImageWidth / 2.0,this.originalImageHeight / 2.0);
this.dx=-overlayPoint.x;
this.dy=-overlayPoint.y;
this.frameNumber=dc.getFrameTimeStamp();
}
}
| Compute the image size, rotation, and position based on the current viewport size. This method updates the calculated values for screen point, rotation point, width, and height. The calculation is not performed if the values have already been calculated for this frame. |
public int encode(byte[] data,int off,int length,OutputStream out) throws IOException {
for (int i=off; i < (off + length); i++) {
int v=data[i] & 0xff;
out.write(encodingTable[(v >>> 4)]);
out.write(encodingTable[v & 0xf]);
}
return length * 2;
}
| encode the input data producing a Hex output stream. |
synchronized void markRemoved(){
if (!(!removed)) {
throw new AssertionError();
}
removed=true;
if (!permanent && callCount == 0) {
ObjectTable.decrementKeepAliveCount();
}
if (exportedTransport != null) {
exportedTransport.targetUnexported();
}
}
| Mark this target as having been removed from the object table. |
public static AnimGameItem process(MD5Model md5Model,MD5AnimModel animModel,Vector3f defaultColour) throws Exception {
List<Matrix4f> invJointMatrices=calcInJointMatrices(md5Model);
List<AnimatedFrame> animatedFrames=processAnimationFrames(md5Model,animModel,invJointMatrices);
List<Mesh> list=new ArrayList<>();
for ( MD5Mesh md5Mesh : md5Model.getMeshes()) {
Mesh mesh=generateMesh(md5Model,md5Mesh);
handleTexture(mesh,md5Mesh,defaultColour);
list.add(mesh);
}
Mesh[] meshes=new Mesh[list.size()];
meshes=list.toArray(meshes);
AnimGameItem result=new AnimGameItem(meshes,animatedFrames,invJointMatrices);
return result;
}
| Constructs and AnimGameItem instace based on a MD5 Model an MD5 Animation |
public ServiceChannel createServiceChannel(ApplicationDescription applicationDescription) throws ServiceResultException {
return new ServiceChannel(createSecureChannel(applicationDescription));
}
| Create a service channel <p> Note this implementation is unsecure as the dialog with discover endpoint is not encrypted. |
public void close(){
this._stats.close();
}
| Closes the <code>FunctionServiceStats</code>. |
public WebSocket disconnect(int closeCode,String reason,long closeDelay){
synchronized (mStateManager) {
switch (mStateManager.getState()) {
case CREATED:
finishAsynchronously();
return this;
case OPEN:
break;
default :
return this;
}
mStateManager.changeToClosing(CloseInitiator.CLIENT);
WebSocketFrame frame=WebSocketFrame.createCloseFrame(closeCode,reason);
sendFrame(frame);
}
mListenerManager.callOnStateChanged(CLOSING);
if (closeDelay < 0) {
closeDelay=DEFAULT_CLOSE_DELAY;
}
stopThreads(closeDelay);
return this;
}
| Disconnect the WebSocket. |
@Override protected void doPreRender(KMLTraversalContext tc,DrawContext dc){
if (this.getRenderable() == null) this.initializeRenderable(tc);
KMLRenderable r=this.getRenderable();
if (r != null) {
r.preRender(tc,dc);
}
}
| Pre-renders the ground overlay geometry represented by this <code>KMLGroundOverlay</code>. This initializes the ground overlay geometry if necessary, prior to pre-rendering. |
public static boolean containsHTML(String text){
if ((text == null) || text.isEmpty()) {
return false;
}
return (text.indexOf('<') != -1) || (text.indexOf('>') != -1);
}
| Check if the text contains HTML tags. |
private CResultFilter(){
}
| You are not supposed to instantiate this class. |
public void transformValues(TDoubleFunction function){
byte[] states=_states;
double[] values=_values;
for (int i=values.length; i-- > 0; ) {
if (states[i] == FULL) {
values[i]=function.execute(values[i]);
}
}
}
| Transform the values in this map using <tt>function</tt>. |
@Override public int read() throws IOException {
return in.read();
}
| Reads the next byte of data from the input stream. The value byte is returned as an <code>int</code> in the range <code>0</code> to <code>255</code>. If no byte is available because the end of the stream has been reached, the value <code>-1</code> is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown. <p> <p> A subclass must provide an implementation of this method. |
private void readEntityDeclaration() throws IOException, XmlPullParserException {
read(START_ENTITY);
boolean generalEntity=true;
skip();
if (peekCharacter() == '%') {
generalEntity=false;
position++;
skip();
}
String name=readName();
skip();
int quote=peekCharacter();
String entityValue;
if (quote == '"' || quote == '\'') {
position++;
entityValue=readValue((char)quote,true,false,ValueContext.ENTITY_DECLARATION);
if (peekCharacter() == quote) {
position++;
}
}
else if (readExternalId(true,false)) {
entityValue="";
skip();
if (peekCharacter() == NDATA[0]) {
read(NDATA);
skip();
readName();
}
}
else {
throw new XmlPullParserException("Expected entity value or external ID",this,null);
}
if (generalEntity && processDocDecl) {
if (documentEntities == null) {
documentEntities=new HashMap<String,char[]>();
}
documentEntities.put(name,entityValue.toCharArray());
}
skip();
read('>');
}
| Read an entity declaration. The value of internal entities are inline: <!ENTITY foo "bar"> The values of external entities must be retrieved by URL or path: <!ENTITY foo SYSTEM "http://host/file"> <!ENTITY foo PUBLIC "-//Android//Foo//EN" "http://host/file"> <!ENTITY foo SYSTEM "../file.png" NDATA png> Entities may be general or parameterized. Parameterized entities are marked by a percent sign. Such entities may only be used in the DTD: <!ENTITY % foo "bar"> |
public static double recall(double truePositive,double falseNegative){
final double totalPositive=truePositive + falseNegative;
if (totalPositive == 0) {
throw new IllegalArgumentException();
}
return truePositive / totalPositive;
}
| Compute the fraction of positive instances that were correctly classified. |
public static List<String> readFileToList(String filePath,String charsetName){
File file=new File(filePath);
List<String> fileContent=new ArrayList<String>();
if (file == null || !file.isFile()) {
return null;
}
BufferedReader reader=null;
try {
InputStreamReader is=new InputStreamReader(new FileInputStream(file),charsetName);
reader=new BufferedReader(is);
String line=null;
while ((line=reader.readLine()) != null) {
fileContent.add(line);
}
reader.close();
return fileContent;
}
catch ( IOException e) {
throw new RuntimeException("IOException occurred. ",e);
}
finally {
if (reader != null) {
try {
reader.close();
}
catch ( IOException e) {
throw new RuntimeException("IOException occurred. ",e);
}
}
}
}
| read file to string list, a element of list is a line |
public IndexSegment(final IndexSegmentStore fileStore){
super(fileStore,ImmutableNodeFactory.INSTANCE,true,fileStore.getIndexMetadata(),fileStore.getIndexMetadata().getIndexSegmentRecordCompressorFactory());
this.fileStore=(IndexSegmentStore)fileStore;
_reopen();
}
| Open a read-only index segment. |
public QueryResultHandlerException(String msg){
super(msg);
}
| Creates a new QueryResultHandlerException. |
public static CSVFormat newFormat(final char delimiter){
return new CSVFormat(delimiter,null,null,null,null,false,false,null,null,null,false);
}
| Creates a new CSV format with the specified delimiter. |
public static EntropyRateCalculatorDiscrete newInstance(int base,int history){
return new EntropyRateCalculatorDiscrete(base,history);
}
| User was formerly forced to create new instances through this factory method. Retained for backwards compatibility. |
public StrTokenizer(final String input,final char delim){
this(input);
setDelimiterChar(delim);
}
| Constructs a tokenizer splitting on the specified delimiter character. |
private void updatePturb(){
double xj=0;
double yj=0;
for (int j=0; j < m_plots.size(); j++) {
PlotData2D temp_plot=(m_plots.get(j));
for (int i=0; i < temp_plot.m_plotInstances.numInstances(); i++) {
if (temp_plot.m_plotInstances.instance(i).isMissing(m_xIndex) || temp_plot.m_plotInstances.instance(i).isMissing(m_yIndex)) {
}
else {
if (m_JitterVal > 0) {
xj=m_JRand.nextGaussian();
yj=m_JRand.nextGaussian();
}
temp_plot.m_pointLookup[i][2]=pturbX(temp_plot.m_pointLookup[i][0],xj);
temp_plot.m_pointLookup[i][3]=pturbY(temp_plot.m_pointLookup[i][1],yj);
}
}
}
}
| Updates the perturbed values for the plots when the jitter value is changed |
@Override public void writeTo(OutputStream out) throws IOException {
out.write(buf,0,count);
}
| Writes the complete contents of this byte array output stream to the specified output stream argument, as if by calling the output stream's write method using <code>out.write(buf, 0, count)</code>. |
public GeneratorModel createGeneratorModel(){
GeneratorModelImpl generatorModel=new GeneratorModelImpl();
return generatorModel;
}
| <!-- begin-user-doc --> <!-- end-user-doc --> |
public final V remove(int index){
if (GWT.isScript()) {
V ret=jsArray.get(index);
jsArray.remove(index);
return ret;
}
else {
return javaArray.remove(index);
}
}
| Remove the element at the given position. |
public void createDefaultState(final String fileContentDescription,final EditorType editorType,final Keymap keymap,final int numberOfLines,final int tabSize){
setCharPosition(null);
setLineNumber(numberOfLines);
setFileType(fileContentDescription);
setEditorTypeFromInstance(editorType);
setKeybindingsFromInstance(keymap);
setTabSize(tabSize);
}
| Creates an initial state, before actual data is available. |
static CipherSuite valueOf(int id1,int id2){
id1&=0xff;
id2&=0xff;
int id=(id1 << 8) | id2;
CipherSuite c=idMap.get(id);
if (c == null) {
String h1=Integer.toString(id1,16);
String h2=Integer.toString(id2,16);
c=new CipherSuite("Unknown 0x" + h1 + ":0x"+ h2,id);
}
return c;
}
| Return a CipherSuite with the given ID. A temporary object is constructed if the ID is unknown. Use isAvailable() to verify that the CipherSuite can actually be used. |
protected synchronized WebBackForwardList clone(){
throw new MustOverrideException();
}
| Clone the entire object to be used in the UI thread by clients of WebView. This creates a copy that should never be modified by any of the webkit package classes. |
public boolean isRevoked(Certificate cert){
if (!cert.getType().equals("X.509")) {
throw new RuntimeException("X.509 CRL used with non X.509 Cert");
}
TBSCertList.CRLEntry[] certs=c.getRevokedCertificates();
X500Name caName=c.getIssuer();
if (certs != null) {
BigInteger serial=((X509Certificate)cert).getSerialNumber();
for (int i=0; i < certs.length; i++) {
if (isIndirect && certs[i].hasExtensions()) {
Extension currentCaName=certs[i].getExtensions().getExtension(Extension.certificateIssuer);
if (currentCaName != null) {
caName=X500Name.getInstance(GeneralNames.getInstance(currentCaName.getParsedValue()).getNames()[0].getName());
}
}
if (certs[i].getUserCertificate().getValue().equals(serial)) {
X500Name issuer;
if (cert instanceof X509Certificate) {
issuer=X500Name.getInstance(((X509Certificate)cert).getIssuerX500Principal().getEncoded());
}
else {
try {
issuer=org.bouncycastle.asn1.x509.Certificate.getInstance(cert.getEncoded()).getIssuer();
}
catch ( CertificateEncodingException e) {
throw new RuntimeException("Cannot process certificate");
}
}
if (!caName.equals(issuer)) {
return false;
}
return true;
}
}
}
return false;
}
| Checks whether the given certificate is on this CRL. |
public final boolean isOperationRunning(final int id){
return mChronosListener.isRunning(id);
}
| Checks if an operation with given launch id is running. |
@CanIgnoreReturnValue @Override public boolean put(@Nullable K key,@Nullable V value){
addNode(key,value,null);
return true;
}
| Stores a key-value pair in the multimap. |
protected Key engineUnwrap(byte[] wrappedKey,String wrappedKeyAlgorithm,int wrappedKeyType) throws InvalidKeyException, NoSuchAlgorithmException {
if (wrappedKey.length == 0) {
throw new InvalidKeyException("The wrapped key is empty");
}
byte[] buffer=new byte[wrappedKey.length];
cipher.decrypt(wrappedKey,0,wrappedKey.length,buffer,0);
for (int i=0; i < buffer.length / 2; i++) {
byte temp=buffer[i];
buffer[i]=buffer[buffer.length - 1 - i];
buffer[buffer.length - 1 - i]=temp;
}
iv=new byte[IV_LEN];
System.arraycopy(buffer,0,iv,0,iv.length);
cipher.init(true,cipherKey.getAlgorithm(),cipherKey.getEncoded(),iv);
byte[] buffer2=new byte[buffer.length - iv.length];
cipher.decrypt(buffer,iv.length,buffer2.length,buffer2,0);
int keyValLen=buffer2.length - CHECKSUM_LEN;
byte[] cks=getChecksum(buffer2,0,keyValLen);
int offset=keyValLen;
for (int i=0; i < CHECKSUM_LEN; i++) {
if (buffer2[offset + i] != cks[i]) {
throw new InvalidKeyException("Checksum comparison failed");
}
}
cipher.init(decrypting,cipherKey.getAlgorithm(),cipherKey.getEncoded(),IV2);
byte[] out=new byte[keyValLen];
System.arraycopy(buffer2,0,out,0,keyValLen);
return ConstructKeys.constructKey(out,wrappedKeyAlgorithm,wrappedKeyType);
}
| Unwrap a previously wrapped key. |
public byte[] toByteArray() throws IOException {
return text == null ? new byte[0] : text.getBytes("UTF-8");
}
| Returns the text in this <code>VirtualLocalFile</code> object in an <code>byte[]</code>. |
private void interruptIdleWorkers(){
interruptIdleWorkers(false);
}
| Common form of interruptIdleWorkers, to avoid having to remember what the boolean argument means. |
protected Node copyInto(Node n){
super.copyInto(n);
AbstractElementNS ae=(AbstractElementNS)n;
ae.namespaceURI=namespaceURI;
return n;
}
| Copy the fields of the current node into the given node. |
private Future<ReplDBMSHeader> waitForCommittedEvent(WatchPredicate<ReplDBMSHeader> predicate,boolean cancel) throws InterruptedException {
return waitForEvent(predicate,cancel,commitWatches,true);
}
| Set a watch on a committed event. This is an event that has been processed completely the task loop *and* committed. This must be synchronized to compute the minimum committed event. |
public void go(){
dim.go();
}
| Resumes execution of the script. |
public void registerBugCollection(BugCollection bugCollection){
}
| Register a BugCollection. This allows us to find the class and method hashes for BugInstances to be compared. |
public Instances kNearestNeighbours(Instance target,int k) throws Exception {
MyHeap heap=new MyHeap(k);
if (m_Stats != null) m_Stats.searchStart();
nearestNeighbours(heap,m_Root,target,k);
if (m_Stats != null) m_Stats.searchFinish();
Instances neighbours=new Instances(m_Instances,heap.totalSize());
m_Distances=new double[heap.totalSize()];
int[] indices=new int[heap.totalSize()];
int i=1;
MyHeapElement h;
while (heap.noOfKthNearest() > 0) {
h=heap.getKthNearest();
indices[indices.length - i]=h.index;
m_Distances[indices.length - i]=h.distance;
i++;
}
while (heap.size() > 0) {
h=heap.get();
indices[indices.length - i]=h.index;
m_Distances[indices.length - i]=h.distance;
i++;
}
m_DistanceFunction.postProcessDistances(m_Distances);
for (i=0; i < indices.length; i++) neighbours.add(m_Instances.instance(indices[i]));
return neighbours;
}
| Returns k nearest instances in the current neighbourhood to the supplied instance. >k instances can be returned if there is more than one instance at the kth boundary (i.e. if there are more than 1 instance with the same distance as the kth nearest neighbour). |
public SocketCommandServer(){
this(0,50,false);
}
| Constructs a new instance using default configurations, i.e. an ephemeral port as the default port, a backlog valued <code>50</code>. |
public static NbtInputStream fromDeflater(File in,NbtLimiter limiter) throws IOException {
return fromDeflater(new FileInputStream(in),limiter);
}
| Construct new NbtInputStream for deflated data file and limiter. |
public Builder user(final User user){
this.user=user;
return this;
}
| Set user. |
public static final String listToString(List<Object> l){
StringBuffer row=new StringBuffer();
for ( Object obj : l) {
row.append(obj.toString()).append(" ");
}
return (row.toString());
}
| returns a string with the elements of l separated by spaces |
public String pad(String value,int places,String padCharacter){
StringBuilder sb=new StringBuilder();
sb.append(value);
while (sb.length() < places) {
sb.append(padCharacter);
}
return sb.toString();
}
| Pads spaces onto the end of the value to make it 'places' long |
public String toString(){
StringBuilder sb=new StringBuilder();
sb.append("java.util.Scanner");
sb.append("[delimiters=" + delimPattern + "]");
sb.append("[position=" + position + "]");
sb.append("[match valid=" + matchValid + "]");
sb.append("[need input=" + needInput + "]");
sb.append("[source closed=" + sourceClosed + "]");
sb.append("[skipped=" + skipped + "]");
sb.append("[group separator=" + groupSeparator + "]");
sb.append("[decimal separator=" + decimalSeparator + "]");
sb.append("[positive prefix=" + positivePrefix + "]");
sb.append("[negative prefix=" + negativePrefix + "]");
sb.append("[positive suffix=" + positiveSuffix + "]");
sb.append("[negative suffix=" + negativeSuffix + "]");
sb.append("[NaN string=" + nanString + "]");
sb.append("[infinity string=" + infinityString + "]");
return sb.toString();
}
| <p>Returns the string representation of this <code>Scanner</code>. The string representation of a <code>Scanner</code> contains information that may be useful for debugging. The exact format is unspecified. |
private synchronized void block(boolean tf){
if (tf) {
try {
wait();
}
catch ( InterruptedException ex) {
}
}
else {
notifyAll();
}
}
| Function used to stop code that calls acceptTrainingSet. This is needed as classifier construction is performed inside a separate thread of execution. |
public boolean isPurge(){
return purge;
}
| Returns true if all the offline messages of the user should be deleted. |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.