code
stringlengths 10
174k
| nl
stringlengths 3
129k
|
---|---|
public void createContainer(){
hierarchicalContainer=new HierarchicalContainer();
hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE_HIDDEN,String.class,null);
hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_FORCED,Action.class,null);
hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID_HIDDEN,Long.class,null);
hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID,String.class,null);
hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST,String.class,null);
hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_DATETIME,String.class,null);
hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN,Action.Status.class,null);
hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_MSGS_HIDDEN,List.class,null);
hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_ROLLOUT_NAME,String.class,null);
}
| Create a empty HierarchicalContainer. |
@Override public boolean eIsSet(int featureID){
switch (featureID) {
case UmplePackage.PROGRAM___ANONYMOUS_PROGRAM_11:
return anonymous_program_1_1 != null && !anonymous_program_1_1.isEmpty();
}
return super.eIsSet(featureID);
}
| <!-- begin-user-doc --> <!-- end-user-doc --> |
public ParameterTypeProcessLocation(String key,String description,boolean allowEntries,boolean allowDirectories,boolean allowAbsoluteEntries,boolean optional){
super(key,description,allowEntries,allowDirectories,allowAbsoluteEntries,optional);
}
| Creates a new parameter type for files with the given extension. If the extension is null no file filters will be used. |
@Override public String globalInfo(){
return "A Deep Back-Propagation Neural Network. " + "For more information see:\n" + getTechnicalInformation().toString();
}
| Description to display in the GUI. |
@Override public void run(){
amIActive=true;
String inputHeader=null;
String outputHeader=null;
int row, col, x, y;
double z;
float progress=0;
int a;
int filterSizeX=3;
int filterSizeY=3;
double n;
double sum;
double sumOfTheSquares;
double average;
double stdDev;
int dX[];
int dY[];
int midPointX;
int midPointY;
int numPixelsInFilter;
boolean filterRounded=false;
double[] filterShape;
boolean reflectAtBorders=false;
if (args.length <= 0) {
showFeedback("Plugin parameters have not been set.");
return;
}
for (int i=0; i < args.length; i++) {
if (i == 0) {
inputHeader=args[i];
}
else if (i == 1) {
outputHeader=args[i];
}
else if (i == 2) {
filterSizeX=Integer.parseInt(args[i]);
}
else if (i == 3) {
filterSizeY=Integer.parseInt(args[i]);
}
else if (i == 4) {
filterRounded=Boolean.parseBoolean(args[i]);
}
else if (i == 5) {
reflectAtBorders=Boolean.parseBoolean(args[i]);
}
}
if ((inputHeader == null) || (outputHeader == null)) {
showFeedback("One or more of the input parameters have not been set properly.");
return;
}
try {
WhiteboxRaster inputFile=new WhiteboxRaster(inputHeader,"r");
inputFile.isReflectedAtEdges=reflectAtBorders;
int rows=inputFile.getNumberRows();
int cols=inputFile.getNumberColumns();
double noData=inputFile.getNoDataValue();
WhiteboxRaster outputFile=new WhiteboxRaster(outputHeader,"rw",inputHeader,WhiteboxRaster.DataType.FLOAT,noData);
outputFile.setPreferredPalette(inputFile.getPreferredPalette());
if (Math.floor(filterSizeX / 2d) == (filterSizeX / 2d)) {
showFeedback("Filter dimensions must be odd numbers. The specified filter x-dimension" + " has been modified.");
filterSizeX++;
}
if (Math.floor(filterSizeY / 2d) == (filterSizeY / 2d)) {
showFeedback("Filter dimensions must be odd numbers. The specified filter y-dimension" + " has been modified.");
filterSizeY++;
}
numPixelsInFilter=filterSizeX * filterSizeY;
dX=new int[numPixelsInFilter];
dY=new int[numPixelsInFilter];
filterShape=new double[numPixelsInFilter];
midPointX=(int)Math.floor(filterSizeX / 2);
midPointY=(int)Math.floor(filterSizeY / 2);
if (!filterRounded) {
a=0;
for (row=0; row < filterSizeY; row++) {
for (col=0; col < filterSizeX; col++) {
dX[a]=col - midPointX;
dY[a]=row - midPointY;
filterShape[a]=1;
a++;
}
}
}
else {
double aSqr=midPointX * midPointX;
double bSqr=midPointY * midPointY;
a=0;
for (row=0; row < filterSizeY; row++) {
for (col=0; col < filterSizeX; col++) {
dX[a]=col - midPointX;
dY[a]=row - midPointY;
z=(dX[a] * dX[a]) / aSqr + (dY[a] * dY[a]) / bSqr;
if (z > 1) {
filterShape[a]=0;
}
else {
filterShape[a]=1;
}
a++;
}
}
}
for (row=0; row < rows; row++) {
for (col=0; col < cols; col++) {
z=inputFile.getValue(row,col);
if (z != noData) {
n=0;
sum=0;
sumOfTheSquares=0;
for (a=0; a < numPixelsInFilter; a++) {
x=col + dX[a];
y=row + dY[a];
z=inputFile.getValue(y,x);
if (z != noData) {
n+=filterShape[a];
sum+=z * filterShape[a];
sumOfTheSquares+=(z * filterShape[a]) * z;
}
}
if (n > 2) {
average=sum / n;
stdDev=(sumOfTheSquares - (sum * sum) / n) / n;
if (stdDev > 0) {
stdDev=Math.sqrt(stdDev);
}
outputFile.setValue(row,col,stdDev);
}
else {
outputFile.setValue(row,col,noData);
}
}
else {
outputFile.setValue(row,col,noData);
}
}
if (cancelOp) {
cancelOperation();
return;
}
progress=(float)(100f * row / (rows - 1));
updateProgress((int)progress);
}
outputFile.addMetadataEntry("Created by the " + getDescriptiveName() + " tool.");
outputFile.addMetadataEntry("Created on " + new Date());
inputFile.close();
outputFile.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. |
public final E firstElement(){
return get(0);
}
| Returns the first element of the vector. |
public void createTables(TableCreationMode mode){
ArrayList<Type<?>> sorted=sortTypes();
try (Connection connection=getConnection();Statement statement=connection.createStatement()){
connection.setAutoCommit(false);
if (mode == TableCreationMode.DROP_CREATE) {
executeDropStatements(statement);
}
for ( Type<?> type : sorted) {
String sql=tableCreateStatement(type,mode);
statementListeners.beforeExecuteUpdate(statement,sql,null);
statement.execute(sql);
statementListeners.afterExecuteUpdate(statement);
}
for ( Type<?> type : sorted) {
createIndexes(connection,mode,type);
}
connection.commit();
}
catch ( SQLException e) {
throw new TableModificationException(e);
}
}
| Create the tables over the connection. |
@Override protected void writeToXML(IAnalyzedInterval analyzedInterval,AnalyzedIntervalType jaxbAnalyzedInterval,Marshaller marshaller) throws AdeException {
File outFile=getIntervalV2FullXMLFile(analyzedInterval,m_outputInGZipFormat);
if (m_verbose) {
System.out.println("saving Ade V2 full xml in " + outFile.getAbsolutePath());
}
Writer xmlStreamWriter=null;
FileOutputStream fos=null;
GZIPOutputStream zos=null;
try {
File parentdir=outFile.getParentFile();
parentdir.mkdirs();
outFile.createNewFile();
if (m_outputInGZipFormat) {
fos=new FileOutputStream(outFile);
BufferedOutputStream bos=new BufferedOutputStream(fos);
zos=new GZIPOutputStream(bos);
xmlStreamWriter=new PrintWriter(zos);
}
else {
fos=new FileOutputStream(outFile);
xmlStreamWriter=new OutputStreamWriter(fos,"UTF-8");
}
xmlStreamWriter.write("<?xml version='1.0' encoding='UTF-8' ?> \n");
xmlStreamWriter.write("<?xml-stylesheet href='" + XSL_FILENAME + "' type=\"text/xsl\" ?> \n");
ObjectFactory factory=new ObjectFactory();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,Boolean.TRUE);
marshaller.marshal(factory.createAnalyzedInterval(jaxbAnalyzedInterval),xmlStreamWriter);
}
catch ( IOException e) {
throw new AdeInternalException("Failed to create xml file for interval " + outFile.getName() + " of source "+ m_source.getSourceId(),e);
}
catch ( JAXBException e) {
throw new AdeInternalException("Failed to write xml file for interval " + outFile.getName() + " of source "+ m_source.getSourceId(),e);
}
finally {
if (zos != null) {
try {
zos.close();
}
catch ( IOException e) {
logger.error("Failed to close ZIPOutputStream: " + outFile.getName(),e);
}
}
if (fos != null) {
try {
fos.close();
}
catch ( IOException e) {
logger.error("Failed to close FileOutputStream: " + outFile.getName(),e);
}
}
if (xmlStreamWriter != null) {
try {
xmlStreamWriter.close();
}
catch ( IOException e) {
logger.error("Failed to close file: " + outFile.getName(),e);
}
}
}
}
| Output the content to a XML file. This method intended for override by subclass to customize the XML output format. |
public boolean isAscending(){
return m_asc;
}
| Indicates if the axis values should be presented in ascending order along the axis. |
public void add(Component componentToAdd,String id,double percentX,double percentY,double percentWidth,double percentHeight){
add(componentToAdd);
mosaicPaneListeners.componentAdded(componentToAdd,id,percentX,percentY,percentWidth,percentHeight);
}
| Called to add an object to be laid out, to the layout engine. |
private void preconditionTest(){
final long token=req.token();
getQuorum().assertQuorum(token);
assertHAReady(token);
final QuorumService<HAGlue> quorumService=getQuorum().getClient();
if (!quorumService.isFollower(token)) throw new QuorumException();
final long localCommitCounter=getRootBlockView().getCommitCounter();
if (req.getNewCommitCounter() != localCommitCounter + 1) {
throw new RuntimeException("leader is preparing for commitCounter=" + req.getNewCommitCounter() + ", but follower is at localCommitCounter="+ localCommitCounter);
}
}
| Check various conditions that need to be true. <p> Note: We do this once before we take the barrier lock and once after. We need to do this before we take the barrier lock to avoid a distributed deadlock when a service is attempting to do runWithBarrierLock() to join concurrent with the GATHER of a 2-phase commit. We do it after we take the barrier lock to ensure that the conditions are still satisified - they are all light weight tests, but the conditions could become invalidated so it does not hurt to check again. |
public void init(int WindowNo,FormFrame frame){
log.info("");
m_WindowNo=WindowNo;
m_frame=frame;
try {
jbInit();
dynInit();
frame.getContentPane().add(mainPanel,BorderLayout.CENTER);
frame.getContentPane().add(confirmPanel,BorderLayout.SOUTH);
}
catch ( Exception e) {
log.log(Level.SEVERE,"",e);
}
}
| Initialize Panel |
public static void main(final String[] args){
DOMTestCase.doMain(hc_documentcreateattribute.class,args);
}
| Runs this test from the command line. |
@Override public void run(){
amIActive=true;
String inputHeader=null;
String outputHeader=null;
int row, col, x, y;
float progress=0;
double slope;
double z, z2;
int i;
int[] dX=new int[]{1,1,1,0,-1,-1,-1,0};
int[] dY=new int[]{-1,0,1,1,1,0,-1,-1};
double dist;
double gridRes;
double diagGridRes;
double maxSlope;
double flowDir=0;
if (args.length <= 0) {
showFeedback("Plugin parameters have not been set.");
return;
}
for (i=0; i < args.length; i++) {
if (i == 0) {
inputHeader=args[i];
}
else if (i == 1) {
outputHeader=args[i];
}
}
if ((inputHeader == null) || (outputHeader == null)) {
showFeedback("One or more of the input parameters have not been set properly.");
return;
}
try {
WhiteboxRaster DEM=new WhiteboxRaster(inputHeader,"r");
int rows=DEM.getNumberRows();
int cols=DEM.getNumberColumns();
double noData=DEM.getNoDataValue();
gridRes=DEM.getCellSizeX();
diagGridRes=gridRes * Math.sqrt(2);
WhiteboxRaster output=new WhiteboxRaster(outputHeader,"rw",inputHeader,WhiteboxRaster.DataType.FLOAT,noData);
output.setPreferredPalette("spectrum.pal");
output.setZUnits("dimensionless");
for (row=0; row < rows; row++) {
for (col=0; col < cols; col++) {
z=DEM.getValue(row,col);
if (z != noData) {
flowDir=0;
for (i=0; i < 8; i++) {
z2=DEM.getValue(row + dY[i],col + dX[i]);
if (z2 != noData && z2 < z) {
flowDir+=1 << i;
}
}
output.setValue(row,col,flowDir);
}
}
if (cancelOp) {
cancelOperation();
return;
}
progress=(float)(100f * row / (rows - 1));
updateProgress((int)progress);
}
output.addMetadataEntry("Created by the " + getDescriptiveName() + " tool.");
output.addMetadataEntry("Created on " + new Date());
DEM.close();
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. |
public ResultPoint[] detect() throws NotFoundException {
int height=image.getHeight();
int width=image.getWidth();
int halfHeight=height / 2;
int halfWidth=width / 2;
int deltaY=Math.max(1,height / (MAX_MODULES * 8));
int deltaX=Math.max(1,width / (MAX_MODULES * 8));
int top=0;
int bottom=height;
int left=0;
int right=width;
ResultPoint pointA=findCornerFromCenter(halfWidth,0,left,right,halfHeight,-deltaY,top,bottom,halfWidth / 2);
top=(int)pointA.getY() - 1;
ResultPoint pointB=findCornerFromCenter(halfWidth,-deltaX,left,right,halfHeight,0,top,bottom,halfHeight / 2);
left=(int)pointB.getX() - 1;
ResultPoint pointC=findCornerFromCenter(halfWidth,deltaX,left,right,halfHeight,0,top,bottom,halfHeight / 2);
right=(int)pointC.getX() + 1;
ResultPoint pointD=findCornerFromCenter(halfWidth,0,left,right,halfHeight,deltaY,top,bottom,halfWidth / 2);
bottom=(int)pointD.getY() + 1;
pointA=findCornerFromCenter(halfWidth,0,left,right,halfHeight,-deltaY,top,bottom,halfWidth / 4);
return new ResultPoint[]{pointA,pointB,pointC,pointD};
}
| <p>Detects a rectangular region of black and white -- mostly black -- with a region of mostly white, in an image.</p> |
public void addResourceBundle(ResourceBundle bundle){
bundles.add(bundle);
}
| This method extends this resource bundle with the properties set by the given bundle. If those properties are already contained, they will be ignored. |
public MonitorVersionException(){
super();
}
| Create a MonitorVersionException |
public static <E extends Comparable<E>>SingleLinkedNode<E> pairWiseSwap(SingleLinkedNode<E> node){
if (node == null || node.next == null) return node;
SingleLinkedNode<E> nextNode=node.next, nextOfNextNode=nextNode.next;
nextNode.next=node;
node.next=pairWiseSwap(nextOfNextNode);
return nextNode;
}
| Recursively swaps adjacent nodes of a linked list. <p/> Example: Input: 11->22->33->44->55 Output: 22->11->44->33->55 |
@Override public boolean handleMessage(Message msg){
if (msg.what == 1) {
adapter.setBills(bills);
adapter.notifyDataSetChanged();
}
else {
Toast.makeText(BillListActivity.this,errMsg,Toast.LENGTH_SHORT).show();
}
return true;
}
| Callback interface you can use when instantiating a Handler to avoid having to implement your own subclass of Handler. handleMessage() defines the operations to perform when the Handler receives a new Message to process. |
public static Coordinate[] removeRepeatedPoints(Coordinate[] coord){
if (!hasRepeatedPoints(coord)) return coord;
CoordinateList coordList=new CoordinateList(coord,false);
return coordList.toCoordinateArray();
}
| If the coordinate array argument has repeated points, constructs a new array containing no repeated points. Otherwise, returns the argument. |
public static Vector<String> findPackages(){
Vector<String> result;
Enumeration<String> packages;
initCache();
result=new Vector<String>();
packages=m_ClassCache.packages();
while (packages.hasMoreElements()) {
result.add(packages.nextElement());
}
Collections.sort(result,new StringCompare());
return result;
}
| Lists all packages it can find in the classpath. |
private DualPivotQuicksort(){
}
| Prevents instantiation. |
public boolean isDefaultNamespace(String namespaceURI){
return false;
}
| DOM Level 3: This method checks if the specified <code>namespaceURI</code> is the default namespace or not. |
public void checkIndex(ShardPath targetPath) throws IOException {
BytesStreamOutput os=new BytesStreamOutput();
PrintStream out=new PrintStream(os,false,Charsets.UTF_8.name());
try (Directory directory=new SimpleFSDirectory(targetPath.resolveIndex());final CheckIndex checkIndex=new CheckIndex(directory)){
checkIndex.setInfoStream(out);
CheckIndex.Status status=checkIndex.checkIndex();
out.flush();
if (!status.clean) {
logger.warn("check index [failure]\n{}",new String(os.bytes().toBytes(),Charsets.UTF_8));
throw new IllegalStateException("index check failure");
}
}
}
| Runs check-index on the target shard and throws an exception if it failed |
protected int rearrangePoints(int[] indices,final int startidx,final int endidx,final int splitDim,final double splitVal){
int tmp, left=startidx - 1;
for (int i=startidx; i <= endidx; i++) {
if (m_EuclideanDistance.valueIsSmallerEqual(m_Instances.instance(indices[i]),splitDim,splitVal)) {
left++;
tmp=indices[left];
indices[left]=indices[i];
indices[i]=tmp;
}
}
return left + 1;
}
| Re-arranges the indices array so that in the portion of the array belonging to the node to be split, the points <= to the splitVal are on the left of the portion and those > the splitVal are on the right. |
@Override public Result decode(BinaryBitmap image) throws NotFoundException, ChecksumException, FormatException {
return decode(image,null);
}
| Locates and decodes a MaxiCode in an image. |
public JSONObject putOnce(String key,Object value) throws JSONException {
if (key != null && value != null) {
if (this.opt(key) != null) {
throw new JSONException("Duplicate key \"" + key + "\"");
}
this.put(key,value);
}
return this;
}
| Put a key/value pair in the JSONObject, but only if the key and the value are both non-null, and only if there is not already a member with that name. |
protected void appendDetail(StringBuffer buffer,String fieldName,Collection coll){
buffer.append(coll);
}
| <p>Append to the <code>toString</code> a <code>Collection</code>.</p> |
public DeleteIndexRequest(String... indices){
this.indices=indices;
}
| Constructs a new delete index request for the specified indices. |
@DSGenerator(tool_name="Doppelganger",tool_version="2.0",generated_on="2013-12-30 12:59:17.042 -0500",hash_original_method="D43EB4B47E694B53E14D637B6CBB15DA",hash_generated_method="7FE5675D2A5F80229B9CC32689C8E510") public void appendExtRecord(byte[] extRecord){
try {
if (extRecord.length != EXT_RECORD_LENGTH_BYTES) {
return;
}
if ((extRecord[0] & EXT_RECORD_TYPE_MASK) != EXT_RECORD_TYPE_ADDITIONAL_DATA) {
return;
}
if ((0xff & extRecord[1]) > MAX_EXT_CALLED_PARTY_LENGTH) {
return;
}
number+=PhoneNumberUtils.calledPartyBCDFragmentToString(extRecord,2,0xff & extRecord[1]);
}
catch ( RuntimeException ex) {
Log.w(LOG_TAG,"Error parsing AdnRecord ext record",ex);
}
}
| See TS 51.011 10.5.10 |
public Joint createJoint(JointDef def){
assert (isLocked() == false);
if (isLocked()) {
return null;
}
Joint j=Joint.create(this,def);
j.m_prev=null;
j.m_next=m_jointList;
if (m_jointList != null) {
m_jointList.m_prev=j;
}
m_jointList=j;
++m_jointCount;
j.m_edgeA.joint=j;
j.m_edgeA.other=j.getBodyB();
j.m_edgeA.prev=null;
j.m_edgeA.next=j.getBodyA().m_jointList;
if (j.getBodyA().m_jointList != null) {
j.getBodyA().m_jointList.prev=j.m_edgeA;
}
j.getBodyA().m_jointList=j.m_edgeA;
j.m_edgeB.joint=j;
j.m_edgeB.other=j.getBodyA();
j.m_edgeB.prev=null;
j.m_edgeB.next=j.getBodyB().m_jointList;
if (j.getBodyB().m_jointList != null) {
j.getBodyB().m_jointList.prev=j.m_edgeB;
}
j.getBodyB().m_jointList=j.m_edgeB;
Body bodyA=def.bodyA;
Body bodyB=def.bodyB;
if (def.collideConnected == false) {
ContactEdge edge=bodyB.getContactList();
while (edge != null) {
if (edge.other == bodyA) {
edge.contact.flagForFiltering();
}
edge=edge.next;
}
}
return j;
}
| create a joint to constrain bodies together. No reference to the definition is retained. This may cause the connected bodies to cease colliding. |
private int handleC(String value,DoubleMetaphoneResult result,int index){
if (conditionC0(value,index)) {
result.append('K');
index+=2;
}
else if (index == 0 && contains(value,index,6,"CAESAR")) {
result.append('S');
index+=2;
}
else if (contains(value,index,2,"CH")) {
index=handleCH(value,result,index);
}
else if (contains(value,index,2,"CZ") && !contains(value,index - 2,4,"WICZ")) {
result.append('S','X');
index+=2;
}
else if (contains(value,index + 1,3,"CIA")) {
result.append('X');
index+=3;
}
else if (contains(value,index,2,"CC") && !(index == 1 && charAt(value,0) == 'M')) {
return handleCC(value,result,index);
}
else if (contains(value,index,2,"CK","CG","CQ")) {
result.append('K');
index+=2;
}
else if (contains(value,index,2,"CI","CE","CY")) {
if (contains(value,index,3,"CIO","CIE","CIA")) {
result.append('S','X');
}
else {
result.append('S');
}
index+=2;
}
else {
result.append('K');
if (contains(value,index + 1,2," C"," Q"," G")) {
index+=3;
}
else if (contains(value,index + 1,1,"C","K","Q") && !contains(value,index + 1,2,"CE","CI")) {
index+=2;
}
else {
index++;
}
}
return index;
}
| Handles 'C' cases |
void error(int errorId,int resourceId){
mEventHandler.error(errorId,mConnection.mContext.getText(resourceId).toString());
}
| Helper: calls error() on eventhandler with appropriate message This should not be called before the mConnection is set. |
public static void checkHitsQuery(Query query,ScoreDoc[] hits1,ScoreDoc[] hits2,int[] results){
checkDocIds("hits1",results,hits1);
checkDocIds("hits2",results,hits2);
checkEqual(query,hits1,hits2);
}
| Tests that two queries have an expected order of documents, and that the two queries have the same score values. |
protected static void link(final ReilBlock parent,final ReilBlock child){
parent.m_children.add(child);
child.m_parents.add(parent);
}
| Links two REIL blocks. |
public static <K,V>SynchronizedSortedBagMultimap<K,V> of(MutableSortedBagMultimap<K,V> multimap,Object lock){
if (multimap == null) {
throw new IllegalArgumentException("cannot create a SynchronizedSortedBagMultimap for null");
}
return new SynchronizedSortedBagMultimap<>(multimap,lock);
}
| This method will take a Multimap and wrap it directly in a SynchronizedSortedBagMultimap. Additionally, a developer specifies which lock to use with the collection. |
public static String readStringFromReader(Reader reader) throws IOException {
return readAllCharsFromReader(reader).toString();
}
| Reads all chars from given reader until an EOF is read, and returns them as a String. Closes reader afterwards. |
public String number() throws ParseException {
int startIdx=ptr;
try {
if (!isDigit(lookAhead(0))) {
throw new ParseException(buffer + ": Unexpected token at " + lookAhead(0),ptr);
}
consume(1);
while (true) {
char next=lookAhead(0);
if (isDigit(next)) {
consume(1);
}
else break;
}
return buffer.substring(startIdx,ptr);
}
catch ( ParseException ex) {
return buffer.substring(startIdx,ptr);
}
}
| Get and consume the next number. |
@DSGenerator(tool_name="Doppelganger",tool_version="2.0",generated_on="2013-12-30 12:33:27.373 -0500",hash_original_method="59D4C7A828654550E9A00289F418A41B",hash_generated_method="A1ADB842CDB3D89617B61CB662BF8B7B") public Entry(String tag,long millis){
if (tag == null) throw new NullPointerException("tag == null");
mTag=tag;
mTimeMillis=millis;
mData=null;
mFileDescriptor=null;
mFlags=IS_EMPTY;
}
| Create a new empty Entry with no contents. |
public void attrAdded(Attr node,String newv){
if (!changing && baseVal != null) {
baseVal.invalidate();
}
fireBaseAttributeListeners();
if (!hasAnimVal) {
fireAnimatedAttributeListeners();
}
}
| Called when an Attr node has been added. |
public void resizeFrame(JComponent f,int newX,int newY,int newWidth,int newHeight){
setBoundsForFrame(ghostPanel,newX,newY,newWidth,newHeight);
}
| resizeFrame() - |
public void test_putLjava_lang_ObjectLjava_lang_Object(){
hm.put("KEY","VALUE");
assertEquals("Failed to install key/value pair","VALUE",hm.get("KEY"));
HashMap m=new HashMap();
m.put(new Short((short)0),"short");
m.put(null,"test");
m.put(new Integer(0),"int");
assertEquals("Failed adding to bucket containing null","short",m.get(new Short((short)0)));
assertEquals("Failed adding to bucket containing null2","int",m.get(new Integer(0)));
}
| java.util.HashMap#put(java.lang.Object, java.lang.Object) |
@Override public BigdataSailRepositoryConnection cxn(){
if (closed) throw Exceptions.alreadyClosed();
tx.readWrite();
return tx.cxn();
}
| Return the unisolated SAIL connection. Automatically opens the Tinkerpop3 Transaction if not already open. |
public static String toString(Integer arg){
return toString("%d",arg);
}
| Convert integer to string |
private double readInheritFontSizeAttribute(IXMLElement elem,String attributeName,String defaultValue) throws IOException {
String value=null;
if (elem.hasAttribute(attributeName,SVG_NAMESPACE)) {
value=elem.getAttribute(attributeName,SVG_NAMESPACE,null);
}
else if (elem.hasAttribute(attributeName)) {
value=elem.getAttribute(attributeName,null);
}
else if (elem.getParent() != null && (elem.getParent().getNamespace() == null || elem.getParent().getNamespace().equals(SVG_NAMESPACE))) {
return readInheritFontSizeAttribute(elem.getParent(),attributeName,defaultValue);
}
else {
value=defaultValue;
}
if (value.equals("inherit")) {
return readInheritFontSizeAttribute(elem.getParent(),attributeName,defaultValue);
}
else if (SVG_ABSOLUTE_FONT_SIZES.containsKey(value)) {
return SVG_ABSOLUTE_FONT_SIZES.get(value);
}
else if (SVG_RELATIVE_FONT_SIZES.containsKey(value)) {
return SVG_RELATIVE_FONT_SIZES.get(value) * readInheritFontSizeAttribute(elem.getParent(),attributeName,defaultValue);
}
else if (value.endsWith("%")) {
double factor=Double.valueOf(value.substring(0,value.length() - 1));
return factor * readInheritFontSizeAttribute(elem.getParent(),attributeName,defaultValue);
}
else {
return toNumber(elem,value);
}
}
| Reads a font size attribute that is inherited. As specified by http://www.w3.org/TR/SVGMobile12/text.html#FontPropertiesUsedBySVG http://www.w3.org/TR/2006/CR-xsl11-20060220/#font-getChildCount |
boolean isInitializing(){
return this.state == INITIALIZING;
}
| Returns true if this grantor is still initializing and not yet ready for lock requests. |
public static void logNormalize(double[] a){
double logTotal=logSum(a);
if (logTotal == Double.NEGATIVE_INFINITY) {
double v=-Math.log(a.length);
for (int i=0; i < a.length; i++) {
a[i]=v;
}
return;
}
shift(a,-logTotal);
}
| Makes the values in this array sum to 1.0. Does it in place. If the total is 0.0, sets a to the uniform distribution. |
public Word(Word w,Sentence s){
this.idx=w.idx;
this.Form=w.Form;
this.Lemma=w.Lemma;
this.POS=w.POS;
this.Feats=w.Feats;
this.Deprel=w.Deprel;
this.head=w.head;
this.headID=w.headID;
this.children=w.children;
this.corefid=w.corefid;
if (s == null) {
this.mySentence=w.mySentence;
}
else {
this.mySentence=s;
if (s.size() > this.idx) {
s.remove(this.idx);
s.add(this.idx,this);
}
}
this.isBOS=w.isBOS;
this.rep=new Double[w.rep.length];
for (int i=0; i < w.rep.length; i++) this.rep[i]=w.rep[i];
this.begin=w.begin;
this.end=w.end;
if (head != null) {
for ( Word child : children) child.head=this;
head.children.remove(w);
head.children.add(this);
}
}
| Used to replace an old word with a new (updates dependencies). Used to make a predicate from a word during predicate identification. |
@Override public boolean containsKey(Object key){
int hash=hash(key);
return segmentFor(hash).containsKey(key,hash);
}
| Tests if the specified object is a key in this table. |
public Interval(long startInstant,long endInstant){
super(startInstant,endInstant,null);
}
| Constructs an interval from a start and end instant with the ISO default chronology in the default time zone. |
public boolean isTimeout(){
return timeout;
}
| Gets the timeout value for this ForgotPasswordWSBean. |
public void updatePolygon(Mesh poly){
if (getNumberOfChildren() < 3) {
return;
}
FloatBuffer vertexBuffer=tessellator.tessellate(getPointList(),null);
FloatBuffer normalBuffer=BufferUtils.createFloatBuffer(vertexBuffer.capacity());
MathUtil.computePolygonNormal(vertexBuffer,normalBuffer,true);
poly.getMeshData().setVertexBuffer(vertexBuffer);
poly.getMeshData().setNormalBuffer(normalBuffer);
poly.getMeshData().updateVertexCount();
poly.markDirty(DirtyType.Bounding);
poly.updateModelBound();
poly.updateGeometricState(0);
}
| Update the polygon from the points |
static int testTanh(){
int failures=0;
double[][] testCases={{0.0625,0.06241874674751251449014289119421133},{0.1250,0.12435300177159620805464727580589271},{0.1875,0.18533319990813951753211997502482787},{0.2500,0.24491866240370912927780113149101697},{0.3125,0.30270972933210848724239738970991712},{0.3750,0.35835739835078594631936023155315807},{0.4375,0.41157005567402245143207555859415687},{0.5000,0.46211715726000975850231848364367256},{0.5625,0.50982997373525658248931213507053130},{0.6250,0.55459972234938229399903909532308371},{0.6875,0.59637355547924233984437303950726939},{0.7500,0.63514895238728731921443435731249638},{0.8125,0.67096707420687367394810954721913358},{0.8750,0.70390560393662106058763026963135371},{0.9375,0.73407151960434149263991588052503660},{1.0000,0.76159415595576488811945828260479366},{1.0625,0.78661881210869761781941794647736081},{1.1250,0.80930107020178101206077047354332696},{1.1875,0.82980190998595952708572559629034476},{1.2500,0.84828363995751289761338764670750445},{1.3125,0.86490661772074179125443141102709751},{1.3750,0.87982669965198475596055310881018259},{1.4375,0.89319334040035153149249598745889365},{1.5000,0.90514825364486643824230369645649557},{1.5625,0.91582454416876231820084311814416443},{1.6250,0.92534622531174107960457166792300374},{1.6875,0.93382804322259173763570528576138652},{1.7500,0.94137553849728736226942088377163687},{1.8125,0.94808528560440629971240651310180052},{1.8750,0.95404526017994877009219222661968285},{1.9375,0.95933529331468249183399461756952555},{2.0000,0.96402758007581688394641372410092317},{2.0625,0.96818721657637057702714316097855370},{2.1250,0.97187274591350905151254495374870401},{2.1875,0.97513669829362836159665586901156483},{2.2500,0.97802611473881363992272924300618321},{2.3125,0.98058304703705186541999427134482061},{2.3750,0.98284502917257603002353801620158861},{2.4375,0.98484551746427837912703608465407824},{2.5000,0.98661429815143028888127603923734964},{2.5625,0.98817786228751240824802592958012269},{2.6250,0.98955974861288320579361709496051109},{2.6875,0.99078085564125158320311117560719312},{2.7500,0.99185972456820774534967078914285035},{2.8125,0.99281279483715982021711715899682324},{2.8750,0.99365463431502962099607366282699651},{2.9375,0.99439814606575805343721743822723671},{3.0000,0.99505475368673045133188018525548849},{3.0625,0.99563456710930963835715538507891736},{3.1250,0.99614653067334504917102591131792951},{3.1875,0.99659855517712942451966113109487039},{3.2500,0.99699763548652601693227592643957226},{3.3125,0.99734995516557367804571991063376923},{3.3750,0.99766097946988897037219469409451602},{3.4375,0.99793553792649036103161966894686844},{3.5000,0.99817789761119870928427335245061171},{3.5625,0.99839182812874152902001617480606320},{3.6250,0.99858065920179882368897879066418294},{3.6875,0.99874733168378115962760304582965538},{3.7500,0.99889444272615280096784208280487888},{3.8125,0.99902428575443546808677966295308778},{3.8750,0.99913888583735077016137617231569011},{3.9375,0.99924003097049627100651907919688313},{4.0000,0.99932929973906704379224334434172499},{4.0625,0.99940808577297384603818654530731215},{4.1250,0.99947761936180856115470576756499454},{4.1875,0.99953898655601372055527046497863955},{4.2500,0.99959314604388958696521068958989891},{4.3125,0.99964094406130644525586201091350343},{4.3750,0.99968312756179494813069349082306235},{4.4375,0.99972035584870534179601447812936151},{4.5000,0.99975321084802753654050617379050162},{4.5625,0.99978220617994689112771768489030236},{4.6250,0.99980779516900105210240981251048167},{4.6875,0.99983037791655283849546303868853396},{4.7500,0.99985030754497877753787358852000255},{4.8125,0.99986789571029070417475400133989992},{4.8750,0.99988341746867772271011794614780441},{4.9375,0.99989711557251558205051185882773206},{5.0000,0.99990920426259513121099044753447306},{5.0625,0.99991987261554158551063867262784721},{5.1250,0.99992928749851651137225712249720606},{5.1875,0.99993759617721206697530526661105307},{5.2500,0.99994492861777083305830639416802036},{5.3125,0.99995139951851344080105352145538345},{5.3750,0.99995711010315817210152906092289064},{5.4375,0.99996214970350792531554669737676253},{5.5000,0.99996659715630380963848952941756868},{5.5625,0.99997052203605101013786592945475432},{5.6250,0.99997398574306704793434088941484766},{5.6875,0.99997704246374583929961850444364696},{5.7500,0.99997974001803825215761760428815437},{5.8125,0.99998212060739040166557477723121777},{5.8750,0.99998422147482750993344503195672517},{5.9375,0.99998607548749972326220227464612338},{6.0000,0.99998771165079557056434885235523206},{6.0625,0.99998915556205996764518917496149338},{6.1250,0.99999042981101021976277974520745310},{6.1875,0.99999155433311068015449574811497719},{6.2500,0.99999254672143162687722782398104276},{6.3125,0.99999342250186907900400800240980139},{6.3750,0.99999419537602957780612639767025158},{6.4375,0.99999487743557848265406225515388994},{6.5000,0.99999547935140419285107893831698753},{6.5625,0.99999601054055694588617385671796346},{6.6250,0.99999647931357331502887600387959900},{6.6875,0.99999689300449080997594368612277442},{6.7500,0.99999725808558628431084200832778748},{6.8125,0.99999758026863294516387464046135924},{6.8750,0.99999786459425991170635407313276785},{6.9375,0.99999811551081218572759991597586905},{7.0000,0.99999833694394467173571641595066708},{7.0625,0.99999853235803894918375164252059190},{7.1250,0.99999870481040359014665019356422927},{7.1875,0.99999885699910593255108365463415411},{7.2500,0.99999899130518359709674536482047025},{7.3125,0.99999910982989611769943303422227663},{7.3750,0.99999921442759946591163427422888252},{7.4375,0.99999930673475777603853435094943258},{7.5000,0.99999938819554614875054970643513124},{7.5625,0.99999946008444508183970109263856958},{7.6250,0.99999952352618001331402589096040117},{7.6875,0.99999957951331792817413683491979752},{7.7500,0.99999962892179632633374697389145081},{7.8125,0.99999967252462750190604116210421169},{7.8750,0.99999971100399253750324718031574484},{7.9375,0.99999974496191422474977283863588658},{8.0000,0.99999977492967588981001883295636840},{8.0625,0.99999980137613348259726597081723424},{8.1250,0.99999982471505097353529823063673263},{8.1875,0.99999984531157382142423402736529911},{8.2500,0.99999986348794179107425910499030547},{8.3125,0.99999987952853049895833839645847571},{8.3750,0.99999989368430056302584289932834041},{8.4375,0.99999990617672396471542088609051728},{8.5000,0.99999991720124905211338798152800748},{8.5625,0.99999992693035839516545287745322387},{8.6250,0.99999993551626733394129009365703767},{8.6875,0.99999994309330543951799157347876934},{8.7500,0.99999994978001814614368429416607424},{8.8125,0.99999995568102143535399207289008504},{8.8750,0.99999996088863858914831986187674522},{8.9375,0.99999996548434461974481685677429908},{9.0000,0.99999996954004097447930211118358244},{9.0625,0.99999997311918045901919121395899372},{9.1250,0.99999997627775997868467948564005257},{9.1875,0.99999997906519662964368381583648379},{9.2500,0.99999998152510084671976114264303159},{9.3125,0.99999998369595870397054673668361266},{9.3750,0.99999998561173404286033236040150950},{9.4375,0.99999998730239984852716512979473289},{9.5000,0.99999998879440718770812040917618843},{9.5625,0.99999999011109904501789298212541698},{9.6250,0.99999999127307553219220251303121960},{9.6875,0.99999999229851618412119275358396363},{9.7500,0.99999999320346438410630581726217930},{9.8125,0.99999999400207836827291739324060736},{9.8750,0.99999999470685273619047001387577653},{9.9375,0.99999999532881393331131526966058758},{10.0000,0.99999999587769276361959283713827574}};
for (int i=0; i < testCases.length; i++) {
double[] testCase=testCases[i];
failures+=testTanhCaseWithUlpDiff(testCase[0],testCase[1],3.0);
}
double[][] specialTestCases={{0.0,0.0},{NaNd,NaNd},{Double.longBitsToDouble(0x7FF0000000000001L),NaNd},{Double.longBitsToDouble(0xFFF0000000000001L),NaNd},{Double.longBitsToDouble(0x7FF8555555555555L),NaNd},{Double.longBitsToDouble(0xFFF8555555555555L),NaNd},{Double.longBitsToDouble(0x7FFFFFFFFFFFFFFFL),NaNd},{Double.longBitsToDouble(0xFFFFFFFFFFFFFFFFL),NaNd},{Double.longBitsToDouble(0x7FFDeadBeef00000L),NaNd},{Double.longBitsToDouble(0xFFFDeadBeef00000L),NaNd},{Double.longBitsToDouble(0x7FFCafeBabe00000L),NaNd},{Double.longBitsToDouble(0xFFFCafeBabe00000L),NaNd},{Double.POSITIVE_INFINITY,1.0}};
for (int i=0; i < specialTestCases.length; i++) {
failures+=testTanhCaseWithUlpDiff(specialTestCases[i][0],specialTestCases[i][1],0.0);
}
for (int i=DoubleConsts.MIN_SUB_EXPONENT; i < -27; i++) {
double d=Math.scalb(2.0,i);
failures+=testTanhCaseWithUlpDiff(d,d,2.5);
}
for (int i=22; i < 32; i++) {
failures+=testTanhCaseWithUlpDiff(i,1.0,2.5);
}
for (int i=5; i <= DoubleConsts.MAX_EXPONENT; i++) {
double d=Math.scalb(2.0,i);
failures+=testTanhCaseWithUlpDiff(d,1.0,2.5);
}
return failures;
}
| Test accuracy of {Math, StrictMath}.tanh. The specified accuracy is 2.5 ulps. The defintion of tanh(x) is (e^x - e^(-x))/(e^x + e^(-x)) The series expansion of tanh(x) = x - x^3/3 + 2x^5/15 - 17x^7/315 + ... Therefore, 1. For large values of x tanh(x) ~= signum(x) 2. For small values of x, tanh(x) ~= x. Additionally, tanh is an odd function; tanh(-x) = -tanh(x). |
public static BigdataGraph create(final BlueprintsValueFactory vf) throws Exception {
return create(vf,new Properties());
}
| Create a new local in-memory bigdata instance with the supplied value factory. |
public static void writeToXmlImpl(List<Block> toSerialize,@Nullable OutputStream os,@Nullable Writer writer) throws BlocklySerializerException {
try {
XmlSerializer serializer=mParserFactory.newSerializer();
if (os != null) {
serializer.setOutput(os,null);
}
else {
serializer.setOutput(writer);
}
serializer.setPrefix("",XML_NAMESPACE);
serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output",true);
serializer.startTag(XML_NAMESPACE,"xml");
for (int i=0; i < toSerialize.size(); i++) {
toSerialize.get(i).serialize(serializer,true);
}
serializer.endTag(XML_NAMESPACE,"xml");
serializer.flush();
}
catch ( XmlPullParserException|IOException e) {
throw new BlocklySerializerException(e);
}
}
| Serializes all Blocks in the given list and writes them to the either the output stream or writer, whichever is not null. |
public void onSuccess(){
if (_firstSuccessTime <= 0) {
_firstSuccessTime=CurrentTime.currentTime();
}
_dynamicRecoverTimeout.set(1000L);
_firstFailTime=0;
}
| Called when the server has a successful response |
public SVGPaintManager(String prop,Value v){
super(prop,v);
}
| Creates a new SVGPaintManager. |
public void runTest() throws Throwable {
Document doc;
NodeList elementList;
Node employeeNode;
NodeList childList;
Node oldChild=null;
Node newChild=null;
Node child;
String childName;
Node childNode;
java.util.List actual=new java.util.ArrayList();
java.util.List expected=new java.util.ArrayList();
expected.add("strong");
expected.add("code");
expected.add("sup");
expected.add("var");
expected.add("em");
Node replacedChild;
int nodeType;
doc=(Document)load("hc_staff",true);
elementList=doc.getElementsByTagName("p");
employeeNode=elementList.item(1);
childList=((Element)employeeNode).getElementsByTagName("*");
newChild=childList.item(0);
oldChild=childList.item(5);
replacedChild=employeeNode.replaceChild(newChild,oldChild);
assertSame("return_value_same",oldChild,replacedChild);
for (int indexN10094=0; indexN10094 < childList.getLength(); indexN10094++) {
childNode=(Node)childList.item(indexN10094);
childName=childNode.getNodeName();
nodeType=(int)childNode.getNodeType();
if (equals(1,nodeType)) {
actual.add(childName);
}
else {
assertEquals("textNodeType",3,nodeType);
assertEquals("textNodeName","#text",childName);
}
}
assertEqualsAutoCase("element","childNames",expected,actual);
}
| Runs the test case. |
public void runTest(){
try {
Template template1=RuntimeSingleton.getTemplate(getFileName(null,"path1",TMPL_FILE_EXT));
Template template2=RuntimeSingleton.getTemplate(getFileName(null,"path2",TMPL_FILE_EXT));
FileOutputStream fos1=new FileOutputStream(getFileName(RESULTS_DIR,"path1",RESULT_FILE_EXT));
FileOutputStream fos2=new FileOutputStream(getFileName(RESULTS_DIR,"path2",RESULT_FILE_EXT));
Writer writer1=new BufferedWriter(new OutputStreamWriter(fos1));
Writer writer2=new BufferedWriter(new OutputStreamWriter(fos2));
VelocityContext context=new VelocityContext();
template1.merge(context,writer1);
writer1.flush();
writer1.close();
template2.merge(context,writer2);
writer2.flush();
writer2.close();
if (!isMatch(RESULTS_DIR,COMPARE_DIR,"path1",RESULT_FILE_EXT,CMP_FILE_EXT) || !isMatch(RESULTS_DIR,COMPARE_DIR,"path2",RESULT_FILE_EXT,CMP_FILE_EXT)) {
fail("Output incorrect.");
}
}
catch ( Exception e) {
fail(e.getMessage());
}
}
| Runs the test. |
@DSComment("Private Method") @DSBan(DSCat.PRIVATE_METHOD) @DSGenerator(tool_name="Doppelganger",tool_version="2.0",generated_on="2013-12-30 12:59:03.935 -0500",hash_original_method="747AFE004560A767DF481C3AA8002660",hash_generated_method="9625D3D3689DEE9B299B2E695D5C9E6A") private ComprehensionTlv searchForTag(ComprehensionTlvTag tag,List<ComprehensionTlv> ctlvs){
Iterator<ComprehensionTlv> iter=ctlvs.iterator();
return searchForNextTag(tag,iter);
}
| Search for a COMPREHENSION-TLV object with the given tag from a list |
public Result(double gSquare,double pValue,int df,boolean isIndep){
this.gSquare=gSquare;
this.pValue=pValue;
this.df=df;
this.isIndep=isIndep;
}
| Constructs a new g square result using the given parameters. |
private static char[] zzUnpackCMap(String packed){
char[] map=new char[0x10000];
int i=0;
int j=0;
while (i < 174) {
int count=packed.charAt(i++);
char value=packed.charAt(i++);
do map[j++]=value;
while (--count > 0);
}
return map;
}
| Unpacks the compressed character translation table. |
public boolean hasStickyHeader(View itemView,int orientation,int position){
int offset, margin;
mDimensionCalculator.initMargins(mTempRect1,itemView);
if (orientation == LinearLayout.VERTICAL) {
offset=itemView.getTop();
margin=mTempRect1.top;
}
else {
offset=itemView.getLeft();
margin=mTempRect1.left;
}
return offset <= margin && mAdapter.getHeaderId(position) >= 0;
}
| Determines if a view should have a sticky header. The view has a sticky header if: 1. It is the first element in the recycler view 2. It has a valid ID associated to its position |
public DistributedLogClientBuilder streamStatsReceiver(StatsReceiver streamStatsReceiver){
DistributedLogClientBuilder newBuilder=newBuilder(this);
newBuilder._streamStatsReceiver=streamStatsReceiver;
return newBuilder;
}
| Stream Stats Receiver to expose per stream stats. |
public void connect() throws IOException {
connect(null,null);
}
| Initiate drone connection procedure. |
public SOM(DistanceMetric dm,int somHeight,int somWeight,VectorCollectionFactory<VecPaired<Vec,Integer>> vcFactory){
this(DEFAULT_MAX_ITERS,DEFAULT_KF,DEFAULT_LEARNING_RATE,DEFAULT_LEARNING_DECAY,DEFAULT_NEIGHBOR_DECAY,dm,somHeight,somWeight,vcFactory);
}
| Creates a new SOM using the given parameters |
public String toString(int maxKeysToPrint,boolean multiline){
PriorityQueue<E> pq=clone();
StringBuilder sb=new StringBuilder(multiline ? "" : "[");
int numKeysPrinted=0;
NumberFormat f=NumberFormat.getInstance();
f.setMaximumFractionDigits(5);
while (numKeysPrinted < maxKeysToPrint && pq.hasNext()) {
double priority=pq.getPriority();
E element=pq.next();
sb.append(element == null ? "null" : element.toString());
sb.append(" : ");
sb.append(f.format(priority));
if (numKeysPrinted < size() - 1) sb.append(multiline ? "\n" : ", ");
numKeysPrinted++;
}
if (numKeysPrinted < size()) sb.append("...");
if (!multiline) sb.append("]");
return sb.toString();
}
| Returns a representation of the queue in decreasing priority order, displaying at most maxKeysToPrint elements and optionally printing one element per line. |
private static final void logErrors(final List<CompilerError> errors,final String label,boolean warn,final Log log){
log.info("-------------------------------------------------------------");
log.warn("CHECKER FRAMEWORK " + label.toUpperCase() + ": ");
log.info("-------------------------------------------------------------");
for ( final CompilerError error : errors) {
final String msg=error.toString().trim();
if (warn) {
log.warn(msg);
}
else {
log.error(msg);
}
}
final String labelLc=label.toLowerCase() + ((errors.size() == 1) ? "" : "s");
log.info(errors.size() + " " + labelLc);
log.info("-------------------------------------------------------------");
}
| Print a header with the given label and print all errors similar to the style maven itself uses |
public void generateLootChest(World world,Random random,BlockPos pos,int min,int max,IBlockState state,ResourceLocation lootTable){
world.setBlockState(pos,state,3);
TileEntityChest chest=(TileEntityChest)world.getTileEntity(pos);
if (chest != null) chest.setLootTable(lootTable,random.nextLong());
}
| Generates a loot chest at a location |
public DCDs(){
this(10000,false);
}
| Creates a new DCDL2 SVM object |
protected static boolean isIntendedException(Exception e,Class<?> clazz){
final String message=e.getMessage();
return (!TextUtils.isEmpty(message) && message.startsWith(clazz.getName()));
}
| Checks if the exception is one of the intended server side exception that has been thrown over the AIDL layer. |
public boolean hasConditions(){
return ifModifiedSince != null || ifNoneMatch != null;
}
| Returns true if the request contains conditions that save the server from sending a response that the client has locally. When the caller adds conditions, this cache won't participate in the request. |
@Override public boolean isActive(){
return amIActive;
}
| Used by the Whitebox GUI to tell if this plugin is still running. |
public static char toCharValue(Object o) throws PageException {
if (o instanceof Character) return ((Character)o).charValue();
else if (o instanceof Boolean) return (char)((((Boolean)o).booleanValue()) ? 1 : 0);
else if (o instanceof Double) return (char)(((Double)o).doubleValue());
else if (o instanceof Number) return (char)(((Number)o).doubleValue());
else if (o instanceof String) {
String str=o.toString();
if (str.length() > 0) return str.charAt(0);
throw new ExpressionException("can't cast empty string to a char");
}
else if (o instanceof ObjectWrap) {
return toCharValue(((ObjectWrap)o).getEmbededObject());
}
else if (o == null) return toCharValue("");
throw new CasterException(o,"char");
}
| cast a Object to a char value (primitive value type) |
public static PeriodType yearDayTime(){
PeriodType type=cYDTime;
if (type == null) {
type=new PeriodType("YearDayTime",new DurationFieldType[]{DurationFieldType.years(),DurationFieldType.days(),DurationFieldType.hours(),DurationFieldType.minutes(),DurationFieldType.seconds(),DurationFieldType.millis()},new int[]{0,-1,-1,1,2,3,4,5});
cYDTime=type;
}
return type;
}
| Gets a type that defines all standard fields except months and weeks. <ul> <li>years <li>days <li>hours <li>minutes <li>seconds <li>milliseconds </ul> |
private static img createWorkflowImage(String name,int activeNode,String js_command,boolean pressed){
StringBuffer imgName=new StringBuffer(name);
imgName.append("WF");
imgName.append(".gif");
img img=new img(MobileEnv.getImageDirectory(imgName.toString()),name);
if (!(imgName.toString()).startsWith("Spacer") && !(imgName.toString()).startsWith("Arrow")) {
if (!pressed) img.setID("imgButton");
else img.setID("imgButtonPressed");
}
if (js_command != null && js_command.length() > 0 && activeNode != 0) {
String js_command_front="document." + FORM_NAME + "."+ J_Command+ ".value='"+ activeNode+ "'; ";
js_command_front=js_command_front + "document." + FORM_NAME+ ".submit();";
img.setOnClick(js_command_front + js_command);
}
return img;
}
| Create Image with name, id of button_name and set M_Command onClick |
public static boolean isFluid(World world,int x,int y,int z){
return getFluid(world,x,y,z,false) != null;
}
| Whether or not a certain block is considered a fluid. |
public boolean isActiveInTransaction(CompositeTransaction tx){
boolean ret=false;
if (currentContext != null && tx != null) ret=currentContext.isInTransaction(tx);
return ret;
}
| Tests if the session is active (enlisted) in the given transaction. |
public static <V extends Vec>void meanVector(Vec mean,List<V> dataSet){
if (dataSet.isEmpty()) throw new ArithmeticException("Can not compute the mean of zero data points");
else if (dataSet.get(0).length() != mean.length()) throw new ArithmeticException("Vector dimensions do not agree");
for ( Vec x : dataSet) mean.mutableAdd(x);
mean.mutableDivide(dataSet.size());
}
| Computes the mean of the given data set. |
@Override public final void write(byte[] source,int offset,int len){
this.size+=len;
}
| override OutputStream's write() |
@Override public void onDragEnd(DragEndEvent event){
log("onDragEnd: " + event,RED);
}
| Log the drag end event. |
protected boolean beforeSave(boolean newRecord){
MPayment payment=new MPayment(getCtx(),getC_Payment_ID(),get_TrxName());
if ((newRecord || is_ValueChanged("C_Invoice_ID")) && (payment.getC_Charge_ID() != 0 || payment.getC_Invoice_ID() != 0 || payment.getC_Order_ID() != 0)) {
log.saveError("PaymentIsAllocated","");
return false;
}
BigDecimal check=getAmount().add(getDiscountAmt()).add(getWriteOffAmt()).add(getOverUnderAmt());
if (check.compareTo(getInvoiceAmt()) != 0) {
log.saveError("Error",Msg.parseTranslation(getCtx(),"@InvoiceAmt@(" + getInvoiceAmt() + ") <> @Totals@("+ check+ ")"));
return false;
}
if (newRecord || is_ValueChanged("C_Invoice_ID")) {
getInvoice();
if (m_invoice != null) setAD_Org_ID(m_invoice.getAD_Org_ID());
}
return true;
}
| Before Save |
public static int moveCodePointOffset(char source[],int start,int limit,int offset16,int shift32){
int size=source.length;
int count;
char ch;
int result=offset16 + start;
if (start < 0 || limit < start) {
throw new StringIndexOutOfBoundsException(start);
}
if (limit > size) {
throw new StringIndexOutOfBoundsException(limit);
}
if (offset16 < 0 || result > limit) {
throw new StringIndexOutOfBoundsException(offset16);
}
if (shift32 > 0) {
if (shift32 + result > size) {
throw new StringIndexOutOfBoundsException(result);
}
count=shift32;
while (result < limit && count > 0) {
ch=source[result];
if (isLeadSurrogate(ch) && (result + 1 < limit) && isTrailSurrogate(source[result + 1])) {
result++;
}
count--;
result++;
}
}
else {
if (result + shift32 < start) {
throw new StringIndexOutOfBoundsException(result);
}
for (count=-shift32; count > 0; count--) {
result--;
if (result < start) {
break;
}
ch=source[result];
if (isTrailSurrogate(ch) && result > start && isLeadSurrogate(source[result - 1])) {
result--;
}
}
}
if (count != 0) {
throw new StringIndexOutOfBoundsException(shift32);
}
result-=start;
return result;
}
| Shifts offset16 by the argument number of codepoints within a subarray. |
public void technicalServiceChanged(ValueChangeEvent event){
Long newServiceKey=(Long)event.getNewValue();
techServiceBean.setSelectedTechnicalServiceKeyWithExceptionAndRefresh(newServiceKey.longValue());
supplierIdToAdd=null;
suppliersForTechnicalService=null;
}
| Called by the value changed listener of the technical service selectionOneMenu. |
protected Object readResp() throws Exception {
InputStream is=huc.getInputStream();
Value mpo=packer.read(is);
return unMsg(mpo);
}
| Receives an RPC response and converts to an object |
public Object convert(final String value,final Class<?> clazz){
Converter converter=this.lookup(clazz);
if (converter == null) {
converter=this.lookup(String.class);
}
return converter.convert(clazz,value);
}
| Convert the specified value to an object of the specified class (if possible). Otherwise, return a String representation of the value. |
@DSComment("Package priviledge") @DSBan(DSCat.DEFAULT_MODIFIER) @DSGenerator(tool_name="Doppelganger",tool_version="2.0",generated_on="2013-12-30 12:56:25.397 -0500",hash_original_method="0360B175C51ABE1598A686E1C95592B6",hash_generated_method="90506082E3D0459E2C81EA8FB00BD16F") void remove(ThreadLocal<?> key){
cleanUp();
for (int index=key.hash & mask; ; index=next(index)) {
Object reference=table[index];
if (reference == key.reference) {
table[index]=TOMBSTONE;
table[index + 1]=null;
tombstones++;
size--;
return;
}
if (reference == null) {
return;
}
}
}
| Removes entry for the given ThreadLocal. |
@DSSafe(DSCat.SAFE_OTHERS) @DSGenerator(tool_name="Doppelganger",tool_version="2.0",generated_on="2013-12-30 13:01:36.047 -0500",hash_original_method="53A11CFB931BDAEE1F32CE61EF0BEDA2",hash_generated_method="42AD5E13A84C0A5943C2A2C723DC64B6") public UnsupportedDigestAlgorithmException(String message){
super(message);
}
| Creates a new UnsupportedAuthAlgoritmException with the specified message. |
public static int interleave(int x,int y,int z){
if (((x | y | z) & 0xFFFFFC00) != 0) throw new IllegalArgumentException("Overflow");
return part1by2(x) | (part1by2(y) << 1) | (part1by2(z) << 2);
}
| Interleaves the bits of the three specified integer values (Morton code). |
public Type3Message(byte[] material) throws IOException {
parse(material);
}
| Creates a Type-3 message using the given raw Type-3 material. |
public static String formatDecimalNumber(double number,String pattern,Locale locale){
com.ibm.icu.text.NumberFormat nf=com.ibm.icu.text.NumberFormat.getNumberInstance(locale);
String nbParsing="";
((com.ibm.icu.text.DecimalFormat)nf).applyPattern(pattern);
((com.ibm.icu.text.DecimalFormat)nf).toPattern();
nbParsing=nf.format(number);
return nbParsing;
}
| Format a decimal number to the pattern given |
public cudaStream_t(){
}
| Creates a new, uninitialized cudaStream_t |
public static void main(String... args) throws Exception {
String targetDir=args.length == 0 ? "." : args[0];
Class.forName("org.h2.Driver");
Connection conn=DriverManager.getConnection("jdbc:h2:mem:","sa","");
InputStream in=Newsfeed.class.getResourceAsStream("newsfeed.sql");
ResultSet rs=RunScript.execute(conn,new InputStreamReader(in,"ISO-8859-1"));
in.close();
while (rs.next()) {
String file=rs.getString("FILE");
String content=rs.getString("CONTENT");
if (file.endsWith(".txt")) {
content=convertHtml2Text(content);
}
new File(targetDir).mkdirs();
FileOutputStream out=new FileOutputStream(targetDir + "/" + file);
Writer writer=new OutputStreamWriter(out,"UTF-8");
writer.write(content);
writer.close();
out.close();
}
conn.close();
}
| This method is called when executing this sample application from the command line. |
public static String convertMoRefToString(ManagedObjectReference ref){
if (ref == null) {
return null;
}
return ref.getType() + DELIMITER + ref.getValue();
}
| Serializes a MoRef into a String. |
@ApiOperation(value="Delete user",notes="Delete a user from the system. Roles allowed: system/admin") @ApiResponses({@ApiResponse(code=204,message="Deleted"),@ApiResponse(code=404,message="Not Found"),@ApiResponse(code=409,message="Impossible to remove user"),@ApiResponse(code=500,message="Internal Server Error")}) @DELETE @Path("/{id}") @GenerateLink(rel=LINK_REL_REMOVE_USER_BY_ID) @RolesAllowed("system/admin") public void remove(@ApiParam(value="User ID") @PathParam("id") String id) throws NotFoundException, ServerException, ConflictException {
userDao.remove(id);
}
| Removes user with given identifier. |
@Override public Object primDie(final IScope scope) throws GamaRuntimeException {
GAMA.closeExperiment(getSpecies());
GAMA.getGui().closeSimulationViews(true,false);
return null;
}
| Method primDie() |
public Request createRequest(javax2.sip.address.URI requestURI,String method,CallIdHeader callId,CSeqHeader cSeq,FromHeader from,ToHeader to,List via,MaxForwardsHeader maxForwards,ContentTypeHeader contentType,byte[] content) throws ParseException {
if (requestURI == null || method == null || callId == null || cSeq == null || from == null || to == null || via == null || maxForwards == null || content == null || contentType == null) throw new NullPointerException("missing parameters");
SIPRequest sipRequest=new SIPRequest();
sipRequest.setRequestURI(requestURI);
sipRequest.setMethod(method);
sipRequest.setCallId(callId);
sipRequest.setCSeq(cSeq);
sipRequest.setFrom(from);
sipRequest.setTo(to);
sipRequest.setVia(via);
sipRequest.setMaxForwards(maxForwards);
sipRequest.setContent(content,contentType);
if (userAgent != null) {
sipRequest.setHeader(userAgent);
}
return sipRequest;
}
| Creates a new Request message of type specified by the method paramater, containing the URI of the Request, the mandatory headers of the message with a body in the form of a byte array and body content type. |
private FakeCrashLibrary(){
throw new AssertionError("No instances.");
}
| Not a real crash reporting library! |
@Override public Object eGet(int featureID,boolean resolve,boolean coreType){
switch (featureID) {
case GamlPackage.SDECLARATION__NAME:
return getName();
}
return super.eGet(featureID,resolve,coreType);
}
| <!-- begin-user-doc --> <!-- end-user-doc --> |
@Override public Object eGet(int featureID,boolean resolve,boolean coreType){
switch (featureID) {
case ExpressionsPackage.CONDITIONAL_EXPRESSION__CONDITION:
return getCondition();
case ExpressionsPackage.CONDITIONAL_EXPRESSION__TRUE_CASE:
return getTrueCase();
case ExpressionsPackage.CONDITIONAL_EXPRESSION__FALSE_CASE:
return getFalseCase();
}
return super.eGet(featureID,resolve,coreType);
}
| <!-- begin-user-doc --> <!-- end-user-doc --> |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.