code
stringlengths 10
174k
| nl
stringlengths 3
129k
|
---|---|
public T caseTypeSpecifier(TypeSpecifier object){
return null;
}
| Returns the result of interpreting the object as an instance of '<em>Type Specifier</em>'. <!-- begin-user-doc --> This implementation returns null; returning a non-null result will terminate the switch. <!-- end-user-doc --> |
@DSGenerator(tool_name="Doppelganger",tool_version="2.0",generated_on="2014-02-25 10:38:06.878 -0500",hash_original_method="42A30DA5805C25DC1FF8BB76E1D4A883",hash_generated_method="B0E719B437F0CB56217298A3A09102B7") public Reader retrieveHeader(String header,int lowArticleNumber,int highArticleNumber) throws IOException {
return __retrieveHeader(header,new String(lowArticleNumber + "-" + highArticleNumber));
}
| Return an article header for all articles between lowArticleNumber and highArticleNumber, inclusively. <p> |
public void w(Object str){
if (debug) {
if (logLevel <= Log.WARN) {
String name=getFunctionName();
if (name != null) {
Log.w(tag,name + "\n" + str+ "\n------------------------------------------------------------------------------");
}
else {
Log.w(tag,str.toString());
}
}
}
}
| The Log Level:w |
public void throwException(){
mv.visitInsn(Opcodes.ATHROW);
}
| Generates the instruction to throw an exception. |
public static short max(short a,short b,short c){
if (b > a) {
a=b;
}
if (c > a) {
a=c;
}
return a;
}
| <p>Gets the maximum of three <code>short</code> values.</p> |
public void paint(Graphics g,Rectangle bounds){
Color temp=g.getColor();
g.setColor(color);
g.fillRect(bounds.x,bounds.y,bounds.width,bounds.height);
g.setColor(temp);
}
| Paints the background. |
private void shortcutToggle(ActionEvent e,DeployUtilities.ToggleType toggleType){
boolean checkBoxState=true;
if (e.getSource() instanceof JCheckBoxMenuItem) {
checkBoxState=((JCheckBoxMenuItem)e.getSource()).getState();
}
if (shortcutCreator.getJarPath() == null) {
showErrorDialog("Unable to determine jar path; " + toggleType + " entry cannot succeed.");
return;
}
if (!checkBoxState) {
if (confirmDialog.prompt("Remove " + name + " from "+ toggleType+ "?")) {
if (!shortcutCreator.removeShortcut(toggleType)) {
displayErrorMessage("Error removing " + toggleType + " entry");
checkBoxState=true;
}
else {
displayInfoMessage("Successfully removed " + toggleType + " entry");
}
}
else {
checkBoxState=true;
}
}
else {
if (!shortcutCreator.createShortcut(toggleType)) {
displayErrorMessage("Error creating " + toggleType + " entry");
checkBoxState=false;
}
else {
displayInfoMessage("Successfully added " + toggleType + " entry");
}
}
if (e.getSource() instanceof JCheckBoxMenuItem) {
((JCheckBoxMenuItem)e.getSource()).setState(checkBoxState);
}
}
| Process toggle/checkbox events as they relate to creating shortcuts |
protected POInfo initPO(Properties ctx){
POInfo poi=POInfo.getPOInfo(ctx,Table_ID,get_TrxName());
return poi;
}
| Load Meta Data |
public StaticAnalysisStat(String statName){
this.statName=statName;
}
| Create a new, initially empty statistics object. |
public URI(String p_scheme,String p_userinfo,String p_host,int p_port,String p_path,String p_queryString,String p_fragment) throws MalformedURIException {
if (p_scheme == null || p_scheme.trim().length() == 0) {
throw new MalformedURIException(Utils.messages.createMessage(MsgKey.ER_SCHEME_REQUIRED,null));
}
if (p_host == null) {
if (p_userinfo != null) {
throw new MalformedURIException(Utils.messages.createMessage(MsgKey.ER_NO_USERINFO_IF_NO_HOST,null));
}
if (p_port != -1) {
throw new MalformedURIException(Utils.messages.createMessage(MsgKey.ER_NO_PORT_IF_NO_HOST,null));
}
}
if (p_path != null) {
if (p_path.indexOf('?') != -1 && p_queryString != null) {
throw new MalformedURIException(Utils.messages.createMessage(MsgKey.ER_NO_QUERY_STRING_IN_PATH,null));
}
if (p_path.indexOf('#') != -1 && p_fragment != null) {
throw new MalformedURIException(Utils.messages.createMessage(MsgKey.ER_NO_FRAGMENT_STRING_IN_PATH,null));
}
}
setScheme(p_scheme);
setHost(p_host);
setPort(p_port);
setUserinfo(p_userinfo);
setPath(p_path);
setQueryString(p_queryString);
setFragment(p_fragment);
}
| Construct a new URI that follows the generic URI syntax from its component parts. Each component is validated for syntax and some basic semantic checks are performed as well. See the individual setter methods for specifics. |
public ResolvableMethod annotated(Class<? extends Annotation> annotationType){
this.annotationTypes.add(annotationType);
return this;
}
| Methods with the given annotation. |
public StageProgressTracker(String name,int threadCount){
this.name=name;
this.threadCount=threadCount;
this.taskInfo=new TaskProgress[threadCount];
this.committedSeqno=new AtomicIntervalGuard<ReplDBMSHeader>(threadCount);
for (int i=0; i < taskInfo.length; i++) taskInfo[i]=new TaskProgress(name,i);
if (logger.isDebugEnabled()) {
logger.info("Initiating stage process tracker for stage: name=" + name + " threadCount="+ threadCount);
}
}
| Creates a new stage process tracker. |
public static float function3(float x){
return x * x + 2 * x + 1;
}
| Second-order polynomial. |
private void updateProgress(String progressLabel,int progress){
if (myHost != null && ((progress != previousProgress) || (!progressLabel.equals(previousProgressLabel)))) {
myHost.updateProgress(progressLabel,progress);
}
previousProgress=progress;
previousProgressLabel=progressLabel;
}
| Used to communicate a progress update between a plugin tool and the main Whitebox user interface. |
public static boolean checkTransactionFees(int size,Transaction transaction,TransactionOutput output){
long in=output.getValue().value;
long out=0;
for ( TransactionOutput o : transaction.getOutputs()) {
out+=o.getValue().value;
}
long diff=in - out;
float f=((float)diff) / size;
if (f >= Constants.FEE_PER_BYTE_MIN) {
if (f <= Constants.FEE_PER_BYTE_MAX) {
return true;
}
}
System.out.println("Fee not correct. Total Fee: " + diff + " Per Byte: "+ f+ " Size: "+ size);
return false;
}
| Check transaction fees. |
public void cancel(){
cancel=true;
}
| Calling this method cancels the event |
@Override public void receiveEmptyMessage(Exchange exchange,EmptyMessage message){
if (exchange.getFailedTransmissionCount() != 0) {
getRemoteEndpoint(exchange).setEstimatorState(exchange);
}
super.receiveEmptyMessage(exchange,message);
calculateRTT(exchange);
checkRemoteEndpointQueue(exchange);
}
| If we receive an ACK or RST, calculate the RTT and update the RTO values |
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
s.defaultWriteObject();
s.writeDouble(get());
}
| Saves the state to a stream (that is, serializes it). |
private void read(InputNode node,Object source,Schema schema) throws Exception {
Section section=schema.getSection();
readVersion(node,source,schema);
readSection(node,source,section);
}
| This <code>read</code> method performs deserialization of the XML schema class type by traversing the contacts and instantiating them using details from the provided XML element. Because this will convert a non-primitive value it delegates to other converters to perform deserialization of lists and primitives. <p> If any of the required contacts are not present within the provided XML element this will terminate deserialization and throw an exception. The annotation missing is reported in the exception. |
@Override public void eSet(int featureID,Object newValue){
switch (featureID) {
case SGraphPackage.SPECIFICATION_ELEMENT__SPECIFICATION:
setSpecification((String)newValue);
return;
}
super.eSet(featureID,newValue);
}
| <!-- begin-user-doc --> <!-- end-user-doc --> |
public static boolean isStatic(int mod){
return (mod & STATIC) != 0;
}
| Returns true if the modifiers include the <tt>static</tt> modifier. |
private int dp2px(int dp){
return (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,dp,this.mMetrics);
}
| Dp to px |
private void testBillingWithSteppedPricesForEvents(int eventsNumber,BigDecimal expectedCosts,BigDecimal[] stepLimit,BigDecimal[] stepCosts,int freePeriod) throws Exception {
final int testMonth=Calendar.APRIL;
final int testDay=1;
final int testYear=2010;
final long billingTime=getTimeInMillisForBilling(testYear,testMonth,testDay);
long subscriptionCreationTime=getTimeInMillisForBilling(testYear,testMonth - 2,testDay);
long subscriptionActivationTime=subscriptionCreationTime;
long eventOccurTime=billingTime - 1;
testBillingWithSteppedPricesForEvents(eventsNumber,expectedCosts,stepLimit,stepCosts,freePeriod,billingTime,subscriptionCreationTime,subscriptionActivationTime,eventOccurTime);
}
| Billing test for price model with stepped price. |
public Field newField(Class<?> declaringClass,String name,Class<?> type,int modifiers,int slot,String signature,byte[] annotations){
return langReflectAccess().newField(declaringClass,name,type,modifiers,slot,signature,annotations);
}
| Creates a new java.lang.reflect.Field. Access checks as per java.lang.reflect.AccessibleObject are not overridden. |
public void runTest() throws Throwable {
Document doc;
NodeList elementList;
Node nameNode;
CharacterData child;
String childData;
doc=(Document)load("hc_staff",true);
elementList=doc.getElementsByTagName("strong");
nameNode=elementList.item(0);
child=(CharacterData)nameNode.getFirstChild();
child.appendData(", Esquire");
childData=child.getData();
assertEquals("characterdataAppendDataGetDataAssert","Margaret Martin, Esquire",childData);
}
| Runs the test case. |
public static long convertDateValueToMillis(TimeZone tz,long dateValue){
return getMillis(tz,yearFromDateValue(dateValue),monthFromDateValue(dateValue),dayFromDateValue(dateValue),0,0,0,0);
}
| Convert an encoded date value to millis, using the supplied timezone. |
public void elementDecl(String name,String model) throws SAXException {
if (m_inExternalDTD) return;
try {
final java.io.Writer writer=m_writer;
DTDprolog();
writer.write("<!ELEMENT ");
writer.write(name);
writer.write(' ');
writer.write(model);
writer.write('>');
writer.write(m_lineSep,0,m_lineSepLen);
}
catch ( IOException e) {
throw new SAXException(e);
}
}
| Report an element type declaration. <p>The content model will consist of the string "EMPTY", the string "ANY", or a parenthesised group, optionally followed by an occurrence indicator. The model will be normalized so that all whitespace is removed,and will include the enclosing parentheses.</p> |
public static double hypot(double a,double b){
double r;
if (Math.abs(a) > Math.abs(b)) {
r=b / a;
r=Math.abs(a) * Math.sqrt(1 + r * r);
}
else if (b != 0) {
r=a / b;
r=Math.abs(b) * Math.sqrt(1 + r * r);
}
else {
r=0.0;
}
return r;
}
| sqrt(a^2 + b^2) without under/overflow. |
public static void debug(String message){
StringBuffer buffer=new StringBuffer();
buffer.append(new Date(System.currentTimeMillis()));
buffer.append(" - [");
buffer.append(Thread.currentThread().getName());
buffer.append("] ");
buffer.append(message);
System.out.println(buffer.toString());
}
| Print a debug message to the console. Pre-pend the message with the current date and the name of the current thread. |
@Override public boolean isCancelled(){
return this.cancelled;
}
| Gets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins |
private void requestCoffeeList(){
List<String> inventory=new ArrayList<String>(4);
inventory.add(SupportUtils.SKU_ESPRESSO);
inventory.add(SupportUtils.SKU_CAPPUCCINO);
inventory.add(SupportUtils.SKU_ICED_COFFEE);
inventory.add(SupportUtils.SKU_EARL_GREY);
mIabHelper.queryInventoryAsync(true,inventory,mQueryInventoryListener);
}
| request asynchronously the coffee list |
Double computePortMetric(StoragePort port){
StorageSystem system=_dbClient.queryObject(StorageSystem.class,port.getStorageDevice());
DiscoveredDataObject.Type type=DiscoveredDataObject.Type.valueOf(system.getSystemType());
StringMap portMap=port.getMetrics();
double emaFactor=getEmaFactor(DiscoveredDataObject.Type.valueOf(system.getSystemType()));
if (emaFactor > 1.0) {
emaFactor=1.0;
}
Double portAvgBusy=MetricsKeys.getDouble(MetricsKeys.avgPercentBusy,portMap);
Double portEmaBusy=MetricsKeys.getDouble(MetricsKeys.emaPercentBusy,portMap);
Double portPercentBusy=(portAvgBusy * emaFactor) + ((1 - emaFactor) * portEmaBusy);
MetricsKeys.putDouble(MetricsKeys.avgPortPercentBusy,portPercentBusy,port.getMetrics());
Double cpuAvgBusy=null;
Double cpuEmaBusy=null;
Double portMetricDouble=portPercentBusy;
if (type == DiscoveredDataObject.Type.vmax || type == DiscoveredDataObject.Type.vnxblock || type == DiscoveredDataObject.Type.vplex) {
StorageHADomain haDomain=_dbClient.queryObject(StorageHADomain.class,port.getStorageHADomain());
StringMap cpuMap=haDomain.getMetrics();
cpuAvgBusy=MetricsKeys.getDouble(MetricsKeys.avgPercentBusy,cpuMap);
cpuEmaBusy=MetricsKeys.getDouble(MetricsKeys.emaPercentBusy,cpuMap);
Double cpuPercentBusy=(cpuAvgBusy * emaFactor) + ((1 - emaFactor) * cpuEmaBusy);
MetricsKeys.putDouble(MetricsKeys.avgCpuPercentBusy,cpuPercentBusy,port.getMetrics());
portMetricDouble+=cpuPercentBusy;
portMetricDouble/=2.0;
}
_log.info(String.format("%s %s: portMetric %f port %f %f cpu %s %s",port.getNativeGuid(),portName(port),portMetricDouble,portAvgBusy,portEmaBusy,cpuAvgBusy == null ? "n/a" : cpuAvgBusy.toString(),cpuEmaBusy == null ? "n/a" : cpuEmaBusy.toString()));
return portMetricDouble;
}
| Compute the overall port metric given the port. The overall port metric is a equally weighted average of the port%busy and cpu%busy (if both port and cpu metrics are supported) normalized to a 0-100% scale. So 75% port busy and 25% cpu busy would be 100%/2 = 50% overall busy. The port%busy and cpu%busy are computed from the combination of short term and long term averages for each (respectively). This is (emaFactor * portAvgBusy + (1-emaFactor) * portEmaBusy) for example, where the first term is the short term average and the second term is the longer term average. |
private void populateAccessProfile(AccessProfile accessProfile,StorageSystem storageDevice,String nameSpace) throws DatabaseException, DeviceControllerException {
accessProfile.setSystemId(storageDevice.getId());
accessProfile.setSystemClazz(storageDevice.getClass());
if (Type.vnxblock.toString().equalsIgnoreCase(storageDevice.getSystemType()) || Type.vmax.toString().equalsIgnoreCase(storageDevice.getSystemType()) || Type.ibmxiv.name().equals(storageDevice.getSystemType())) {
injectDiscoveryProfile(accessProfile,storageDevice);
if (null != nameSpace) {
accessProfile.setnamespace(nameSpace);
}
}
else if (Type.vnxfile.toString().equalsIgnoreCase(storageDevice.getSystemType())) {
accessProfile.setIpAddress(storageDevice.getIpAddress());
accessProfile.setUserName(storageDevice.getUsername());
accessProfile.setPassword(storageDevice.getPassword());
accessProfile.setSystemType(storageDevice.getSystemType());
accessProfile.setserialID(storageDevice.getSerialNumber());
if (null != storageDevice.getPortNumber()) {
accessProfile.setPortNumber(storageDevice.getPortNumber());
}
if (null != nameSpace) {
accessProfile.setnamespace(nameSpace);
}
}
else if (storageDevice.getSystemType().equals(Type.isilon.toString())) {
accessProfile.setSystemType(storageDevice.getSystemType());
accessProfile.setIpAddress(storageDevice.getIpAddress());
accessProfile.setUserName(storageDevice.getUsername());
accessProfile.setserialID(storageDevice.getSerialNumber());
accessProfile.setPassword(storageDevice.getPassword());
accessProfile.setPortNumber(storageDevice.getPortNumber());
accessProfile.setLastSampleTime(0L);
if (null != nameSpace) {
accessProfile.setnamespace(nameSpace);
}
}
else if (storageDevice.getSystemType().equals(Type.vplex.toString())) {
accessProfile.setSystemType(storageDevice.getSystemType());
accessProfile.setIpAddress(storageDevice.getIpAddress());
accessProfile.setUserName(storageDevice.getUsername());
accessProfile.setserialID(storageDevice.getSerialNumber());
accessProfile.setPassword(storageDevice.getPassword());
accessProfile.setPortNumber(storageDevice.getPortNumber());
accessProfile.setLastSampleTime(0L);
if (null != nameSpace) {
accessProfile.setnamespace(nameSpace);
}
}
else if (storageDevice.getSystemType().equals(Type.netapp.toString()) || storageDevice.getSystemType().equals(Type.netappc.toString()) || Type.vnxe.toString().equalsIgnoreCase(storageDevice.getSystemType())) {
accessProfile.setSystemType(storageDevice.getSystemType());
accessProfile.setIpAddress(storageDevice.getIpAddress());
accessProfile.setUserName(storageDevice.getUsername());
accessProfile.setPassword(storageDevice.getPassword());
accessProfile.setserialID(storageDevice.getSerialNumber());
accessProfile.setPortNumber(storageDevice.getPortNumber());
accessProfile.setLastSampleTime(0L);
if (null != nameSpace) {
accessProfile.setnamespace(nameSpace);
}
}
else if (storageDevice.getSystemType().equals(Type.rp.toString())) {
accessProfile.setSystemType(storageDevice.getSystemType());
accessProfile.setIpAddress(storageDevice.getIpAddress());
accessProfile.setUserName(storageDevice.getUsername());
accessProfile.setserialID(storageDevice.getSerialNumber());
accessProfile.setPassword(storageDevice.getPassword());
accessProfile.setPortNumber(storageDevice.getPortNumber());
accessProfile.setLastSampleTime(0L);
if (null != nameSpace) {
accessProfile.setnamespace(nameSpace);
}
}
else if (storageDevice.getSystemType().equals(Type.datadomain.toString())) {
injectDiscoveryProfile(accessProfile,storageDevice);
accessProfile.setPortNumber(storageDevice.getSmisPortNumber());
accessProfile.setLastSampleTime(0L);
if (null != nameSpace) {
accessProfile.setnamespace(nameSpace);
}
}
else if (storageDevice.getSystemType().equals(Type.scaleio.toString())) {
injectDiscoveryProfile(accessProfile,storageDevice);
if (null != nameSpace) {
accessProfile.setnamespace(nameSpace);
}
}
else if (storageDevice.getSystemType().equals(Type.openstack.toString())) {
accessProfile.setSystemType(storageDevice.getSystemType());
accessProfile.setIpAddress(storageDevice.getSmisProviderIP());
accessProfile.setUserName(storageDevice.getSmisUserName());
accessProfile.setserialID(storageDevice.getSerialNumber());
accessProfile.setPassword(storageDevice.getSmisPassword());
accessProfile.setPortNumber(storageDevice.getSmisPortNumber());
accessProfile.setLastSampleTime(0L);
}
else if (storageDevice.getSystemType().equals(Type.xtremio.toString())) {
accessProfile.setSystemType(storageDevice.getSystemType());
accessProfile.setIpAddress(storageDevice.getSmisProviderIP());
accessProfile.setUserName(storageDevice.getSmisUserName());
accessProfile.setPassword(storageDevice.getSmisPassword());
accessProfile.setPortNumber(storageDevice.getSmisPortNumber());
accessProfile.setLastSampleTime(0L);
if (null != nameSpace) {
accessProfile.setnamespace(nameSpace);
}
}
else if (storageDevice.getSystemType().equals(Type.ecs.toString())) {
accessProfile.setSystemType(storageDevice.getSystemType());
accessProfile.setIpAddress(storageDevice.getIpAddress());
accessProfile.setUserName(storageDevice.getUsername());
accessProfile.setserialID(storageDevice.getSerialNumber());
accessProfile.setPassword(storageDevice.getPassword());
accessProfile.setPortNumber(storageDevice.getPortNumber());
accessProfile.setLastSampleTime(0L);
if (null != nameSpace) {
accessProfile.setnamespace(nameSpace);
}
}
else if (storageDevice.getSystemType().equals(Type.hds.toString())) {
populateHDSAccessProfile(accessProfile,storageDevice,nameSpace);
}
else if (storageDevice.getSystemType().equals(Type.ceph.toString())) {
accessProfile.setSystemType(storageDevice.getSystemType());
accessProfile.setIpAddress(storageDevice.getSmisProviderIP());
accessProfile.setUserName(storageDevice.getSmisUserName());
accessProfile.setserialID(storageDevice.getSerialNumber());
accessProfile.setPassword(storageDevice.getSmisPassword());
accessProfile.setLastSampleTime(0L);
}
else if (StorageSystem.Type.isDriverManagedStorageSystem(storageDevice.getSystemType())) {
if (StorageSystem.Type.isProviderStorageSystem(storageDevice.getSystemType())) {
injectDiscoveryProfile(accessProfile,storageDevice);
StorageProvider provider=getActiveProviderForStorageSystem(storageDevice,accessProfile);
accessProfile.setPortNumber(provider.getPortNumber());
}
else {
accessProfile.setSystemType(storageDevice.getSystemType());
accessProfile.setIpAddress(storageDevice.getIpAddress());
accessProfile.setUserName(storageDevice.getUsername());
accessProfile.setserialID(storageDevice.getSerialNumber());
accessProfile.setPassword(storageDevice.getPassword());
accessProfile.setPortNumber(storageDevice.getPortNumber());
accessProfile.setLastSampleTime(0L);
}
if (null != nameSpace) {
accessProfile.setnamespace(nameSpace);
}
}
else if (storageDevice.getSystemType().equals(Type.unity.toString())) {
populateUnityAccessProfileForSystem(accessProfile,storageDevice);
if (null != nameSpace) {
accessProfile.setnamespace(nameSpace);
}
}
else {
throw new RuntimeException("populateAccessProfile: Device type unknown : " + storageDevice.getSystemType());
}
}
| Populate accessProfile values from storageDevice. |
public boolean isSafeDeleteAvailable(@NotNull PsiElement element){
return false;
}
| Checks if the Safe Delete refactoring can be applied to the specified element in the language. The Safe Delete refactoring also requires the plugin to implement Find Usages functionality. |
public static void writeByteCollection(DataOutput out,Collection<Byte> col) throws IOException {
if (col != null) {
out.writeInt(col.size());
for ( Byte i : col) out.writeByte(i);
}
else out.writeInt(-1);
}
| // FIXME: added for DR dataCenterIds, review if it is needed after GG-6879. |
public boolean isBlockCarsEnabled(){
return (0 < (_blockOptions & BLOCK_CARS));
}
| When enabled block cars from staging. |
public boolean matchCase(final Dictionary<String,?> map){
Object temp=null;
temp=map.get(id);
if (temp == null) {
return false;
}
if (comparator == PRESENT) {
return true;
}
final Object attr=temp;
try {
if (attr instanceof String) {
return compareStringCase(value,comparator,(String)attr);
}
else if (attr instanceof Number) {
return compareNumber(value.trim(),comparator,(Number)attr);
}
else if (attr instanceof String[]) {
final String[] array=(String[])attr;
if (array.length == 0) {
return false;
}
final String val=comparator == APPROX ? stripWhitespaces(value) : value;
for (int i=0; i < array.length; i++) {
if (compareStringCase(val,comparator,array[i])) {
return true;
}
}
return false;
}
else if (attr instanceof Boolean) {
return (comparator == EQUALS || comparator == APPROX) && ((Boolean)attr).equals(Boolean.valueOf(value));
}
else if (attr instanceof Character) {
return value.length() == 1 ? compareTyped(new Character(value.charAt(0)),comparator,(Character)attr) : false;
}
else if (attr instanceof Collection) {
final Collection<?> col=(Collection<?>)attr;
final Object[] obj=col.toArray();
return compareArrayCase(value,comparator,obj);
}
else if (attr instanceof Object[]) {
return compareArrayCase(value,comparator,(Object[])attr);
}
else if (attr.getClass().isArray()) {
for (int i=0; i < Array.getLength(attr); i++) {
final Object obj=Array.get(attr,i);
if (obj instanceof Number && compareNumber(value,comparator,(Number)obj) || obj instanceof Character && compareTyped(new Character(value.trim().charAt(0)),comparator,(Character)obj) || compareReflective(value,comparator,obj)) {
return true;
}
}
return false;
}
else {
return compareReflective(value,comparator,attr);
}
}
catch ( final Throwable t) {
return false;
}
}
| check if the filter matches a dictionary of attributes. This method id case sensitive. |
public static BlankFragment newInstance(String param1,int param2){
BlankFragment fragment=new BlankFragment();
Bundle args=new Bundle();
args.putString(ARG_PARAM1,param1);
args.putInt(ARG_PARAM2,param2);
fragment.setArguments(args);
return fragment;
}
| Use this factory method to create a new instance of this fragment using the provided parameters. |
public static void restoreDefaultSetting(String key){
Object object=DEFAULT_MAP.get(key);
if (object != null) {
if (object instanceof String) {
SIMBRAIN_PREFERENCES.put(key,(String)object);
}
else if (object instanceof Double) {
SIMBRAIN_PREFERENCES.putDouble(key,(Double)object);
}
else if (object instanceof Integer) {
SIMBRAIN_PREFERENCES.putInt(key,(Integer)object);
}
else if (object instanceof Float) {
SIMBRAIN_PREFERENCES.putFloat(key,(Float)object);
}
}
}
| Reverts a setting to its default value. |
public Collection<AISValidationFailure> failures(){
return Collections.unmodifiableCollection(failureList);
}
| Gets all failures, if there were any. The collection will be unmodifiable and immutable; if it is not empty, subsequent invocations of this method may all return same collection instance, but only as long as no additional failures are reported. If new failures are reported, they and the previous will be in a new collection instance. |
private TcpHostCandidate findCandidate(Component component,Socket socket){
InetAddress localAddress=socket.getLocalAddress();
int localPort=socket.getLocalPort();
for ( LocalCandidate candidate : component.getLocalCandidates()) {
TransportAddress transportAddress=candidate.getTransportAddress();
if (candidate instanceof TcpHostCandidate && Transport.TCP.equals(transportAddress.getTransport()) && localPort == transportAddress.getPort() && localAddress.equals(transportAddress.getAddress())) {
return (TcpHostCandidate)candidate;
}
}
return null;
}
| Searches among the local candidates of <tt>Component</tt> for a <tt>TcpHostCandidate</tt> with the same transport address as the local transport address of <tt>socket</tt>. We expect to find such a candidate, which has been added by this <tt>TcpHarvester</tt> while harvesting. |
private void processReport(int id,long seqno,long time,D datum){
ThreadPosition tp=array.get(id);
if (tp == null) {
tp=new ThreadPosition();
tp.id=id;
tp.seqno=seqno;
tp.time=time;
tp.reportTime=System.currentTimeMillis();
tp.datum=datum;
array.put(id,tp);
if (head == null) {
head=tp;
tail=tp;
}
else {
ThreadPosition nextTp=head;
while (nextTp != null) {
if (nextTp.seqno > tp.seqno) {
if (nextTp.before != null) nextTp.before.after=tp;
tp.before=nextTp.before;
tp.after=nextTp;
nextTp.before=tp;
break;
}
nextTp=nextTp.after;
}
if (nextTp == null) {
tail.after=tp;
tp.before=tail;
tail=tp;
}
if (tp.before == null) head=tp;
}
}
else {
if (tp.seqno > seqno) bug("Thread reporting position moved backwards: task=" + id + " previous seqno="+ tp.seqno+ " new seqno="+ seqno);
tp.seqno=seqno;
tp.time=time;
tp.reportTime=System.currentTimeMillis();
tp.datum=datum;
ThreadPosition nextTp=tp.after;
while (nextTp != null && tp.seqno > tp.after.seqno) {
if (tp.before != null) tp.before.after=nextTp;
if (nextTp.after != null) nextTp.after.before=tp;
nextTp.before=tp.before;
tp.after=nextTp.after;
nextTp.after=tp;
tp.before=nextTp;
if (head == tp) head=nextTp;
nextTp=tp.after;
}
if (tp.after == null) tail=tp;
}
}
| Insert the reported position into the array using the seqno for ordering. |
public void addFilter(ValueExpr theExpr){
mFilters.add(theExpr);
}
| Add a Filter to this group |
public void connected(){
}
| Called when the DDM server connects. The handler is allowed to send messages to the server. |
public QuestNotStartedCondition(final String questname){
this.questname=checkNotNull(questname);
}
| Creates a new QuestNotStartedCondtion. |
VcfReader(TabixLineReader reader,VcfHeader header) throws IOException {
mIn=reader;
mHeader=header;
mNumSamples=mHeader.getNumberOfSamples();
setNext();
}
| Read VcfRecords from a region of a block-compressed file |
public boolean isAllowedToResendTransfer() throws RcsPersistentStorageException, RcsGenericException {
try {
return mTransferInf.isAllowedToResendTransfer();
}
catch ( Exception e) {
RcsPersistentStorageException.assertException(e);
throw new RcsGenericException(e);
}
}
| Returns whether you can resend the transfer. |
public static double powQuick(double value,double power){
if (USE_JDK_MATH) {
return STRICT_MATH ? StrictMath.pow(value,power) : Math.pow(value,power);
}
return FastMath.exp(power * FastMath.logQuick(value));
}
| Quick pow, with a max relative error of about 3.5e-2 for |a^b| < 1e10, of about 0.17 for |a^b| < 1e50, and worse accuracy above. |
public void testParameters() throws Exception {
Similarity sim=getSimilarity("text_params");
assertEquals(LMDirichletSimilarity.class,sim.getClass());
LMDirichletSimilarity lm=(LMDirichletSimilarity)sim;
assertEquals(1000f,lm.getMu(),0.01f);
}
| dirichlet with parameters |
protected void startAnimationTimer(){
if (animator == null) {
animator=new Animator();
}
animator.start(getRepaintInterval());
}
| Starts the animation thread, creating and initializing it if necessary. This method is invoked when an indeterminate progress bar should start animating. Reasons for this may include: <ul> <li>The progress bar is determinate and becomes displayable <li>The progress bar is displayable and becomes determinate <li>The progress bar is displayable and determinate and this UI is installed </ul> If you implement your own animation thread, you must override this method. |
@Override public void eSet(int featureID,Object newValue){
switch (featureID) {
case StextPackage.TRANSITION_SPECIFICATION__REACTION:
setReaction((TransitionReaction)newValue);
return;
}
super.eSet(featureID,newValue);
}
| <!-- begin-user-doc --> <!-- end-user-doc --> |
public int lastRemaining(int n){
int start=1;
int step=2;
int len=n;
boolean isFromLeft=true;
while (len != 1) {
len>>=1;
if (isFromLeft) {
start=start + step * len - step / 2;
}
else {
start=start - step * len + step / 2;
}
step<<=1;
isFromLeft=!isFromLeft;
}
return start;
}
| Calculate the start point of next round with: The start point of this round, the step, the number of removed integers. If from left, start = start + step * len - step / 2 If from right, start = start - step * len + step / 2 step / 2 is actually the step of last round. Stop when only one integer remain. |
public void testRenameFileSourceMissing() throws Exception {
create(igfsSecondary,paths(DIR,SUBDIR),paths(FILE));
create(igfs,null,null);
igfs.rename(FILE,FILE2);
checkExist(igfs,DIR,SUBDIR);
checkExist(igfs,igfsSecondary,FILE2);
checkNotExist(igfs,igfsSecondary,FILE);
}
| Test rename in case source doesn't exist and the path being renamed is a file. |
public final int yylength(){
return zzMarkedPos - zzStartRead;
}
| Returns the length of the matched text region. |
final void advance(){
for (; ; ) {
if (nextTableIndex >= 0) {
if ((nextEntry=entryAt(currentTable,nextTableIndex--)) != null) break;
}
else if (nextSegmentIndex >= 0) {
Segment<K,V> seg=segmentAt(segments,nextSegmentIndex--);
if (seg != null && (currentTable=seg.table) != null) nextTableIndex=currentTable.length - 1;
}
else break;
}
}
| Sets nextEntry to first node of next non-empty table (in backwards order, to simplify checks). |
public BasicBlock firstInCodeOrder(){
return (BasicBlock)_firstNode;
}
| Return the first basic block with respect to the current code linearization order. |
public LocalProcessController(final int pid){
if (pid < 1) {
throw new IllegalArgumentException("Invalid pid '" + pid + "' specified");
}
this.pid=pid;
}
| Constructs an instance for controlling a local process. |
public static void dumpCursor(Cursor cursor){
dumpCursor(cursor,System.out);
}
| Prints the contents of a Cursor to System.out. The position is restored after printing. |
public BigInteger validateDHKeyPair(AsymmetricCipherKeyPair pair){
DHPrivateKeyParameters priv=(DHPrivateKeyParameters)pair.getPrivate();
DHPublicKeyParameters pub=(DHPublicKeyParameters)pair.getPublic();
assertNotNull(priv);
assertNotNull(pub);
BigInteger g=Crypto.DH_GROUP_PARAMETERS.getG();
BigInteger p=Crypto.DH_GROUP_PARAMETERS.getP();
assertEquals("Tests that the public key y == g^(private key x) mod p",pub.getY(),g.modPow(priv.getX(),p));
BigInteger foo=new BigInteger(Crypto.DH_SUBGROUP_SIZE,Crypto.random);
BigInteger gToTheFoo=g.modPow(foo,Crypto.DH_GROUP_PARAMETERS.getP());
BigInteger fooInverse=foo.modInverse(Crypto.DH_GROUP_PARAMETERS.getQ());
BigInteger newG=gToTheFoo.modPow(fooInverse,Crypto.DH_GROUP_PARAMETERS.getP());
assertEquals("Tests that we can inverse group exponentiation",g,newG);
return priv.getX();
}
| A helper routine that verifies that a given Diffie-Hellman keypair is valid. |
@Override public void handlePatch(Operation patch){
State currentState=getState(patch);
State patchState=patch.getBody(State.class);
try {
validatePatch(currentState,patchState);
applyPatch(currentState,patchState);
validateState(currentState);
patch.complete();
switch (currentState.taskInfo.stage) {
case STARTED:
handleStartedStage(currentState,patchState);
break;
case FAILED:
case FINISHED:
case CANCELLED:
break;
default :
throw new IllegalStateException(String.format("Invalid stage %s",currentState.taskInfo.stage));
}
}
catch (Throwable e) {
ServiceUtils.logSevere(this,e);
if (!OperationUtils.isCompleted(patch)) {
patch.fail(e);
}
}
}
| Patch operation handler. Implements all logic to drive our state machine. |
private static boolean isValid(long value,long minValue,long maxValue,long increment){
return minValue <= value && maxValue >= value && maxValue > minValue && increment != 0 && BigInteger.valueOf(increment).abs().compareTo(BigInteger.valueOf(maxValue).subtract(BigInteger.valueOf(minValue))) < 0;
}
| Validates the specified prospective start value, min value, max value and increment relative to each other, since each of their respective validities are contingent on the values of the other parameters. |
public CompiledST defineTemplate(String templateName,String template){
if (templateName.charAt(0) != '/') templateName="/" + templateName;
try {
CompiledST impl=defineTemplate(templateName,new CommonToken(GroupParser.ID,templateName),null,template,null);
return impl;
}
catch ( STException se) {
}
return null;
}
| for testing |
@Override protected final Object clone(){
return this;
}
| There is only intended to be a single instance of the NULL object, so the clone method returns itself. |
protected boolean useDrawerToggle(){
return true;
}
| Helper method to allow child classes to opt-out of having the hamburger menu. |
private void resetNextInetSocketAddress(Proxy proxy) throws IOException {
inetSocketAddresses=new ArrayList<>();
String socketHost;
int socketPort;
if (proxy.type() == Proxy.Type.DIRECT || proxy.type() == Proxy.Type.SOCKS) {
socketHost=address.url().host();
socketPort=address.url().port();
}
else {
SocketAddress proxyAddress=proxy.address();
if (!(proxyAddress instanceof InetSocketAddress)) {
throw new IllegalArgumentException("Proxy.address() is not an " + "InetSocketAddress: " + proxyAddress.getClass());
}
InetSocketAddress proxySocketAddress=(InetSocketAddress)proxyAddress;
socketHost=getHostString(proxySocketAddress);
socketPort=proxySocketAddress.getPort();
}
if (socketPort < 1 || socketPort > 65535) {
throw new SocketException("No route to " + socketHost + ":"+ socketPort+ "; port is out of range");
}
if (proxy.type() == Proxy.Type.SOCKS) {
inetSocketAddresses.add(InetSocketAddress.createUnresolved(socketHost,socketPort));
}
else {
List<InetAddress> addresses=address.dns().lookup(socketHost);
for (int i=0, size=addresses.size(); i < size; i++) {
InetAddress inetAddress=addresses.get(i);
inetSocketAddresses.add(new InetSocketAddress(inetAddress,socketPort));
}
}
nextInetSocketAddressIndex=0;
}
| Prepares the socket addresses to attempt for the current proxy or host. |
public static void addImports(final CompilationUnitRewrite rewrite,ImportRewriteContext context,final ASTNode node,final Map<Name,String> typeImports,final Map<Name,String> staticImports,final boolean declarations){
addImports(rewrite,context,node,typeImports,staticImports,null,declarations);
}
| Adds the necessary imports for an AST node to the specified compilation unit. |
private String issueInventory(){
if (m_M_Locator_ID == 0) throw new IllegalArgumentException("No Locator");
if (m_M_Product_ID == 0) throw new IllegalArgumentException("No Product");
if (m_MovementQty == null || m_MovementQty.signum() == 0) m_MovementQty=Env.ONE;
MProjectIssue pi=new MProjectIssue(m_project);
pi.setMandatory(m_M_Locator_ID,m_M_Product_ID,m_MovementQty);
if (m_MovementDate != null) pi.setMovementDate(m_MovementDate);
if (m_Description != null && m_Description.length() > 0) pi.setDescription(m_Description);
pi.process();
MProjectLine pl=new MProjectLine(m_project);
pl.setMProjectIssue(pi);
pl.saveEx();
addLog(pi.getLine(),pi.getMovementDate(),pi.getMovementQty(),null);
return "@Created@ 1";
}
| Issue from Inventory |
@DSGenerator(tool_name="Doppelganger",tool_version="2.0",generated_on="2014-09-03 15:00:47.305 -0400",hash_original_method="75025FE733C588323FB29CA64B72756D",hash_generated_method="FB333AB9EE3E9B39A75ADCDD9A7CC5B6") private URL createSearchURL(URL url) throws MalformedURLException {
if (url == null) {
return url;
}
String protocol=url.getProtocol();
if (isDirectory(url) || protocol.equals("jar")) {
return url;
}
if (factory == null) {
return new URL("jar","",-1,url.toString() + "!/");
}
return new URL("jar","",-1,url.toString() + "!/",factory.createURLStreamHandler("jar"));
}
| Returns an URL that will be checked if it contains the class or resource. If the file component of the URL is not a directory, a Jar URL will be created. |
public double absDet(){
double absDet=1.0;
for ( double d : s) absDet*=d;
return absDet;
}
| Computes the absolute value of the determinant for the full matrix. |
public RadialGradientApp(){
super("Radial Gradient");
JPanel panel=new JPanel();
panel.add(new SphereComponent());
add(panel);
pack();
setLocationRelativeTo(null);
}
| Creates a new instance of RadialGradientApp |
public static String generateXml(ApiClass element){
StringBuffer buffer=new StringBuffer(XML_START + element.name + XML_END+ "\n");
for ( ApiField field : element.fields) {
generateXml(field,1,buffer);
}
buffer.append(XML_START).append("/").append(element.name).append(XML_END);
return buffer.toString();
}
| Returns an XML Payload format for the given Api Class |
@Override public void releaseView(){
mView=null;
}
| PLIReleaseView methods |
public void paintScrollBarThumbBackground(SynthContext context,Graphics g,int x,int y,int w,int h,int orientation){
paintBackground(context,g,x,y,w,h,orientation);
}
| Paints the background of the thumb of a scrollbar. The thumb provides a graphical indication as to how much of the Component is visible in a <code>JScrollPane</code>. |
public void addFatalError(String msg){
addFatalError(msg,null);
}
| Adds a <code>FATAL</code> entry filled with the given message to this status. The severity of this status will changed to <code>FATAL</code>. |
public void addFirst(HDR obj){
hlist.add(0,(HDR)obj);
}
| Concatenate the list of stuff that we are keeping around and also the text corresponding to these structures (that we parsed). |
protected boolean isAuthProcess(HttpServletRequest request){
boolean result=false;
result=(getUseLdap(request).booleanValue() && getUsingOSAuth(request).booleanValue()) || StringUtils.isNotEmpty(getName(request));
return result;
}
| Metodo que comprueba si la peticion actual es un proceso de login |
public LogModule(Environment environment){
this.environment=environment;
}
| Creates a new LogModule which uses the given environment to determine the logging configuration. |
public int length(){
return m_length;
}
| Returns the length of this string. |
public static void main(String[] args){
String serverName=null;
String Filename=null;
if (args.length > 0) serverName=args[0];
if (args.length > 1) Filename=args[1];
if (serverName == null || serverName.length() == 0) {
try {
serverName=InetAddress.getLocalHost().getHostName();
}
catch ( Exception e) {
e.printStackTrace();
}
}
MD5EjbTest myMD5EjbTest=new MD5EjbTest(serverName,Filename);
}
| Start Method |
private void prepareTestEnvironment(){
given().body("{\"id\" : \"u1r1\"}").put("items/user1/res1");
given().body("{\"id\" : \"u1r2\"}").put("items/user1/res2");
given().body("{\"id\" : \"u2r1\"}").put("items/user2/res1");
given().body("{\"id\" : \"u2r2\"}").put("items/user2/res2");
}
| Creates some resources |
public CModuleNameLabel(final JTable table,final INaviModule module,final Color backgroundColor){
if (starImage == null) {
try {
starImage=new ImageIcon(CMain.class.getResource("data/star.png").toURI().toURL()).getImage();
}
catch ( final MalformedURLException e) {
}
catch ( final URISyntaxException e) {
}
}
m_table=table;
m_module=module;
if (normalFont == null) {
normalFont=new Font(this.getFont().getFontName(),Font.PLAIN,12);
normalBoldFont=new Font(this.getFont().getFontName(),Font.BOLD,12);
}
setBackground(backgroundColor);
setOpaque(true);
}
| Creates a new module name label object. |
public QName(String qname,PrefixResolver resolver,boolean validate){
String prefix=null;
_namespaceURI=null;
int indexOfNSSep=qname.indexOf(':');
if (indexOfNSSep > 0) {
prefix=qname.substring(0,indexOfNSSep);
if (prefix.equals("xml")) {
_namespaceURI=S_XMLNAMESPACEURI;
}
else {
_namespaceURI=resolver.getNamespaceForPrefix(prefix);
}
if (null == _namespaceURI) {
throw new RuntimeException(XMLMessages.createXMLMessage(XMLErrorResources.ER_PREFIX_MUST_RESOLVE,new Object[]{prefix}));
}
_localName=qname.substring(indexOfNSSep + 1);
}
else if (indexOfNSSep == 0) {
throw new RuntimeException(XMLMessages.createXMLMessage(XMLErrorResources.ER_NAME_CANT_START_WITH_COLON,null));
}
else {
_localName=qname;
}
if (validate) {
if ((_localName == null) || (!XML11Char.isXML11ValidNCName(_localName))) {
throw new IllegalArgumentException(XMLMessages.createXMLMessage(XMLErrorResources.ER_ARG_LOCALNAME_INVALID,null));
}
}
m_hashCode=toString().hashCode();
_prefix=prefix;
}
| Construct a QName from a string, resolving the prefix using the given namespace stack. The default namespace is not resolved. |
private void startNotification(){
mNotifyManager=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
mBuilder=new NotificationCompat.Builder(this).setContentTitle("Video Upload").setContentText("Upload in progress").setSmallIcon(android.R.drawable.stat_sys_upload).setTicker("Uploading video").setProgress(0,0,true);
mNotifyManager.notify(NOTIFICATION_ID,mBuilder.build());
}
| Starts the Notification to show the progress of video upload. |
public boolean isCancelled(){
AsyncHttpRequest _request=request.get();
return _request == null || _request.isCancelled();
}
| Returns true if this task was cancelled before it completed normally. |
public ToStringBuilder append(final String fieldName,final byte[] array){
style.append(buffer,fieldName,array,null);
return this;
}
| <p>Append to the <code>toString</code> a <code>byte</code> array.</p> |
public static void main(String[] args){
Header.printHeader(SanralPopulationConverter.class.toString(),args);
String inputFile=args[0];
String idPrefix=args[1];
String subPopulation=args[2];
Double fraction=Double.parseDouble(args[3]);
String outputFile=args[4];
String attributesFile=args[5];
String inputCRS=args[6];
String outputCRS=args[7];
Boolean convertDurationToEndTime=Boolean.parseBoolean(args[8]);
SanralPopulationConverter.Run(inputFile,idPrefix,inputCRS,subPopulation,fraction,outputFile,attributesFile,outputCRS,convertDurationToEndTime);
Header.printFooter();
}
| Running the population converter. |
protected HookExecutor.STATUS run() throws Exception {
this.hook.execute(events);
return HookExecutor.STATUS.EXECUTION_SCHEDULED;
}
| The HystrixCommand run method. Executes the Hook. |
public void idle(){
}
| Called every <code>IDLE_INTERVAL</code> ms. while waiting for a message. Overridden to allow insertion of asynch notifications. |
private void fciOrientbk(IKnowledge bk,Graph graph,List<Node> variables){
logger.log("info","Starting BK Orientation.");
for (Iterator<KnowledgeEdge> it=bk.forbiddenEdgesIterator(); it.hasNext(); ) {
KnowledgeEdge edge=it.next();
Node from=SearchGraphUtils.translate(edge.getFrom(),variables);
Node to=SearchGraphUtils.translate(edge.getTo(),variables);
if (from == null || to == null) {
continue;
}
if (graph.getEdge(from,to) == null) {
continue;
}
graph.setEndpoint(to,from,Endpoint.ARROW);
graph.setEndpoint(from,to,Endpoint.CIRCLE);
logger.log("knowledgeOrientation",SearchLogUtils.edgeOrientedMsg("Knowledge",graph.getEdge(from,to)));
}
for (Iterator<KnowledgeEdge> it=bk.requiredEdgesIterator(); it.hasNext(); ) {
KnowledgeEdge edge=it.next();
Node from=SearchGraphUtils.translate(edge.getFrom(),variables);
Node to=SearchGraphUtils.translate(edge.getTo(),variables);
if (from == null || to == null) {
continue;
}
if (graph.getEdge(from,to) == null) {
continue;
}
graph.setEndpoint(to,from,Endpoint.TAIL);
graph.setEndpoint(from,to,Endpoint.ARROW);
logger.log("knowledgeOrientation",SearchLogUtils.edgeOrientedMsg("Knowledge",graph.getEdge(from,to)));
}
logger.log("info","Finishing BK Orientation.");
}
| Orients according to background knowledge |
public static void decode(DecodeReturn d){
String dat=d.data;
int x=d.pos;
int len=d.data.length();
for (; x < len; x++) if (!Character.isWhitespace(dat.charAt(x))) break;
if (x == len) {
d.type=DecodeReturn.T_ERROR;
d.s="Out of tokens";
return;
}
switch (dat.charAt(x)) {
case 't':
if (x + 3 < len && dat.charAt(x + 1) == 'r' && dat.charAt(x + 2) == 'u' && dat.charAt(x + 3) == 'e') {
d.type=DecodeReturn.T_BOOLEAN;
d.l=1;
d.pos=x + 4;
return;
}
else {
d.type=DecodeReturn.T_ERROR;
d.s="Expected a (true) boolean";
return;
}
case 'T':
{
d.type=DecodeReturn.T_BOOLEAN;
d.l=1;
d.pos=x + 1;
return;
}
case 'F':
{
d.type=DecodeReturn.T_BOOLEAN;
d.l=0;
d.pos=x + 1;
return;
}
case 'f':
if (x + 4 < len && dat.charAt(x + 1) == 'a' && dat.charAt(x + 2) == 'l' && dat.charAt(x + 3) == 's' && dat.charAt(x + 4) == 'e') {
d.type=DecodeReturn.T_BOOLEAN;
d.l=0;
d.pos=x + 5;
return;
}
else {
boolean readHuman=false;
String sf=null;
int initial=x + 1;
for (; x < len; x++) if (dat.charAt(x) == '|') break;
if (x == initial) readHuman=true;
if (x >= len) {
d.type=DecodeReturn.T_ERROR;
d.s="Expected a float";
return;
}
if (!readHuman) sf=dat.substring(initial,x);
x++;
int initial2=x;
for (; x < len; x++) if (dat.charAt(x) == '|') break;
if (x >= len) {
d.type=DecodeReturn.T_ERROR;
d.s="Expected a float";
return;
}
if (readHuman) sf=dat.substring(initial2,x);
float f;
try {
if (readHuman) f=Float.parseFloat(sf);
else f=Float.intBitsToFloat(Integer.parseInt(sf));
}
catch (NumberFormatException e) {
d.type=DecodeReturn.T_ERROR;
d.s="Expected a float";
return;
}
d.type=DecodeReturn.T_FLOAT;
d.d=f;
d.pos=x + 1;
return;
}
case 'd':
{
boolean readHuman=false;
String sf=null;
int initial=x + 1;
for (; x < len; x++) if (dat.charAt(x) == '|') break;
if (x == initial) readHuman=true;
if (x >= len) {
d.type=DecodeReturn.T_ERROR;
d.s="Expected a double";
return;
}
if (!readHuman) sf=dat.substring(initial,x);
x++;
int initial2=x;
for (; x < len; x++) if (dat.charAt(x) == '|') break;
if (x >= len) {
d.type=DecodeReturn.T_ERROR;
d.s="Expected a double";
return;
}
if (readHuman) sf=dat.substring(initial2,x);
double f;
try {
if (readHuman) f=Double.parseDouble(sf);
else f=Double.longBitsToDouble(Long.parseLong(sf));
}
catch (NumberFormatException e) {
d.type=DecodeReturn.T_ERROR;
d.s="Expected a double";
return;
}
d.type=DecodeReturn.T_DOUBLE;
d.d=f;
d.pos=x + 1;
return;
}
case 'b':
{
int initial=x + 1;
for (; x < len; x++) if (dat.charAt(x) == '|') break;
if (x >= len) {
d.type=DecodeReturn.T_ERROR;
d.s="Expected a byte";
return;
}
String sf=dat.substring(initial,x);
byte f;
try {
f=Byte.parseByte(sf);
}
catch (NumberFormatException e) {
d.type=DecodeReturn.T_ERROR;
d.s="Expected a byte";
return;
}
d.type=DecodeReturn.T_BYTE;
d.l=f;
d.pos=x + 1;
return;
}
case 's':
{
int initial=x + 1;
for (; x < len; x++) if (dat.charAt(x) == '|') break;
if (x >= len) {
d.type=DecodeReturn.T_ERROR;
d.s="Expected a short";
return;
}
String sf=dat.substring(initial,x);
short f;
try {
f=Short.parseShort(sf);
}
catch (NumberFormatException e) {
d.type=DecodeReturn.T_ERROR;
d.s="Expected a short";
return;
}
d.type=DecodeReturn.T_SHORT;
d.l=f;
d.pos=x + 1;
return;
}
case 'i':
{
int initial=x + 1;
for (; x < len; x++) if (dat.charAt(x) == '|') break;
if (x >= len) {
d.type=DecodeReturn.T_ERROR;
d.s="Expected an int";
return;
}
String sf=dat.substring(initial,x);
int f;
try {
f=Integer.parseInt(sf);
}
catch (NumberFormatException e) {
d.type=DecodeReturn.T_ERROR;
d.s="Expected an int";
return;
}
d.type=DecodeReturn.T_INT;
d.l=f;
d.pos=x + 1;
return;
}
case 'l':
{
int initial=x + 1;
for (; x < len; x++) if (dat.charAt(x) == '|') break;
if (x >= len) {
d.type=DecodeReturn.T_ERROR;
d.s="Expected a long";
return;
}
String sf=dat.substring(initial,x);
long f;
try {
f=Long.parseLong(sf);
}
catch (NumberFormatException e) {
d.type=DecodeReturn.T_ERROR;
d.s="Expected a long";
return;
}
d.type=DecodeReturn.T_LONG;
d.l=f;
d.pos=x + 1;
return;
}
case '"':
{
StringBuilder sb=new StringBuilder();
boolean inUnicode=false;
x++;
for (; x < len; x++) {
char c=dat.charAt(x);
if (c == '"') {
if (inUnicode) {
d.type=DecodeReturn.T_ERROR;
d.s="Forgot to terminate Unicode with a '\\u' in the string";
return;
}
d.type=DecodeReturn.T_STRING;
d.s=sb.toString();
d.pos=x + 1;
return;
}
else if (c == '\\') {
x++;
if (x >= len) {
d.type=DecodeReturn.T_ERROR;
d.s="Unterminated String";
return;
}
if (dat.charAt(x) != 'u' && inUnicode) {
d.type=DecodeReturn.T_ERROR;
d.s="Escape character in Unicode sequence";
return;
}
switch (dat.charAt(x)) {
case 'u':
inUnicode=!inUnicode;
break;
case 'b':
sb.append('\b');
break;
case 'n':
sb.append('\n');
break;
case '"':
sb.append('"');
break;
case '\'':
sb.append('\'');
break;
case 't':
sb.append('\t');
break;
case '\\':
sb.append('\\');
break;
case '0':
sb.append('\0');
break;
default :
{
d.type=DecodeReturn.T_ERROR;
d.s="Bad escape char in String";
return;
}
}
}
else if (inUnicode) {
if (x + 3 >= len) {
d.type=DecodeReturn.T_ERROR;
d.s="Unterminated String";
return;
}
try {
sb.append((char)(Integer.decode("0x" + c + dat.charAt(x + 1)+ dat.charAt(x + 2)+ dat.charAt(x + 3)).intValue()));
;
x+=3;
}
catch (NumberFormatException e) {
d.type=DecodeReturn.T_ERROR;
d.s="Bad Unicode in String";
return;
}
}
else sb.append(c);
}
d.type=DecodeReturn.T_ERROR;
d.s="Unterminated String";
return;
}
case '\'':
{
x++;
if (x >= len) {
d.type=DecodeReturn.T_ERROR;
d.s="Unterminated char";
return;
}
char c=dat.charAt(x);
if (c == '\\') {
x++;
if (x >= len) {
d.type=DecodeReturn.T_ERROR;
d.s="Unterminated char";
return;
}
switch (dat.charAt(x)) {
case 'u':
if (x + 4 >= len) {
d.type=DecodeReturn.T_ERROR;
d.s="Unterminated char";
return;
}
try {
c=(char)(Integer.decode("0x" + dat.charAt(x + 1) + dat.charAt(x + 2)+ dat.charAt(x + 3)+ dat.charAt(x + 4)).intValue());
}
catch (NumberFormatException e) {
d.type=DecodeReturn.T_ERROR;
d.s="Bad Unicode in char";
return;
}
x+=5;
break;
case 'b':
c='\b';
x++;
break;
case 'n':
c='\n';
x++;
break;
case '"':
c='"';
x++;
break;
case '\'':
c='\'';
x++;
break;
case 't':
c='\t';
x++;
break;
case '\\':
c='\\';
x++;
break;
case '0':
c='\0';
x++;
break;
default :
{
d.type=DecodeReturn.T_ERROR;
d.s="Bad escape char in char";
return;
}
}
if (dat.charAt(x) != '\'') {
d.type=DecodeReturn.T_ERROR;
d.s="Bad char";
return;
}
d.type=DecodeReturn.T_CHAR;
d.l=c;
d.pos=x + 1;
return;
}
else {
x++;
if (x >= len) {
d.type=DecodeReturn.T_ERROR;
d.s="Unterminated char";
return;
}
if (dat.charAt(x) != '\'') {
d.type=DecodeReturn.T_ERROR;
d.s="Bad char";
return;
}
d.type=DecodeReturn.T_CHAR;
d.l=c;
d.pos=x + 1;
return;
}
}
default :
d.type=DecodeReturn.T_ERROR;
d.s="Unknown token";
return;
}
}
| Decodes the next item out of a DecodeReturn and modifies the DecodeReturn to hold the results. See DecodeReturn for more explanations about how to interpret the results. |
public Falls(){
super();
}
| Needed by CGLib |
protected Object createJvmMemoryMBean(String groupName,String groupOid,ObjectName groupObjname,MBeanServer server){
if (server != null) return new JvmMemoryImpl(this,server);
else return new JvmMemoryImpl(this);
}
| Factory method for "JvmMemory" group MBean. You can redefine this method if you need to replace the default generated MBean class with your own customized class. |
public String toString(){
java.text.MessageFormat form=new java.text.MessageFormat(sun.security.util.ResourcesMgr.getString("NTSidGroupPrincipal.name","sun.security.util.AuthResources"));
Object[] source={getName()};
return form.format(source);
}
| Return a string representation of this <code>NTSidGroupPrincipal</code>. <p> |
public static boolean isDraw(String[][] m){
for (int i=0; i < m.length; i++) {
for (int j=0; j < m[i].length; j++) {
if (m[i][j] == " ") return false;
}
}
return true;
}
| isDraw returns true if all the cells on the grid have been filled with tokens and neither player has achieved a win |
protected void run() throws Exception {
}
| Override this method to do work in the Jetstream application. |
public static boolean isEmpty(Map map){
return (map == null || map.isEmpty());
}
| Return <code>true</code> if the supplied Map is <code>null</code> or empty. Otherwise, return <code>false</code>. |
public static Object sum(Object[] items){
return sum((Iterable)Arrays.asList(items));
}
| Sums all the items from an array of items. |
public void testGetF24(){
AbstractThrottle instance=new AbstractThrottleImpl();
boolean expResult=false;
boolean result=instance.getF24();
assertEquals(expResult,result);
}
| Test of getF24 method, of class AbstractThrottle. |
@Deprecated public void readObject(ObjectInputStream s) throws IOException {
}
| Reads the object stream. |
public IllinoisLemmatizer(boolean isLazilyInitialized){
super(ViewNames.LEMMA,new String[]{ViewNames.POS},isLazilyInitialized,new LemmatizerConfigurator().getDefaultConfig());
}
| default parameters, but set whether lazily initialized or not |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.