code
stringlengths 10
174k
| nl
stringlengths 3
129k
|
---|---|
@Override public boolean mayIntersect(S2Cell cell){
if (numVertices() == 0) {
return false;
}
for (int i=0; i < numVertices(); ++i) {
if (cell.contains(vertex(i))) {
return true;
}
}
S2Point[] cellVertices=new S2Point[4];
for (int i=0; i < 4; ++i) {
cellVertices[i]=cell.getVertex(i);
}
for (int j=0; j < 4; ++j) {
S2EdgeUtil.EdgeCrosser crosser=new S2EdgeUtil.EdgeCrosser(cellVertices[j],cellVertices[(j + 1) & 3],vertex(0));
for (int i=1; i < numVertices(); ++i) {
if (crosser.robustCrossing(vertex(i)) >= 0) {
return true;
}
}
}
return false;
}
| If this method returns false, the region does not intersect the given cell. Otherwise, either region intersects the cell, or the intersection relationship could not be determined. |
public void add(int index,int element){
checkRangeIncludingEndpoint(index);
ensureCapacity(size + 1);
int numtomove=size - index;
System.arraycopy(array,index,array,index + 1,numtomove);
array[index]=element;
size++;
}
| Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices). |
public void load(PolicyMappings policyMappings){
ASN1Sequence policyMappingsSeq=(ASN1Sequence)policyMappings.toASN1Primitive();
ASN1Encodable[] asn1EncArray=policyMappingsSeq.toArray();
PolicyMapping[] policyMappingsArray=new PolicyMapping[asn1EncArray.length];
for (int i=0; i < asn1EncArray.length; i++) {
policyMappingsArray[i]=PolicyMapping.getInstance(asn1EncArray[i]);
}
Arrays.sort(policyMappingsArray,new IssuerDomainPolicyComparator());
data=new Object[policyMappingsArray.length][2];
int i=0;
for ( PolicyMapping policyMapping : policyMappingsArray) {
data[i][0]=policyMapping;
data[i][1]=policyMapping;
i++;
}
fireTableDataChanged();
}
| Load the PolicyMappingsTableModel with policy mappings. |
public static void addParserContext(String[] mimeTypes,XMLEventParserContext prototypeContext){
if (mimeTypes == null || mimeTypes.length == 0) {
String message=Logging.getMessage("nullValue.MimeTypeListIsNull");
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
if (prototypeContext == null) {
String message=Logging.getMessage("nullValue.ParserContextIsNull");
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
parsers.add(new ParserTableEntry(mimeTypes,prototypeContext));
}
| Appends a specified prototype parser context to the list of those already registered. |
LootmodeActionListener(String mode){
this.mode=mode;
}
| Create a LootmodeActionListener for changing to a specified mode. |
protected BreakIterator parseBreakIterator(String type,Locale locale){
if (type == null || "SENTENCE".equals(type)) {
return BreakIterator.getSentenceInstance(locale);
}
else if ("LINE".equals(type)) {
return BreakIterator.getLineInstance(locale);
}
else if ("WORD".equals(type)) {
return BreakIterator.getWordInstance(locale);
}
else if ("CHARACTER".equals(type)) {
return BreakIterator.getCharacterInstance(locale);
}
else if ("WHOLE".equals(type)) {
return new WholeBreakIterator();
}
else {
throw new IllegalArgumentException("Unknown " + HighlightParams.BS_TYPE + ": "+ type);
}
}
| parse a break iterator type for the specified locale |
public boolean hasPurchase(String sku){
return mPurchaseMap.containsKey(sku);
}
| Returns whether or not there exists a purchase of the given product. |
public static String mangleNativeMethod(String owner,String name,String desc){
StringBuilder sb=new StringBuilder();
sb.append("Java_");
sb.append(mangleNativeString(owner));
sb.append("_");
sb.append(mangleNativeString(name));
if (desc != null) {
sb.append("__");
sb.append(mangleNativeString(desc.substring(1,desc.lastIndexOf(')'))));
}
return sb.toString();
}
| Returns the long version of the JNI function name for a method. |
public boolean maybeDirty(){
return !_mainHashShared;
}
| Method called to check to quickly see if a child symbol table may have gotten additional entries. Used for checking to see if a child table should be merged into shared table. |
public void firePan(int direction,float amount){
if (direction < PanEvent.PAN_FIRST || direction > PanEvent.PAN_LAST) {
throw new IllegalArgumentException("Bad value, " + direction + " for direction in "+ "PanSupport.firePan()");
}
float az=PanEvent.dir2Az(direction);
firePan(az);
}
| Send a pan event to all registered listeners. |
public Class<? extends XtextEditor> bindXtextEditor(){
return N4MFEditor.class;
}
| Bind custom XtextEditor. |
private static void printPositionMenuHelp(){
System.out.println("<command> (<abbreviated command>) : <description>");
System.out.println("-------------------------------------------------");
System.out.println("list (l) : list positions");
System.out.println("show (s) : show position");
System.out.println("back (b) : go back to previous menu");
System.out.println("transactions (t) : go to the transactions menu");
System.out.println("help (h) : help");
System.out.println("quit (q) : quit");
System.out.println("");
}
| Prints the available commands at the position menu. |
public void skipIgnored(int options){
if ((options & SKIP_WHITESPACE) != 0) {
for (; ; ) {
int a=_current();
if (!UCharacterProperty.isRuleWhiteSpace(a)) break;
_advance(UTF16.getCharCount(a));
}
}
}
| Skips ahead past any ignored characters, as indicated by the given options. This is useful in conjunction with the lookahead() method. Currently, this only has an effect for SKIP_WHITESPACE. |
public CustomProperty(){
super(KEY);
}
| Constructs an instance using the default key. |
public static void main(String[] args){
TermStep fs=new TermStep();
TermStepInfo termStepInfo=fs.execute(args);
OozieUtil oozieUtil=new OozieUtil();
try {
oozieUtil.persistBeanData(termStepInfo,false);
}
catch ( Exception e) {
LOGGER.error(e);
throw new MetadataException(e);
}
}
| This method calls execute method and persist the output till runtime. |
public static boolean grOrEq(double a,double b){
return (b - a < SMALL);
}
| Tests if a is greater or equal to b. |
public InactiveState(DownloadInfoRunnable downloadInfoRunnable){
super(downloadInfoRunnable);
}
| Construct an inactive state. |
public HierarchicalClusterModel(ClusterModel clusterModel){
rootNode=new HierarchicalClusterNode("root");
for ( Cluster cluster : clusterModel.getClusters()) {
rootNode.addSubNode(new HierarchicalClusterLeafNode(cluster.getClusterId(),cluster.getExampleIds()));
}
}
| Creates a hierarchical cluster model by copying a flat one. |
@Override public synchronized boolean isValid(int timeout){
try {
debugCodeCall("isValid",timeout);
if (session == null || session.isClosed()) {
return false;
}
getTransactionIsolation();
return true;
}
catch ( Exception e) {
logAndConvert(e);
return false;
}
}
| Returns true if this connection is still valid. |
@Override public synchronized void clear(){
File[] files=mRootDirectory.listFiles();
if (files != null) {
for ( File file : files) {
file.delete();
}
}
mEntries.clear();
mTotalSize=0;
VolleyLog.d("Cache cleared.");
}
| Clears the cache. Deletes all cached files from disk. |
public StorageIndex(){
this.version=VERSION_NO;
}
| Creates a new specification whose values must be filled in. |
public static <T>int createTableIfNotExists(ConnectionSource connectionSource,Class<T> dataClass) throws SQLException {
return createTable(connectionSource,dataClass,true);
}
| Create a table if it does not already exist. This is not supported by all databases. |
public void updateSummaries(){
PrefServiceBridge prefServiceBridge=PrefServiceBridge.getInstance();
CheckBoxPreference navigationErrorPref=(CheckBoxPreference)findPreference(PREF_NAVIGATION_ERROR);
navigationErrorPref.setChecked(prefServiceBridge.isResolveNavigationErrorEnabled());
CheckBoxPreference searchSuggestionsPref=(CheckBoxPreference)findPreference(PREF_SEARCH_SUGGESTIONS);
searchSuggestionsPref.setChecked(prefServiceBridge.isSearchSuggestEnabled());
CheckBoxPreference extendedReportingPref=(CheckBoxPreference)findPreference(PREF_SAFE_BROWSING_EXTENDED_REPORTING);
if (extendedReportingPref != null) {
extendedReportingPref.setChecked(prefServiceBridge.isSafeBrowsingExtendedReportingEnabled());
}
CheckBoxPreference safeBrowsingPref=(CheckBoxPreference)findPreference(PREF_SAFE_BROWSING);
if (safeBrowsingPref != null) {
safeBrowsingPref.setChecked(prefServiceBridge.isSafeBrowsingEnabled());
}
Preference doNotTrackPref=findPreference(PREF_DO_NOT_TRACK);
if (prefServiceBridge.isDoNotTrackEnabled()) {
doNotTrackPref.setSummary(getActivity().getResources().getText(R.string.text_on));
}
else {
doNotTrackPref.setSummary(getActivity().getResources().getText(R.string.text_off));
}
Preference contextualPref=findPreference(PREF_CONTEXTUAL_SEARCH);
if (contextualPref != null) {
if (prefServiceBridge.isContextualSearchDisabled()) {
contextualPref.setSummary(getActivity().getResources().getText(R.string.text_off));
}
else {
contextualPref.setSummary(getActivity().getResources().getText(R.string.text_on));
}
}
PrivacyPreferencesManager privacyPrefManager=PrivacyPreferencesManager.getInstance(getActivity());
if (privacyPrefManager.isCellularExperimentEnabled()) {
Preference usageAndCrashPref=findPreference(PREF_USAGE_AND_CRASH_REPORTING);
if (privacyPrefManager.isUsageAndCrashReportingEnabled()) {
usageAndCrashPref.setSummary(getActivity().getResources().getText(R.string.text_on));
}
else {
usageAndCrashPref.setSummary(getActivity().getResources().getText(R.string.text_off));
}
}
}
| Updates the summaries for several preferences. |
public static Sv2Command extractMessageType(LocoNetMessage m){
if (isSupportedSv2Message(m)) {
int msgCmd=m.getElement(SV2_SV_CMD_ELEMENT_INDEX);
for ( Sv2Command s : Sv2Command.values()) {
if (s.getCmd() == msgCmd) {
log.debug("LocoNet message has SV2 message command " + msgCmd);
return s;
}
}
}
return null;
}
| Interprets a LocoNet message to determine its SV Programming Format 2 <SV_CMD>. If the message is not an SV Programming Format 2 message, returns null |
protected SQLException unsupported(String message) throws SQLException {
try {
throw DbException.getUnsupportedException(message);
}
catch ( Exception e) {
return logAndConvert(e);
}
}
| Get and throw a SQL exception meaning this feature is not supported. |
public final void close(){
try {
log.info("Closing ...");
assert (writer != null);
writer.flush();
writer.close();
log.info("... done!");
}
catch ( IOException e) {
e.printStackTrace();
}
}
| finalize and close csv file |
@RequestMapping(value={"","/"},method=RequestMethod.GET) @ResponseBody public RestWrapper list(@RequestParam(value="page",defaultValue="0") int startPage,@RequestParam(value="size",defaultValue="10") int pageSize,Principal principal){
RestWrapper restWrapper=null;
try {
Integer counter=processDeploymentQueueDAO.totalRecordCount();
List<com.wipro.ats.bdre.md.dao.jpa.ProcessDeploymentQueue> jpaPdqList=processDeploymentQueueDAO.list(startPage,pageSize);
List<ProcessDeploymentQueue> processDeploymentQueues=new ArrayList<ProcessDeploymentQueue>();
for ( com.wipro.ats.bdre.md.dao.jpa.ProcessDeploymentQueue pdq : jpaPdqList) {
ProcessDeploymentQueue processDeploymentQueue=new ProcessDeploymentQueue();
processDeploymentQueue.setDeploymentId(pdq.getDeploymentId());
processDeploymentQueue.setProcessTypeId(pdq.getProcessType().getProcessTypeId());
processDeploymentQueue.setDeployStatusId((int)pdq.getDeployStatus().getDeployStatusId());
processDeploymentQueue.setStartTs(pdq.getStartTs());
processDeploymentQueue.setEndTs(pdq.getEndTs());
processDeploymentQueue.setInsertTs(pdq.getInsertTs());
processDeploymentQueue.setBusDomainId(pdq.getBusDomain().getBusDomainId());
processDeploymentQueue.setDeployScriptLocation(pdq.getDeployScriptLocation());
processDeploymentQueue.setUserName(pdq.getUserName());
processDeploymentQueue.setProcessId(pdq.getProcess().getProcessId());
processDeploymentQueue.setCounter(counter);
processDeploymentQueues.add(processDeploymentQueue);
}
for ( ProcessDeploymentQueue pdq : processDeploymentQueues) {
if (pdq.getEndTs() != null) {
pdq.setTableEndTs(DateConverter.dateToString(pdq.getEndTs()));
}
if (pdq.getStartTs() != null) {
pdq.setTableStartTs(DateConverter.dateToString(pdq.getStartTs()));
}
pdq.setTableInsertTs(DateConverter.dateToString(pdq.getInsertTs()));
}
restWrapper=new RestWrapper(processDeploymentQueues,RestWrapper.OK);
LOGGER.info("All records listed from ProcessDeploymentQueue by User:" + principal.getName());
}
catch ( MetadataException e) {
LOGGER.error(e);
restWrapper=new RestWrapper(e.getMessage(),RestWrapper.ERROR);
}
return restWrapper;
}
| This method calls proc GetProcessDeploymentQueues and fetches a list records from ProcessDeploymentQueues table. |
@Override public void debug(String format,Object argA,Object argB){
if (logger.isLoggable(Level.FINE)) {
FormattingTuple ft=MessageFormatter.format(format,argA,argB);
log(SELF,Level.FINE,ft.getMessage(),ft.getThrowable());
}
}
| Log a message at level FINE according to the specified format and arguments. <p/> <p> This form avoids superfluous object creation when the logger is disabled for the FINE level. </p> |
public Matrix4x3d add(Matrix4x3fc other){
return add(other,this);
}
| Component-wise add <code>this</code> and <code>other</code>. |
private void log(String str){
Log.i(this.getClass().getSimpleName(),"-----------------" + str);
}
| send message to logcat |
protected void prettyPrint(Reader in,Writer out) throws TranscoderException {
try {
PrettyPrinter pp=new PrettyPrinter();
NewlineValue nlv=(NewlineValue)hints.get(KEY_NEWLINE);
if (nlv != null) {
pp.setNewline(nlv.getValue());
}
Boolean b=(Boolean)hints.get(KEY_FORMAT);
if (b != null) {
pp.setFormat(b.booleanValue());
}
Integer i=(Integer)hints.get(KEY_TABULATION_WIDTH);
if (i != null) {
pp.setTabulationWidth(i.intValue());
}
i=(Integer)hints.get(KEY_DOCUMENT_WIDTH);
if (i != null) {
pp.setDocumentWidth(i.intValue());
}
DoctypeValue dtv=(DoctypeValue)hints.get(KEY_DOCTYPE);
if (dtv != null) {
pp.setDoctypeOption(dtv.getValue());
}
String s=(String)hints.get(KEY_PUBLIC_ID);
if (s != null) {
pp.setPublicId(s);
}
s=(String)hints.get(KEY_SYSTEM_ID);
if (s != null) {
pp.setSystemId(s);
}
s=(String)hints.get(KEY_XML_DECLARATION);
if (s != null) {
pp.setXMLDeclaration(s);
}
pp.print(in,out);
out.flush();
}
catch ( IOException e) {
getErrorHandler().fatalError(new TranscoderException(e.getMessage()));
}
}
| Pretty print the given reader. |
public List<JCVariableDecl> Params(List<Type> argtypes,Symbol owner){
ListBuffer<JCVariableDecl> params=new ListBuffer<JCVariableDecl>();
MethodSymbol mth=(owner.kind == MTH) ? ((MethodSymbol)owner) : null;
if (mth != null && mth.params != null && argtypes.length() == mth.params.length()) {
for ( VarSymbol param : ((MethodSymbol)owner).params) params.append(VarDef(param,null));
}
else {
int i=0;
for (List<Type> l=argtypes; l.nonEmpty(); l=l.tail) params.append(Param(paramName(i++),l.head,owner));
}
return params.toList();
}
| Create a a list of value parameter trees x0, ..., xn from a list of their types and an their owner. |
private boolean anyCharactersAreTheSame(char separator,char quotechar,char escape){
return isSameCharacter(separator,quotechar) || isSameCharacter(separator,escape) || isSameCharacter(quotechar,escape);
}
| checks to see if any two of the three characters are the same. This is because in openCSV the separator, quote, and escape characters must the different. |
public <E extends Layout,AE extends Array1D<E>>GenArray1D(Class<E> elementInterfaceClass,Class<AE> userDefinedArrayClass){
elementInterfaceClassName=ImplHelper.getInterfaceClassName(elementInterfaceClass);
elementImplClassName=ImplHelper.getImplClassName(elementInterfaceClass);
if (null == userDefinedArrayClass) {
arrayImplClassName=ImplHelper.getArray1DClassImplName(elementInterfaceClass);
arrayInterfaceClassName="com/ibm/layout/Array1D";
arrayInterfaceClassSig="L" + arrayInterfaceClassName + "<L"+ elementInterfaceClassName+ ";>;";
}
else {
arrayImplClassName=ImplHelper.getImplClassName(userDefinedArrayClass);
arrayInterfaceClassName=userDefinedArrayClass.getName().replace('.','/');
arrayInterfaceClassSig=null;
}
dbgPrintNames();
}
| Instantiate GenArray1D for user defined array class |
public static void add(List<String> options,char option,Object value){
add(options,"" + option,value);
}
| Adds the array to the options. |
public static void main(String[] args){
MyPoint point1=new MyPoint();
MyPoint point2=new MyPoint(10,30.5);
System.out.println("The distance between (" + point1.getX() + ", "+ point1.getY()+ ") and ("+ point2.getX()+ ", "+ point2.getY()+ ") is: "+ point1.distance(point2));
}
| Main method |
public void load(Element element,Object o){
log.warn("unexpected call of 2nd load form");
}
| Update static data from XML file |
public static CCSprite sprite(String filepath){
return new CCSprite(filepath);
}
| Creates an sprite with an image filepath. The rect used will be the size of the image. The offset will be (0,0). |
protected void installListeners(Component c){
installListeners(c,EventID.CONTAINER);
installListeners(c,EventID.FOCUS);
if (AWTEventMonitor.componentListener_private != null) {
installListeners(c,EventID.COMPONENT);
}
if (AWTEventMonitor.keyListener_private != null) {
installListeners(c,EventID.KEY);
}
if (AWTEventMonitor.mouseListener_private != null) {
installListeners(c,EventID.MOUSE);
}
if (AWTEventMonitor.mouseMotionListener_private != null) {
installListeners(c,EventID.MOTION);
}
if (AWTEventMonitor.windowListener_private != null) {
installListeners(c,EventID.WINDOW);
}
if (AWTEventMonitor.actionListener_private != null) {
installListeners(c,EventID.ACTION);
}
if (AWTEventMonitor.adjustmentListener_private != null) {
installListeners(c,EventID.ADJUSTMENT);
}
if (AWTEventMonitor.itemListener_private != null) {
installListeners(c,EventID.ITEM);
}
if (AWTEventMonitor.textListener_private != null) {
installListeners(c,EventID.TEXT);
}
}
| Installs all currently registered listeners to just the component. |
protected int weightChildNodes(Element rootEl){
int weight=0;
Element caption=null;
List<Element> pEls=new ArrayList<Element>(5);
for ( Element child : rootEl.children()) {
String ownText=child.ownText();
int ownTextLength=ownText.length();
if (ownTextLength < 20) continue;
if (ownTextLength > 200) weight+=Math.max(50,ownTextLength / 10);
if (child.tagName().equals("h1") || child.tagName().equals("h2")) {
weight+=30;
}
else if (child.tagName().equals("div") || child.tagName().equals("p")) {
weight+=calcWeightForChild(child,ownText);
if (child.tagName().equals("p") && ownTextLength > 50) pEls.add(child);
if (child.className().toLowerCase().equals("caption")) caption=child;
}
}
if (caption != null) weight+=30;
if (pEls.size() >= 2) {
for ( Element subEl : rootEl.children()) {
if ("h1;h2;h3;h4;h5;h6".contains(subEl.tagName())) {
weight+=20;
}
else if ("table;li;td;th".contains(subEl.tagName())) {
addScore(subEl,-30);
}
if ("p".contains(subEl.tagName())) addScore(subEl,30);
}
}
return weight;
}
| Weights a child nodes of given Element. During tests some difficulties were met. For instanance, not every single document has nested paragraph tags inside of the major article tag. Sometimes people are adding one more nesting level. So, we're adding 4 points for every 100 symbols contained in tag nested inside of the current weighted element, but only 3 points for every element that's nested 2 levels deep. This way we give more chances to extract the element that has less nested levels, increasing probability of the correct extraction. |
@Override public void finishStage(ResponseBuilder rb){
SolrParams params=rb.req.getParams();
LOG.info("SuggestComponent finishStage with : " + params);
if (!params.getBool(COMPONENT_NAME,false) || rb.stage != ResponseBuilder.STAGE_GET_FIELDS) return;
int count=params.getInt(SUGGEST_COUNT,1);
List<SuggesterResult> suggesterResults=new ArrayList<>();
for ( ShardRequest sreq : rb.finished) {
for ( ShardResponse srsp : sreq.responses) {
NamedList<Object> resp;
if ((resp=srsp.getSolrResponse().getResponse()) != null) {
@SuppressWarnings("unchecked") Map<String,SimpleOrderedMap<NamedList<Object>>> namedList=(Map<String,SimpleOrderedMap<NamedList<Object>>>)resp.get(SuggesterResultLabels.SUGGEST);
LOG.info(srsp.getShard() + " : " + namedList);
suggesterResults.add(toSuggesterResult(namedList));
}
}
}
SuggesterResult suggesterResult=merge(suggesterResults,count);
Map<String,SimpleOrderedMap<NamedList<Object>>> namedListResults=new HashMap<>();
toNamedList(suggesterResult,namedListResults);
rb.rsp.add(SuggesterResultLabels.SUGGEST,namedListResults);
}
| Used in Distributed Search, merges the suggestion results from every shard |
protected double[] computeMeans(Instances insts){
double[] means=new double[insts.numAttributes()];
double[] counts=new double[insts.numAttributes()];
for (int j=0; j < insts.numInstances(); j++) {
Instance inst=insts.instance(j);
for (int i=0; i < insts.numAttributes(); i++) {
means[i]+=inst.weight() * inst.value(i);
counts[i]+=inst.weight();
}
}
for (int i=0; i < insts.numAttributes(); i++) {
if (counts[i] > 0) {
means[i]/=counts[i];
}
else {
means[i]=0.0;
}
}
return means;
}
| Computes the attribute means. |
public InformationModelFactoryImpl(){
super();
}
| Creates an instance of the factory. <!-- begin-user-doc --> <!-- end-user-doc --> |
public boolean equals(final Object that){
if (that == null) {
return false;
}
if (this.getClass().equals(that.getClass())) {
final TransactionalEntity thatEntity=(TransactionalEntity)that;
if (this.getId() == null || thatEntity.getId() == null) {
return false;
}
if (this.getId().equals(thatEntity.getId())) {
return true;
}
}
return false;
}
| Determines the equality of two TransactionalEntity objects. If the supplied object is null, returns false. If both objects are of the same class, and their <code>id</code> values are populated and equal, return <code>true</code>. Otherwise, return <code>false</code>. |
public boolean equals(Object that){
if (that.getClass() != this.getClass()) return false;
SIPDate other=(SIPDate)that;
return this.wkday == other.wkday && this.day == other.day && this.month == other.month && this.year == other.year && this.hour == other.hour && this.minute == other.minute && this.second == other.second;
}
| equality check. |
public JythonScript(Document doc,File file){
super(doc,file);
}
| Initializes the script. Automatically loads the specified file, if not null. |
public static String genUniquePathname(String format){
String ret=null;
if (null != format && !format.isEmpty()) {
ret=String.format(format,(new SimpleDateFormat("ddMMyy-hhmmss.SSS").format(new Date())));
}
return ret;
}
| Generates a unique name that contains current timestamp. |
public boolean isBluetoothAvailable(){
BluetoothAdapter mBluetoothAdapter=BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null) {
Toast.makeText(mContext,"Bluetooth not supported",Toast.LENGTH_SHORT).show();
return false;
}
else return true;
}
| Method to get Bluetooth status |
@Override public Adapter createAdapter(Notifier target){
return modelSwitch.doSwitch((EObject)target);
}
| Creates an adapter for the <code>target</code>. <!-- begin-user-doc --> <!-- end-user-doc --> |
public org.smpte_ra.schemas.st2067_2_2016.SequenceType.ResourceList buildResourceList(List<org.smpte_ra.schemas.st2067_2_2016.BaseResourceType> trackResourceList){
org.smpte_ra.schemas.st2067_2_2016.SequenceType.ResourceList resourceList=new org.smpte_ra.schemas.st2067_2_2016.SequenceType.ResourceList();
resourceList.getResource().addAll(trackResourceList);
return resourceList;
}
| A method to construct a ResourceList for a Sequence conforming to the 2016 schema |
public void yypushback(int number){
if (number > yylength()) zzScanError(ZZ_PUSHBACK_2BIG);
zzMarkedPos-=number;
}
| Pushes the specified amount of characters back into the input stream. They will be read again by then next call of the scanning method |
public void addAnnotation(Method ann) throws ObjectStoreConfigException {
if (annotations.containsKey(ann)) throw new ObjectStoreConfigException(ann.toString() + " can only be added once");
annotations.put(ann,null);
}
| Associates this annotation with its annotated type. |
@DSGenerator(tool_name="Doppelganger",tool_version="2.0",generated_on="2013-12-30 12:55:46.781 -0500",hash_original_method="EEEC9A9B7336175FA90CC43255548EC9",hash_generated_method="A6283962EC4BC9718A7AF6E989D32E51") public SIPHeader parse() throws ParseException {
if (debug) dbg_enter("AllowParser.parse");
AllowList list=new AllowList();
try {
headerName(TokenTypes.ALLOW);
Allow allow=new Allow();
allow.setHeaderName(SIPHeaderNames.ALLOW);
this.lexer.SPorHT();
this.lexer.match(TokenTypes.ID);
Token token=lexer.getNextToken();
allow.setMethod(token.getTokenValue());
list.add(allow);
this.lexer.SPorHT();
while (lexer.lookAhead(0) == ',') {
this.lexer.match(',');
this.lexer.SPorHT();
allow=new Allow();
this.lexer.match(TokenTypes.ID);
token=lexer.getNextToken();
allow.setMethod(token.getTokenValue());
list.add(allow);
this.lexer.SPorHT();
}
this.lexer.SPorHT();
this.lexer.match('\n');
return list;
}
finally {
if (debug) dbg_leave("AllowParser.parse");
}
}
| parse the Allow String header |
int parseAmPmMarker(String source,int ofs) throws ParseException {
String markers[]=getDateFormatSymbols().getAmPmStrings();
int mlen=markers.length;
for (int i=0; i < mlen; i++) {
if (markers[i].equalsIgnoreCase(source)) {
return i;
}
}
char ch=source.charAt(ofs);
if (ch == markers[0].charAt(0)) {
return Calendar.AM;
}
if (ch == markers[1].charAt(0)) {
return Calendar.PM;
}
return throwInvalid("am/pm marker",ofs);
}
| Parse an AM/PM marker. The source marker can be the marker name as defined in DateFormatSymbols, or the first character of the marker name. |
private static int appendClassTypeSignature(char[] string,int start,boolean fullyQualifyTypeNames,StringBuffer buffer){
if (start >= string.length - 2) {
throw new IllegalArgumentException();
}
char c=string[start];
if (c != C_RESOLVED && c != C_UNRESOLVED) {
throw new IllegalArgumentException();
}
boolean resolved=(c == C_RESOLVED);
boolean removePackageQualifiers=!fullyQualifyTypeNames;
if (!resolved) {
removePackageQualifiers=false;
}
int p=start + 1;
int checkpoint=buffer.length();
int innerTypeStart=-1;
boolean inAnonymousType=false;
while (true) {
if (p >= string.length) {
throw new IllegalArgumentException();
}
c=string[p];
switch (c) {
case C_SEMICOLON:
return p;
case C_GENERIC_START:
int e=appendTypeArgumentSignatures(string,p,fullyQualifyTypeNames,buffer);
removePackageQualifiers=false;
p=e;
break;
case C_DOT:
if (removePackageQualifiers) {
buffer.setLength(checkpoint);
}
else {
buffer.append('.');
}
break;
case '/':
if (removePackageQualifiers) {
buffer.setLength(checkpoint);
}
else {
buffer.append('/');
}
break;
case C_DOLLAR:
innerTypeStart=buffer.length();
inAnonymousType=false;
if (resolved) {
removePackageQualifiers=false;
buffer.append('.');
}
break;
default :
if (innerTypeStart != -1 && !inAnonymousType && Character.isDigit(c)) {
inAnonymousType=true;
buffer.setLength(innerTypeStart);
buffer.insert(checkpoint,"new ");
buffer.append("(){}");
}
if (!inAnonymousType) buffer.append(c);
innerTypeStart=-1;
}
p++;
}
}
| Scans the given string for a class type signature starting at the given index and appends it to the given buffer, and returns the index of the last character. |
synchronized void sendRoleRequest(OFControllerRole role,long xid) throws IOException {
Boolean supportsNxRole=(Boolean)sw.getAttribute(IOFSwitch.SWITCH_SUPPORTS_NX_ROLE);
if ((supportsNxRole != null) && !supportsNxRole) {
setSwitchRole(role,RoleRecvStatus.UNSUPPORTED);
}
else {
pendingXid=sendNiciraRoleRequest(role,xid);
pendingRole=role;
this.roleSubmitTimeNs=System.nanoTime();
requestPending=true;
}
}
| Send a role request with the given role to the switch. Send a role request with the given role to the switch and update the pending request and timestamp. |
public MalformedURIException(){
super();
}
| Constructs a <code>MalformedURIException</code> with no specified detail message. |
private void prepareQuery(final Map workflowheaderparams,final StringBuilder qryStr){
qryStr.append("select id from WorkFlowMatrix where objectType = :objecttype and department IN (:departments) ");
if (!"-1".equals(workflowheaderparams.get(ADDITIONALRULE))) {
qryStr.append("and additionalRule = :additionalrule");
}
qryStr.append(" group by id,objectType,department,fromDate,toDate,fromQty,toQty ");
if (!"-1".equals(workflowheaderparams.get(ADDITIONALRULE))) {
qryStr.append(",additionalRule ");
}
}
| This method is used to prepare query that is used in checkIfMatrixExists method |
public static void main(String[] args){
try {
String path=parseArgs(args,null);
String low=parseArgs(args,ARG_KEY_CHAR_RANGE_LOW);
String high=parseArgs(args,ARG_KEY_CHAR_RANGE_HIGH);
String id=parseArgs(args,ARG_KEY_ID);
String ascii=parseArgs(args,ARG_KEY_ASCII);
String testCard=parseArgs(args,ARG_KEY_TESTCARD);
String outPath=parseArgs(args,ARG_KEY_OUTPUT_PATH);
String autoRange=parseArgs(args,ARG_KEY_AUTO_RANGE);
PrintStream ps=null;
FileOutputStream fos=null;
if (outPath != null) {
fos=new FileOutputStream(outPath);
ps=new PrintStream(fos);
}
else {
ps=System.out;
}
if (path != null) {
Font font=Font.create(path);
writeSvgBegin(ps);
writeSvgDefsBegin(ps);
writeFontAsSVGFragment(ps,font,id,(low != null ? Integer.parseInt(low) : -1),(high != null ? Integer.parseInt(high) : -1),(autoRange != null),(ascii != null));
writeSvgDefsEnd(ps);
if (testCard != null) {
String fontFamily=font.getNameTable().getRecord(Table.nameFontFamilyName);
writeSvgTestCard(ps,fontFamily);
}
writeSvgEnd(ps);
if (fos != null) {
fos.close();
}
}
else {
usage();
}
}
catch ( Exception e) {
e.printStackTrace();
System.err.println(e.getMessage());
usage();
}
}
| Starts the application. |
public void fillPolygon(int xPoints[],int yPoints[],int nPoints){
if (nPoints > 0) {
int minX=xPoints[0];
int minY=yPoints[0];
int maxX=xPoints[0];
int maxY=yPoints[0];
for (int i=1; i < nPoints; i++) {
if (xPoints[i] < minX) {
minX=xPoints[i];
}
else if (xPoints[i] > maxX) {
maxX=xPoints[i];
}
if (yPoints[i] < minY) {
minY=yPoints[i];
}
else if (yPoints[i] > maxY) {
maxY=yPoints[i];
}
}
addDrawingRect(minX,minY,maxX - minX,maxY - minY);
}
mPrintMetrics.fill(this);
}
| Fills a closed polygon defined by arrays of <i>x</i> and <i>y</i> coordinates. <p> This method draws the polygon defined by <code>nPoint</code> line segments, where the first <code>nPoint - 1</code> line segments are line segments from <code>(xPoints[i - 1], yPoints[i - 1])</code> to <code>(xPoints[i], yPoints[i])</code>, for 1 ≤ <i>i</i> ≤ <code>nPoints</code>. The figure is automatically closed by drawing a line connecting the final point to the first point, if those points are different. <p> The area inside the polygon is defined using an even-odd fill rule, also known as the alternating rule. |
public VerifiedDownload(Logger log,ArtifactContext context,FileContentStore fileContentStore,Node node){
this.log=log;
this.context=context;
parent=NodeUtils.firstParent(node);
if (parent == null) {
throw new IllegalArgumentException("Parent should not be null: " + node);
}
this.node=node;
this.fileContentStore=fileContentStore;
File f;
File parentDir=fileContentStore.getFile(parent);
parentDir.mkdirs();
try {
f=File.createTempFile(node.getLabel() + ".",".tmp",parentDir);
}
catch ( IOException e) {
e.printStackTrace();
log.debug("IOException while creating temp file: " + e);
f=new File(parentDir,node.getLabel() + AbstractNodeRepositoryManager.VALIDATING);
FileUtil.delete(f);
}
f.deleteOnExit();
tempNode=parent.getChild(f.getName());
tempFile=fileContentStore.getFile(tempNode);
}
| Prepare for the download |
public HistogramComponent(final String name){
super(name);
model=new HistogramModel(HistogramModel.INITIAL_DATA_SOURCES);
init();
addListener();
}
| Create new Histogram Component. |
public static boolean isNumber(final String textString){
final byte[] data=StringUtils.toBytes(textString);
final int strLength=data.length;
boolean isNumber=true;
for (int j=0; j < strLength; j++) {
if ((data[j] >= zeroInt && data[j] <= nineInt) || data[j] == fullStopInt || (j == 0 && data[j] == minusInt)) {
}
else {
isNumber=false;
j=strLength;
}
}
return isNumber;
}
| check to see if the string contains anything other than '-' '0-9' '.' if so then its not a number. |
protected BasicPooledConnAdapter(ThreadSafeClientConnManager tsccm,AbstractPoolEntry entry){
super(tsccm,entry);
markReusable();
}
| Creates a new adapter. |
private void copyAttributes(CSSElement element,Vector selectors,HTMLElement addTo){
if (selectors == null) {
return;
}
for (Enumeration e=selectors.elements(); e.hasMoreElements(); ) {
CSSElement selector=(CSSElement)e.nextElement();
addTo.addChild(selector);
while (selector.getNumChildren() > 0) {
selector=selector.getCSSChildAt(0);
}
element.copyAttributesTo(selector);
}
}
| Copies all attributes from |
static protected int countSharedNeighbors(DBIDs neighbors1,DBIDs neighbors2){
int intersection=0;
DBIDIter iter1=neighbors1.iter();
DBIDIter iter2=neighbors2.iter();
while (iter1.valid() && iter2.valid()) {
final int comp=DBIDUtil.compare(iter1,iter2);
if (comp == 0) {
intersection++;
iter1.advance();
iter2.advance();
}
else if (comp < 0) {
iter1.advance();
}
else {
iter2.advance();
}
}
return intersection;
}
| Compute the intersection size. |
public boolean hasRecords(short platformID,short platformSpecificID){
for (Iterator i=records.keySet().iterator(); i.hasNext(); ) {
NameRecord rec=(NameRecord)i.next();
if (rec.platformID == platformID && rec.platformSpecificID == platformSpecificID) {
return true;
}
}
return false;
}
| Determine if we have any records with a given platform ID and platform-specific ID |
public void stop(){
threadChecker.checkIsOnValidThread();
Log.d(TAG,"stop" + AppRTCUtils.getThreadInfo());
if (proximitySensor == null) {
return;
}
sensorManager.unregisterListener(this,proximitySensor);
}
| Deactivate the proximity sensor. |
ImgComp(final BufferedImage img,final Rectangle off,final boolean right){
this.img=img;
at=AffineTransform.getTranslateInstance(-off.x,0);
d=new Dimension(off.width,off.height);
isRight=right;
}
| Create a clone with a specified backing image |
public SVGOMAnimatedPathData(AbstractElement elt,String ns,String ln,String defaultValue){
super(elt,ns,ln);
this.defaultValue=defaultValue;
}
| Creates a new SVGOMAnimatedPathData. |
public static boolean wildcardMatch(String filename,String wildcardMatcher,IOCase caseSensitivity){
if (filename == null && wildcardMatcher == null) {
return true;
}
if (filename == null || wildcardMatcher == null) {
return false;
}
if (caseSensitivity == null) {
caseSensitivity=IOCase.SENSITIVE;
}
String[] wcs=splitOnTokens(wildcardMatcher);
boolean anyChars=false;
int textIdx=0;
int wcsIdx=0;
Stack<int[]> backtrack=new Stack<int[]>();
do {
if (backtrack.size() > 0) {
int[] array=backtrack.pop();
wcsIdx=array[0];
textIdx=array[1];
anyChars=true;
}
while (wcsIdx < wcs.length) {
if (wcs[wcsIdx].equals("?")) {
textIdx++;
if (textIdx > filename.length()) {
break;
}
anyChars=false;
}
else if (wcs[wcsIdx].equals("*")) {
anyChars=true;
if (wcsIdx == wcs.length - 1) {
textIdx=filename.length();
}
}
else {
if (anyChars) {
textIdx=caseSensitivity.checkIndexOf(filename,textIdx,wcs[wcsIdx]);
if (textIdx == -1) {
break;
}
int repeat=caseSensitivity.checkIndexOf(filename,textIdx + 1,wcs[wcsIdx]);
if (repeat >= 0) {
backtrack.push(new int[]{wcsIdx,repeat});
}
}
else {
if (!caseSensitivity.checkRegionMatches(filename,textIdx,wcs[wcsIdx])) {
break;
}
}
textIdx+=wcs[wcsIdx].length();
anyChars=false;
}
wcsIdx++;
}
if (wcsIdx == wcs.length && textIdx == filename.length()) {
return true;
}
}
while (backtrack.size() > 0);
return false;
}
| Checks a filename to see if it matches the specified wildcard matcher allowing control over case-sensitivity. <p> The wildcard matcher uses the characters '?' and '*' to represent a single or multiple (zero or more) wildcard characters. N.B. the sequence "*?" does not work properly at present in match strings. |
public Scroll(final String name,final String clazz,final String subclass,final Map<String,String> attributes){
super(name,clazz,subclass,attributes);
}
| Creates a new scroll. |
public void valueChanged(ListSelectionEvent e){
ThreadsTableSelectionModel ttsm=(ThreadsTableSelectionModel)e.getSource();
TableSorter ts=(TableSorter)ttsm.getTable().getModel();
int[] rows=ttsm.getTable().getSelectedRows();
StringBuffer sb=new StringBuffer();
for (int i=0; i < rows.length; i++) {
appendThreadInfo(sb,((ThreadsTableModel)ts.getTableModel()).getInfoObjectAtRow(ts.modelIndex(rows[i])));
}
displayContent(sb.toString());
setThreadDisplay(true);
}
| process table selection events (thread display) |
public boolean containsExtensionElementURI(String uri){
if (null == m_ExtensionElementURIs) return false;
return m_ExtensionElementURIs.contains(uri);
}
| Find out if the given "extension-element-prefix" property is defined. |
@Override public String toString(){
return new String(toByteArray());
}
| Gets the curent contents of this byte stream as a string. |
public static boolean addAsFieldMethodCall(BytecodeInstruction f){
if (!f.isMethodCallOfField()) return false;
if (!f.canBeInstrumented()) return false;
registerAsDefUse(f);
registerAsFieldMethodCall(f);
return true;
}
| Gets called by DefUseInstrumentation whenever it detects a field method call as defined by ASMWrapper.isMethodCallField() It is not clear whether a field method call represents a Definition or Use when it is first detected. Later on the DefUseCoverageFactory (TODO or some other part of evosuite) will decide this using the complete CCFGs and their purity analysis, which are not available when DefUseInstrumentation has its turn. The instrumentation will call a special method of the ExecutionTracer which will redirect the instrumentation call to either passedDefinition() or passedUse() depending on how the given instruction will be categorized later on. Registers the given instruction as a field method call and assigns a fresh defUseId to the given instruction. Return false if the given instruction does not represent an instruction which is a use as defined in ASMWrapper.isUse(). Should isKnown() return true for the instruction before calling this method, it also returns false. After the call isKnown() and isKnownAsUse() are expected to return true for the instruction at hand however. |
@Override public synchronized boolean removeAll(Collection<?> collection){
return super.removeAll(collection);
}
| Removes all occurrences in this vector of each object in the specified Collection. |
private void changeOrientation(){
if (mainPanel.getWidth() > mainPanel.getHeight()) {
speedSlider.setOrientation(JSlider.HORIZONTAL);
if (speedSliderContinuous != null) {
speedSliderContinuous.setOrientation(JSlider.HORIZONTAL);
}
mainPanel.remove(buttonPanel);
mainPanel.add(buttonPanel,BorderLayout.EAST);
}
else {
speedSlider.setOrientation(JSlider.VERTICAL);
if (speedSliderContinuous != null) {
speedSliderContinuous.setOrientation(JSlider.VERTICAL);
}
mainPanel.remove(buttonPanel);
mainPanel.add(buttonPanel,BorderLayout.SOUTH);
}
}
| The user has resized the Frame. Possibly change from Horizontal to Vertical layout. |
@Override public boolean isActive(){
return amIActive;
}
| Used by the Whitebox GUI to tell if this plugin is still running. |
public MBeanException(java.lang.Exception e){
super();
exception=e;
}
| Creates an <CODE>MBeanException</CODE> that wraps the actual <CODE>java.lang.Exception</CODE>. |
public static <O,A extends Comparable<A>>CompositePersistence<O,A> of(Persistence<O,A> primaryPersistence,Persistence<O,A> secondaryPersistence){
return new CompositePersistence<O,A>(primaryPersistence,secondaryPersistence,Collections.<Persistence<O,A>>emptyList());
}
| Creates a CompositePersistence wrapping two backing persistences. <b>The collection itself will be persisted to the primary persistence.</b> |
private java.lang.String registerPrefix(javax.xml.stream.XMLStreamWriter xmlWriter,java.lang.String namespace) throws javax.xml.stream.XMLStreamException {
java.lang.String prefix=xmlWriter.getPrefix(namespace);
if (prefix == null) {
prefix=generatePrefix(namespace);
while (xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null) {
prefix=org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix();
}
xmlWriter.writeNamespace(prefix,namespace);
xmlWriter.setPrefix(prefix,namespace);
}
return prefix;
}
| Register a namespace prefix |
public TypeResolver(){
this("java.lang.Object");
}
| Default ctor for instantiation by the extension point. |
public void init(ModeledAuthenticatedUser currentUser,ConnectionModel connectionModel){
this.currentUser=currentUser;
this.connectionModel=connectionModel;
}
| Initializes this configuration, associating it with the current authenticated user and populating it with data from the given model object. |
public static ByteRange fixed(byte num){
return new ByteRange(num,num);
}
| Create range with only gived value in range. |
public static void logStart(@Nullable IgniteLogger log,Class<?> clazz,long start){
log0(log,start,"[" + clazz.getSimpleName() + "]: STARTED");
}
| Log start. |
@Override public LocalLearner create(){
return new NaiveBayes();
}
| Create an instance of this LocalLearner implementation. |
public void visitAttribute(Attribute attr){
if (fv != null) {
fv.visitAttribute(attr);
}
}
| Visits a non standard attribute of the field. |
public static RxANRequest.MultiPartBuilder upload(String url){
return new RxANRequest.MultiPartBuilder(url);
}
| Method to make upload request |
private void onSecondaryPointerUp(MotionEvent ev){
final int pointerIndex=MotionEventCompat.getActionIndex(ev);
final int pointerId=MotionEventCompat.getPointerId(ev,pointerIndex);
if (pointerId == activePointerId) {
final int newPointerIndex=pointerIndex == 0 ? 1 : 0;
lastMotionX=MotionEventCompat.getX(ev,newPointerIndex);
activePointerId=MotionEventCompat.getPointerId(ev,newPointerIndex);
if (velocityTracker != null) {
velocityTracker.clear();
}
}
}
| Check whether active pointer is up and re assign accordingly. |
public boolean isProcessing(){
Object oo=get_Value(COLUMNNAME_Processing);
if (oo != null) {
if (oo instanceof Boolean) return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
}
| Get Process Now. |
public boolean hasValue(){
return getValue() != null;
}
| Returns whether it has the value. |
@Override protected EClass eStaticClass(){
return N4mfPackage.Literals.TESTED_PROJECTS;
}
| <!-- begin-user-doc --> <!-- end-user-doc --> |
public static InetSocketAddress parseAddress(String address){
String[] addressSections=address.split(":");
int port=25565;
if (addressSections.length < 1) throw new IllegalArgumentException("The address \"" + address + "\" is invalid.");
if (addressSections.length >= 2) {
try {
port=Integer.parseInt(addressSections[1].trim());
}
catch ( NumberFormatException ex) {
port=25565;
}
}
return new InetSocketAddress(addressSections[0].trim(),port);
}
| Parse a string version of an address. |
private static int nextKeyIndex(int i,int len){
return (i + 2 < len ? i + 2 : 0);
}
| Circularly traverses table of size len. |
@Override public boolean hasOverlappingRendering(){
return false;
}
| Allows for smoother animations. |
public boolean isServerProcess(){
Object oo=get_Value(COLUMNNAME_IsServerProcess);
if (oo != null) {
if (oo instanceof Boolean) return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
}
| Get Server Process. |
static void createRefreshTimer(){
try {
refreshTimer=new javax.management.timer.Timer();
mbeanServer.registerMBean(refreshTimer,refreshTimerObjectName);
refreshTimer.start();
}
catch ( JMException e) {
logStackTrace(Level.WARN,e,LocalizedStrings.MBeanUtil_FAILED_TO_CREATE_REFRESH_TIMER.toLocalizedString());
}
catch ( JMRuntimeException e) {
logStackTrace(Level.WARN,e,LocalizedStrings.MBeanUtil_FAILED_TO_CREATE_REFRESH_TIMER.toLocalizedString());
}
catch ( Exception e) {
logStackTrace(Level.WARN,e,LocalizedStrings.MBeanUtil_FAILED_TO_CREATE_REFRESH_TIMER.toLocalizedString());
}
}
| Initializes the timer for sending refresh notifications. |
public Builder consumerKey(String consumerKey){
this.consumerKey=checkNotNull(consumerKey,"consumerKey == null");
return this;
}
| Sets the consumer key. |
public static NbtOutputStream writeCompressed(NbtTag tag,OutputStream outputStream) throws IOException {
NbtOutputStream out=new NbtOutputStream(new GZIPOutputStream(outputStream));
out.write(tag);
return out;
}
| Create new compressed nbt output stream for given stream, and write nbt tag to it. |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.