id
int64 22
34.9k
| comment_id
int64 0
328
| comment
stringlengths 2
2.55k
| code
stringlengths 31
107k
| classification
stringclasses 6
values | isFinished
bool 1
class | code_context_2
stringlengths 21
27.3k
| code_context_10
stringlengths 29
27.3k
| code_context_20
stringlengths 29
27.3k
|
---|---|---|---|---|---|---|---|---|
17,634 | 3 | // <include> is used with an in built android layout id | private void resolveIncludes(String resRoot, HashMap<Integer, String> nameMap,
HashMap<Integer, AndroidView> viewMap, boolean isSys) {
HashMap<String, AndroidView> name2View = Maps.newHashMap();
for (Map.Entry<Integer, String> entry : nameMap.entrySet()) {
String name = entry.getValue();
AndroidView view = viewMap.get(entry.getKey());
name2View.put(name, view);
}
// boolean isSys = (viewMap == sysId2View);
LinkedList<AndroidView> work = Lists.newLinkedList();
work.addAll(viewMap.values());
while (!work.isEmpty()) {
AndroidView view = work.remove();
for (int i = 0; i < view.getNumberOfChildren(); i++) {
IAndroidView child = view.getChildInternal(i);
if (child instanceof AndroidView) {
work.add((AndroidView) child);
continue;
}
IncludeAndroidView iav = (IncludeAndroidView) child;
String layoutId = iav.layoutId;
AndroidView tgt = name2View.get(layoutId);
if (tgt != null) {
tgt = (AndroidView) tgt.deepCopy();
tgt.setParent(view, i);
} else if (getLayoutFilePath(resRoot, layoutId, isSys) != null) {
// not exist, let's get it on-demand
String file = getLayoutFilePath(resRoot, layoutId, isSys);
tgt = new AndroidView();
tgt.setParent(view, i);
tgt.setOrigin(file);
readLayout(file, tgt, isSys);
int newId = nonRId--;
viewMap.put(newId, tgt);
nameMap.put(newId, layoutId);
} else if (sysRGeneralIdMap.get("layout").containsKey(layoutId) && sysId2View.containsKey
(sysRGeneralIdMap.get("layout").get(layoutId)
)) {
// <include> is used with an in built android layout id
tgt = (AndroidView) sysId2View.get(sysRGeneralIdMap.get("layout").get(layoutId)).deepCopy();
tgt.setParent(view, i);
} else {
Logger.warn(this.getClass().getSimpleName(), "Unknown layout " + layoutId
+ " included by " + view.getOrigin());
continue;
}
Integer includeeId = iav.includeeId;
if (includeeId != null) {
tgt.setId(includeeId.intValue());
}
work.add(tgt);
}
}
} | NONSATD | true | (sysRGeneralIdMap.get("layout").get(layoutId)
)) {
// <include> is used with an in built android layout id
tgt = (AndroidView) sysId2View.get(sysRGeneralIdMap.get("layout").get(layoutId)).deepCopy();
tgt.setParent(view, i); | tgt = new AndroidView();
tgt.setParent(view, i);
tgt.setOrigin(file);
readLayout(file, tgt, isSys);
int newId = nonRId--;
viewMap.put(newId, tgt);
nameMap.put(newId, layoutId);
} else if (sysRGeneralIdMap.get("layout").containsKey(layoutId) && sysId2View.containsKey
(sysRGeneralIdMap.get("layout").get(layoutId)
)) {
// <include> is used with an in built android layout id
tgt = (AndroidView) sysId2View.get(sysRGeneralIdMap.get("layout").get(layoutId)).deepCopy();
tgt.setParent(view, i);
} else {
Logger.warn(this.getClass().getSimpleName(), "Unknown layout " + layoutId
+ " included by " + view.getOrigin());
continue;
}
Integer includeeId = iav.includeeId;
if (includeeId != null) {
tgt.setId(includeeId.intValue()); | }
IncludeAndroidView iav = (IncludeAndroidView) child;
String layoutId = iav.layoutId;
AndroidView tgt = name2View.get(layoutId);
if (tgt != null) {
tgt = (AndroidView) tgt.deepCopy();
tgt.setParent(view, i);
} else if (getLayoutFilePath(resRoot, layoutId, isSys) != null) {
// not exist, let's get it on-demand
String file = getLayoutFilePath(resRoot, layoutId, isSys);
tgt = new AndroidView();
tgt.setParent(view, i);
tgt.setOrigin(file);
readLayout(file, tgt, isSys);
int newId = nonRId--;
viewMap.put(newId, tgt);
nameMap.put(newId, layoutId);
} else if (sysRGeneralIdMap.get("layout").containsKey(layoutId) && sysId2View.containsKey
(sysRGeneralIdMap.get("layout").get(layoutId)
)) {
// <include> is used with an in built android layout id
tgt = (AndroidView) sysId2View.get(sysRGeneralIdMap.get("layout").get(layoutId)).deepCopy();
tgt.setParent(view, i);
} else {
Logger.warn(this.getClass().getSimpleName(), "Unknown layout " + layoutId
+ " included by " + view.getOrigin());
continue;
}
Integer includeeId = iav.includeeId;
if (includeeId != null) {
tgt.setId(includeeId.intValue());
}
work.add(tgt);
}
}
} |
17,635 | 0 | // In older versions, Preference could be put in layout folder and we do
// not support Prefernce yet. | private void readLayout(String file, AndroidView root, boolean isSys) {
Document doc;
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(file);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
Element rootElement = doc.getDocumentElement();
// In older versions, Preference could be put in layout folder and we do
// not support Prefernce yet.
if (rootElement.getTagName().equals("PreferenceScreen")) {
return;
}
LinkedList<Pair<Node, AndroidView>> work = Lists.newLinkedList();
work.add(new Pair<Node, AndroidView>(rootElement, root));
while (!work.isEmpty()) {
Pair<Node, AndroidView> p = work.removeFirst();
Node node = p.getO1();
AndroidView view = p.getO2();
view.setOrigin(file);
NamedNodeMap attrMap = node.getAttributes();
if (attrMap == null) {
Logger.verb(this.getClass().getSimpleName(), file + "!!!" + node.getClass() + "!!!"
+ node.toString() + "!!!" + node.getTextContent());
}
// Retrieve view id (android:id)
//Node idNode = attrMap.getNamedItem(ID_ATTR);
Node idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
int guiId = -1;
String id = null;
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> pair = parseAndroidId(txt, isSys);
id = pair.getO1();
Integer guiIdObj = pair.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
} else {
guiId = guiIdObj.intValue();
if (lookupNameInGeneralMap("id", guiId, isSys) == null) {
extraId2ViewMap.put(guiIdObj, view);
}
}
}
// Retrieve view type
String guiName = node.getNodeName();
if ("view".equals(guiName)) {
// view without class attribute.
// It does happen.
if (attrMap.getNamedItem("class") == null)
continue;
guiName = attrMap.getNamedItem("class").getTextContent();
} else if (guiName.equals("MenuItemView")) {
// FIXME(tony): this is an "approximation".
guiName = "android.view.MenuItem";
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
//Retrieve callback (android:onClick)
String callback = readAndroidCallback(attrMap, "onClick");
if (callback != null) {
view.setInlineClickHandler(callback);
}
// Retrieve text (android:text)
String text = readAndroidTextOrTitle(attrMap, "text");
// hailong: add hint support
// Retrieve hint (android:hint)
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
if(attrMap.getNamedItem("app:menu") != null){
String menuName = attrMap.getNamedItem("app:menu").getTextContent();
if (menuName != null) {
Pair<String, Integer> pair = parseAndroidId(menuName, isSys);
Integer menuId = pair.getO2();
if (menuId != null) {
view.addAttr(AndroidView.Type.APP_MENU, String.valueOf(menuId));
menuId2View.put(menuId, view);
}
}
if (attrMap.getNamedItem("app:headerLayout") != null) {
String headerName = attrMap.getNamedItem("app:headerLayout").getTextContent();
if (headerName != null) {
Pair<String, Integer> pair = parseAndroidId(headerName, isSys);
Integer headerId = pair.getO2();
if (headerId != null) {
view.addAttr(AndroidView.Type.APP_HEADER_LAYOUT, String.valueOf(headerId));
menuHeaderId2View.put(headerId, view);
}
}
}
}
if ("fragment".equals(guiName)) {
Node fragmentNodeAttr = attrMap.getNamedItem("android:name");
if (fragmentNodeAttr != null) {
String fragmentClass = fragmentNodeAttr.getTextContent();
if (fragmentClass.isEmpty()) {
fragmentNodeAttr = attrMap.getNamedItem("class");
if (fragmentNodeAttr != null) {
fragmentClass = fragmentNodeAttr.getTextContent();
}
}
view.addAttr(AndroidView.Type.ANDROID_NAME, fragmentClass);
}
}
String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
}
if (nodeName.equals("requestFocus")) {
continue;
}
if (!newNode.hasAttributes() && !"TableRow".equals(nodeName)
&& !"View".equals(nodeName)) {
Logger.warn(this.getClass().getSimpleName(),
"no attribute node "
+ newNode.getNodeName());
continue;
}
if (newNode.getNodeName().equals("include")) {
attrMap = newNode.getAttributes();
if (attrMap.getNamedItem("layout") == null) {
Logger.warn("XML", "layout not exist in include");
for (int j = 0; j < attrMap.getLength(); j++) {
Logger.trace("XML", attrMap.item(j).getNodeName());
}
Logger.trace("XML", "filename" + file);
continue;
}
String layoutTxt = attrMap.getNamedItem("layout").getTextContent();
String layoutId = null;
if (layoutTxt.startsWith("@layout/")) {
layoutId = layoutTxt.substring("@layout/".length());
} else if (layoutTxt.startsWith("@android:layout/")) {
layoutId = layoutTxt.substring("@android:layout/".length());
} else if (layoutTxt.matches("@\\*android:layout\\/(\\w)+")) {
layoutId = layoutTxt.substring("@*android:layout/".length());
} else {
throw new RuntimeException("[WARNING] Unhandled layout id "
+ layoutTxt + "," + file);
}
Integer includeeId = null;
id = null;
idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> pair = parseAndroidId(txt, isSys);
id = pair.getO1();
Integer guiIdObj = pair.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id
+ " in " + file);
}
} else {
includeeId = guiIdObj;
}
}
// view.saveInclude(layoutId, includeeId);
IncludeAndroidView iav = new IncludeAndroidView(layoutId, includeeId);
iav.setParent(view);
} else {
AndroidView newView = new AndroidView();
newView.setParent(view);
work.add(new Pair<Node, AndroidView>(newNode, newView));
}
}
}
} | DESIGN | true | }
Element rootElement = doc.getDocumentElement();
// In older versions, Preference could be put in layout folder and we do
// not support Prefernce yet.
if (rootElement.getTagName().equals("PreferenceScreen")) {
return; | Document doc;
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(file);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
Element rootElement = doc.getDocumentElement();
// In older versions, Preference could be put in layout folder and we do
// not support Prefernce yet.
if (rootElement.getTagName().equals("PreferenceScreen")) {
return;
}
LinkedList<Pair<Node, AndroidView>> work = Lists.newLinkedList();
work.add(new Pair<Node, AndroidView>(rootElement, root));
while (!work.isEmpty()) {
Pair<Node, AndroidView> p = work.removeFirst();
Node node = p.getO1();
AndroidView view = p.getO2();
view.setOrigin(file); | private void readLayout(String file, AndroidView root, boolean isSys) {
Document doc;
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(file);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
Element rootElement = doc.getDocumentElement();
// In older versions, Preference could be put in layout folder and we do
// not support Prefernce yet.
if (rootElement.getTagName().equals("PreferenceScreen")) {
return;
}
LinkedList<Pair<Node, AndroidView>> work = Lists.newLinkedList();
work.add(new Pair<Node, AndroidView>(rootElement, root));
while (!work.isEmpty()) {
Pair<Node, AndroidView> p = work.removeFirst();
Node node = p.getO1();
AndroidView view = p.getO2();
view.setOrigin(file);
NamedNodeMap attrMap = node.getAttributes();
if (attrMap == null) {
Logger.verb(this.getClass().getSimpleName(), file + "!!!" + node.getClass() + "!!!"
+ node.toString() + "!!!" + node.getTextContent());
}
// Retrieve view id (android:id)
//Node idNode = attrMap.getNamedItem(ID_ATTR);
Node idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
int guiId = -1;
String id = null; |
17,635 | 1 | // Retrieve view id (android:id)
//Node idNode = attrMap.getNamedItem(ID_ATTR); | private void readLayout(String file, AndroidView root, boolean isSys) {
Document doc;
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(file);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
Element rootElement = doc.getDocumentElement();
// In older versions, Preference could be put in layout folder and we do
// not support Prefernce yet.
if (rootElement.getTagName().equals("PreferenceScreen")) {
return;
}
LinkedList<Pair<Node, AndroidView>> work = Lists.newLinkedList();
work.add(new Pair<Node, AndroidView>(rootElement, root));
while (!work.isEmpty()) {
Pair<Node, AndroidView> p = work.removeFirst();
Node node = p.getO1();
AndroidView view = p.getO2();
view.setOrigin(file);
NamedNodeMap attrMap = node.getAttributes();
if (attrMap == null) {
Logger.verb(this.getClass().getSimpleName(), file + "!!!" + node.getClass() + "!!!"
+ node.toString() + "!!!" + node.getTextContent());
}
// Retrieve view id (android:id)
//Node idNode = attrMap.getNamedItem(ID_ATTR);
Node idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
int guiId = -1;
String id = null;
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> pair = parseAndroidId(txt, isSys);
id = pair.getO1();
Integer guiIdObj = pair.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
} else {
guiId = guiIdObj.intValue();
if (lookupNameInGeneralMap("id", guiId, isSys) == null) {
extraId2ViewMap.put(guiIdObj, view);
}
}
}
// Retrieve view type
String guiName = node.getNodeName();
if ("view".equals(guiName)) {
// view without class attribute.
// It does happen.
if (attrMap.getNamedItem("class") == null)
continue;
guiName = attrMap.getNamedItem("class").getTextContent();
} else if (guiName.equals("MenuItemView")) {
// FIXME(tony): this is an "approximation".
guiName = "android.view.MenuItem";
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
//Retrieve callback (android:onClick)
String callback = readAndroidCallback(attrMap, "onClick");
if (callback != null) {
view.setInlineClickHandler(callback);
}
// Retrieve text (android:text)
String text = readAndroidTextOrTitle(attrMap, "text");
// hailong: add hint support
// Retrieve hint (android:hint)
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
if(attrMap.getNamedItem("app:menu") != null){
String menuName = attrMap.getNamedItem("app:menu").getTextContent();
if (menuName != null) {
Pair<String, Integer> pair = parseAndroidId(menuName, isSys);
Integer menuId = pair.getO2();
if (menuId != null) {
view.addAttr(AndroidView.Type.APP_MENU, String.valueOf(menuId));
menuId2View.put(menuId, view);
}
}
if (attrMap.getNamedItem("app:headerLayout") != null) {
String headerName = attrMap.getNamedItem("app:headerLayout").getTextContent();
if (headerName != null) {
Pair<String, Integer> pair = parseAndroidId(headerName, isSys);
Integer headerId = pair.getO2();
if (headerId != null) {
view.addAttr(AndroidView.Type.APP_HEADER_LAYOUT, String.valueOf(headerId));
menuHeaderId2View.put(headerId, view);
}
}
}
}
if ("fragment".equals(guiName)) {
Node fragmentNodeAttr = attrMap.getNamedItem("android:name");
if (fragmentNodeAttr != null) {
String fragmentClass = fragmentNodeAttr.getTextContent();
if (fragmentClass.isEmpty()) {
fragmentNodeAttr = attrMap.getNamedItem("class");
if (fragmentNodeAttr != null) {
fragmentClass = fragmentNodeAttr.getTextContent();
}
}
view.addAttr(AndroidView.Type.ANDROID_NAME, fragmentClass);
}
}
String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
}
if (nodeName.equals("requestFocus")) {
continue;
}
if (!newNode.hasAttributes() && !"TableRow".equals(nodeName)
&& !"View".equals(nodeName)) {
Logger.warn(this.getClass().getSimpleName(),
"no attribute node "
+ newNode.getNodeName());
continue;
}
if (newNode.getNodeName().equals("include")) {
attrMap = newNode.getAttributes();
if (attrMap.getNamedItem("layout") == null) {
Logger.warn("XML", "layout not exist in include");
for (int j = 0; j < attrMap.getLength(); j++) {
Logger.trace("XML", attrMap.item(j).getNodeName());
}
Logger.trace("XML", "filename" + file);
continue;
}
String layoutTxt = attrMap.getNamedItem("layout").getTextContent();
String layoutId = null;
if (layoutTxt.startsWith("@layout/")) {
layoutId = layoutTxt.substring("@layout/".length());
} else if (layoutTxt.startsWith("@android:layout/")) {
layoutId = layoutTxt.substring("@android:layout/".length());
} else if (layoutTxt.matches("@\\*android:layout\\/(\\w)+")) {
layoutId = layoutTxt.substring("@*android:layout/".length());
} else {
throw new RuntimeException("[WARNING] Unhandled layout id "
+ layoutTxt + "," + file);
}
Integer includeeId = null;
id = null;
idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> pair = parseAndroidId(txt, isSys);
id = pair.getO1();
Integer guiIdObj = pair.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id
+ " in " + file);
}
} else {
includeeId = guiIdObj;
}
}
// view.saveInclude(layoutId, includeeId);
IncludeAndroidView iav = new IncludeAndroidView(layoutId, includeeId);
iav.setParent(view);
} else {
AndroidView newView = new AndroidView();
newView.setParent(view);
work.add(new Pair<Node, AndroidView>(newNode, newView));
}
}
}
} | NONSATD | true | + node.toString() + "!!!" + node.getTextContent());
}
// Retrieve view id (android:id)
//Node idNode = attrMap.getNamedItem(ID_ATTR);
Node idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
int guiId = -1; | while (!work.isEmpty()) {
Pair<Node, AndroidView> p = work.removeFirst();
Node node = p.getO1();
AndroidView view = p.getO2();
view.setOrigin(file);
NamedNodeMap attrMap = node.getAttributes();
if (attrMap == null) {
Logger.verb(this.getClass().getSimpleName(), file + "!!!" + node.getClass() + "!!!"
+ node.toString() + "!!!" + node.getTextContent());
}
// Retrieve view id (android:id)
//Node idNode = attrMap.getNamedItem(ID_ATTR);
Node idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
int guiId = -1;
String id = null;
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> pair = parseAndroidId(txt, isSys);
id = pair.getO1();
Integer guiIdObj = pair.getO2();
if (guiIdObj == null) {
if (!isSys) { | throw new RuntimeException(ex);
}
Element rootElement = doc.getDocumentElement();
// In older versions, Preference could be put in layout folder and we do
// not support Prefernce yet.
if (rootElement.getTagName().equals("PreferenceScreen")) {
return;
}
LinkedList<Pair<Node, AndroidView>> work = Lists.newLinkedList();
work.add(new Pair<Node, AndroidView>(rootElement, root));
while (!work.isEmpty()) {
Pair<Node, AndroidView> p = work.removeFirst();
Node node = p.getO1();
AndroidView view = p.getO2();
view.setOrigin(file);
NamedNodeMap attrMap = node.getAttributes();
if (attrMap == null) {
Logger.verb(this.getClass().getSimpleName(), file + "!!!" + node.getClass() + "!!!"
+ node.toString() + "!!!" + node.getTextContent());
}
// Retrieve view id (android:id)
//Node idNode = attrMap.getNamedItem(ID_ATTR);
Node idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
int guiId = -1;
String id = null;
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> pair = parseAndroidId(txt, isSys);
id = pair.getO1();
Integer guiIdObj = pair.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
} else {
guiId = guiIdObj.intValue();
if (lookupNameInGeneralMap("id", guiId, isSys) == null) {
extraId2ViewMap.put(guiIdObj, view);
}
} |
17,635 | 2 | // Retrieve view type | private void readLayout(String file, AndroidView root, boolean isSys) {
Document doc;
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(file);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
Element rootElement = doc.getDocumentElement();
// In older versions, Preference could be put in layout folder and we do
// not support Prefernce yet.
if (rootElement.getTagName().equals("PreferenceScreen")) {
return;
}
LinkedList<Pair<Node, AndroidView>> work = Lists.newLinkedList();
work.add(new Pair<Node, AndroidView>(rootElement, root));
while (!work.isEmpty()) {
Pair<Node, AndroidView> p = work.removeFirst();
Node node = p.getO1();
AndroidView view = p.getO2();
view.setOrigin(file);
NamedNodeMap attrMap = node.getAttributes();
if (attrMap == null) {
Logger.verb(this.getClass().getSimpleName(), file + "!!!" + node.getClass() + "!!!"
+ node.toString() + "!!!" + node.getTextContent());
}
// Retrieve view id (android:id)
//Node idNode = attrMap.getNamedItem(ID_ATTR);
Node idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
int guiId = -1;
String id = null;
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> pair = parseAndroidId(txt, isSys);
id = pair.getO1();
Integer guiIdObj = pair.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
} else {
guiId = guiIdObj.intValue();
if (lookupNameInGeneralMap("id", guiId, isSys) == null) {
extraId2ViewMap.put(guiIdObj, view);
}
}
}
// Retrieve view type
String guiName = node.getNodeName();
if ("view".equals(guiName)) {
// view without class attribute.
// It does happen.
if (attrMap.getNamedItem("class") == null)
continue;
guiName = attrMap.getNamedItem("class").getTextContent();
} else if (guiName.equals("MenuItemView")) {
// FIXME(tony): this is an "approximation".
guiName = "android.view.MenuItem";
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
//Retrieve callback (android:onClick)
String callback = readAndroidCallback(attrMap, "onClick");
if (callback != null) {
view.setInlineClickHandler(callback);
}
// Retrieve text (android:text)
String text = readAndroidTextOrTitle(attrMap, "text");
// hailong: add hint support
// Retrieve hint (android:hint)
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
if(attrMap.getNamedItem("app:menu") != null){
String menuName = attrMap.getNamedItem("app:menu").getTextContent();
if (menuName != null) {
Pair<String, Integer> pair = parseAndroidId(menuName, isSys);
Integer menuId = pair.getO2();
if (menuId != null) {
view.addAttr(AndroidView.Type.APP_MENU, String.valueOf(menuId));
menuId2View.put(menuId, view);
}
}
if (attrMap.getNamedItem("app:headerLayout") != null) {
String headerName = attrMap.getNamedItem("app:headerLayout").getTextContent();
if (headerName != null) {
Pair<String, Integer> pair = parseAndroidId(headerName, isSys);
Integer headerId = pair.getO2();
if (headerId != null) {
view.addAttr(AndroidView.Type.APP_HEADER_LAYOUT, String.valueOf(headerId));
menuHeaderId2View.put(headerId, view);
}
}
}
}
if ("fragment".equals(guiName)) {
Node fragmentNodeAttr = attrMap.getNamedItem("android:name");
if (fragmentNodeAttr != null) {
String fragmentClass = fragmentNodeAttr.getTextContent();
if (fragmentClass.isEmpty()) {
fragmentNodeAttr = attrMap.getNamedItem("class");
if (fragmentNodeAttr != null) {
fragmentClass = fragmentNodeAttr.getTextContent();
}
}
view.addAttr(AndroidView.Type.ANDROID_NAME, fragmentClass);
}
}
String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
}
if (nodeName.equals("requestFocus")) {
continue;
}
if (!newNode.hasAttributes() && !"TableRow".equals(nodeName)
&& !"View".equals(nodeName)) {
Logger.warn(this.getClass().getSimpleName(),
"no attribute node "
+ newNode.getNodeName());
continue;
}
if (newNode.getNodeName().equals("include")) {
attrMap = newNode.getAttributes();
if (attrMap.getNamedItem("layout") == null) {
Logger.warn("XML", "layout not exist in include");
for (int j = 0; j < attrMap.getLength(); j++) {
Logger.trace("XML", attrMap.item(j).getNodeName());
}
Logger.trace("XML", "filename" + file);
continue;
}
String layoutTxt = attrMap.getNamedItem("layout").getTextContent();
String layoutId = null;
if (layoutTxt.startsWith("@layout/")) {
layoutId = layoutTxt.substring("@layout/".length());
} else if (layoutTxt.startsWith("@android:layout/")) {
layoutId = layoutTxt.substring("@android:layout/".length());
} else if (layoutTxt.matches("@\\*android:layout\\/(\\w)+")) {
layoutId = layoutTxt.substring("@*android:layout/".length());
} else {
throw new RuntimeException("[WARNING] Unhandled layout id "
+ layoutTxt + "," + file);
}
Integer includeeId = null;
id = null;
idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> pair = parseAndroidId(txt, isSys);
id = pair.getO1();
Integer guiIdObj = pair.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id
+ " in " + file);
}
} else {
includeeId = guiIdObj;
}
}
// view.saveInclude(layoutId, includeeId);
IncludeAndroidView iav = new IncludeAndroidView(layoutId, includeeId);
iav.setParent(view);
} else {
AndroidView newView = new AndroidView();
newView.setParent(view);
work.add(new Pair<Node, AndroidView>(newNode, newView));
}
}
}
} | NONSATD | true | }
}
// Retrieve view type
String guiName = node.getNodeName();
if ("view".equals(guiName)) { | "unresolved android:id " + id + " in "
+ file);
}
} else {
guiId = guiIdObj.intValue();
if (lookupNameInGeneralMap("id", guiId, isSys) == null) {
extraId2ViewMap.put(guiIdObj, view);
}
}
}
// Retrieve view type
String guiName = node.getNodeName();
if ("view".equals(guiName)) {
// view without class attribute.
// It does happen.
if (attrMap.getNamedItem("class") == null)
continue;
guiName = attrMap.getNamedItem("class").getTextContent();
} else if (guiName.equals("MenuItemView")) {
// FIXME(tony): this is an "approximation".
guiName = "android.view.MenuItem"; | int guiId = -1;
String id = null;
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> pair = parseAndroidId(txt, isSys);
id = pair.getO1();
Integer guiIdObj = pair.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
} else {
guiId = guiIdObj.intValue();
if (lookupNameInGeneralMap("id", guiId, isSys) == null) {
extraId2ViewMap.put(guiIdObj, view);
}
}
}
// Retrieve view type
String guiName = node.getNodeName();
if ("view".equals(guiName)) {
// view without class attribute.
// It does happen.
if (attrMap.getNamedItem("class") == null)
continue;
guiName = attrMap.getNamedItem("class").getTextContent();
} else if (guiName.equals("MenuItemView")) {
// FIXME(tony): this is an "approximation".
guiName = "android.view.MenuItem";
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
//Retrieve callback (android:onClick)
String callback = readAndroidCallback(attrMap, "onClick");
if (callback != null) {
view.setInlineClickHandler(callback);
}
// Retrieve text (android:text) |
17,635 | 3 | // view without class attribute.
// It does happen. | private void readLayout(String file, AndroidView root, boolean isSys) {
Document doc;
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(file);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
Element rootElement = doc.getDocumentElement();
// In older versions, Preference could be put in layout folder and we do
// not support Prefernce yet.
if (rootElement.getTagName().equals("PreferenceScreen")) {
return;
}
LinkedList<Pair<Node, AndroidView>> work = Lists.newLinkedList();
work.add(new Pair<Node, AndroidView>(rootElement, root));
while (!work.isEmpty()) {
Pair<Node, AndroidView> p = work.removeFirst();
Node node = p.getO1();
AndroidView view = p.getO2();
view.setOrigin(file);
NamedNodeMap attrMap = node.getAttributes();
if (attrMap == null) {
Logger.verb(this.getClass().getSimpleName(), file + "!!!" + node.getClass() + "!!!"
+ node.toString() + "!!!" + node.getTextContent());
}
// Retrieve view id (android:id)
//Node idNode = attrMap.getNamedItem(ID_ATTR);
Node idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
int guiId = -1;
String id = null;
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> pair = parseAndroidId(txt, isSys);
id = pair.getO1();
Integer guiIdObj = pair.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
} else {
guiId = guiIdObj.intValue();
if (lookupNameInGeneralMap("id", guiId, isSys) == null) {
extraId2ViewMap.put(guiIdObj, view);
}
}
}
// Retrieve view type
String guiName = node.getNodeName();
if ("view".equals(guiName)) {
// view without class attribute.
// It does happen.
if (attrMap.getNamedItem("class") == null)
continue;
guiName = attrMap.getNamedItem("class").getTextContent();
} else if (guiName.equals("MenuItemView")) {
// FIXME(tony): this is an "approximation".
guiName = "android.view.MenuItem";
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
//Retrieve callback (android:onClick)
String callback = readAndroidCallback(attrMap, "onClick");
if (callback != null) {
view.setInlineClickHandler(callback);
}
// Retrieve text (android:text)
String text = readAndroidTextOrTitle(attrMap, "text");
// hailong: add hint support
// Retrieve hint (android:hint)
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
if(attrMap.getNamedItem("app:menu") != null){
String menuName = attrMap.getNamedItem("app:menu").getTextContent();
if (menuName != null) {
Pair<String, Integer> pair = parseAndroidId(menuName, isSys);
Integer menuId = pair.getO2();
if (menuId != null) {
view.addAttr(AndroidView.Type.APP_MENU, String.valueOf(menuId));
menuId2View.put(menuId, view);
}
}
if (attrMap.getNamedItem("app:headerLayout") != null) {
String headerName = attrMap.getNamedItem("app:headerLayout").getTextContent();
if (headerName != null) {
Pair<String, Integer> pair = parseAndroidId(headerName, isSys);
Integer headerId = pair.getO2();
if (headerId != null) {
view.addAttr(AndroidView.Type.APP_HEADER_LAYOUT, String.valueOf(headerId));
menuHeaderId2View.put(headerId, view);
}
}
}
}
if ("fragment".equals(guiName)) {
Node fragmentNodeAttr = attrMap.getNamedItem("android:name");
if (fragmentNodeAttr != null) {
String fragmentClass = fragmentNodeAttr.getTextContent();
if (fragmentClass.isEmpty()) {
fragmentNodeAttr = attrMap.getNamedItem("class");
if (fragmentNodeAttr != null) {
fragmentClass = fragmentNodeAttr.getTextContent();
}
}
view.addAttr(AndroidView.Type.ANDROID_NAME, fragmentClass);
}
}
String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
}
if (nodeName.equals("requestFocus")) {
continue;
}
if (!newNode.hasAttributes() && !"TableRow".equals(nodeName)
&& !"View".equals(nodeName)) {
Logger.warn(this.getClass().getSimpleName(),
"no attribute node "
+ newNode.getNodeName());
continue;
}
if (newNode.getNodeName().equals("include")) {
attrMap = newNode.getAttributes();
if (attrMap.getNamedItem("layout") == null) {
Logger.warn("XML", "layout not exist in include");
for (int j = 0; j < attrMap.getLength(); j++) {
Logger.trace("XML", attrMap.item(j).getNodeName());
}
Logger.trace("XML", "filename" + file);
continue;
}
String layoutTxt = attrMap.getNamedItem("layout").getTextContent();
String layoutId = null;
if (layoutTxt.startsWith("@layout/")) {
layoutId = layoutTxt.substring("@layout/".length());
} else if (layoutTxt.startsWith("@android:layout/")) {
layoutId = layoutTxt.substring("@android:layout/".length());
} else if (layoutTxt.matches("@\\*android:layout\\/(\\w)+")) {
layoutId = layoutTxt.substring("@*android:layout/".length());
} else {
throw new RuntimeException("[WARNING] Unhandled layout id "
+ layoutTxt + "," + file);
}
Integer includeeId = null;
id = null;
idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> pair = parseAndroidId(txt, isSys);
id = pair.getO1();
Integer guiIdObj = pair.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id
+ " in " + file);
}
} else {
includeeId = guiIdObj;
}
}
// view.saveInclude(layoutId, includeeId);
IncludeAndroidView iav = new IncludeAndroidView(layoutId, includeeId);
iav.setParent(view);
} else {
AndroidView newView = new AndroidView();
newView.setParent(view);
work.add(new Pair<Node, AndroidView>(newNode, newView));
}
}
}
} | NONSATD | true | String guiName = node.getNodeName();
if ("view".equals(guiName)) {
// view without class attribute.
// It does happen.
if (attrMap.getNamedItem("class") == null)
continue; | } else {
guiId = guiIdObj.intValue();
if (lookupNameInGeneralMap("id", guiId, isSys) == null) {
extraId2ViewMap.put(guiIdObj, view);
}
}
}
// Retrieve view type
String guiName = node.getNodeName();
if ("view".equals(guiName)) {
// view without class attribute.
// It does happen.
if (attrMap.getNamedItem("class") == null)
continue;
guiName = attrMap.getNamedItem("class").getTextContent();
} else if (guiName.equals("MenuItemView")) {
// FIXME(tony): this is an "approximation".
guiName = "android.view.MenuItem";
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
} | String txt = idNode.getTextContent();
Pair<String, Integer> pair = parseAndroidId(txt, isSys);
id = pair.getO1();
Integer guiIdObj = pair.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
} else {
guiId = guiIdObj.intValue();
if (lookupNameInGeneralMap("id", guiId, isSys) == null) {
extraId2ViewMap.put(guiIdObj, view);
}
}
}
// Retrieve view type
String guiName = node.getNodeName();
if ("view".equals(guiName)) {
// view without class attribute.
// It does happen.
if (attrMap.getNamedItem("class") == null)
continue;
guiName = attrMap.getNamedItem("class").getTextContent();
} else if (guiName.equals("MenuItemView")) {
// FIXME(tony): this is an "approximation".
guiName = "android.view.MenuItem";
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
//Retrieve callback (android:onClick)
String callback = readAndroidCallback(attrMap, "onClick");
if (callback != null) {
view.setInlineClickHandler(callback);
}
// Retrieve text (android:text)
String text = readAndroidTextOrTitle(attrMap, "text");
// hailong: add hint support
// Retrieve hint (android:hint)
String hint = readAndroidTextOrTitle(attrMap, "hint"); |
17,635 | 4 | // FIXME(tony): this is an "approximation". | private void readLayout(String file, AndroidView root, boolean isSys) {
Document doc;
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(file);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
Element rootElement = doc.getDocumentElement();
// In older versions, Preference could be put in layout folder and we do
// not support Prefernce yet.
if (rootElement.getTagName().equals("PreferenceScreen")) {
return;
}
LinkedList<Pair<Node, AndroidView>> work = Lists.newLinkedList();
work.add(new Pair<Node, AndroidView>(rootElement, root));
while (!work.isEmpty()) {
Pair<Node, AndroidView> p = work.removeFirst();
Node node = p.getO1();
AndroidView view = p.getO2();
view.setOrigin(file);
NamedNodeMap attrMap = node.getAttributes();
if (attrMap == null) {
Logger.verb(this.getClass().getSimpleName(), file + "!!!" + node.getClass() + "!!!"
+ node.toString() + "!!!" + node.getTextContent());
}
// Retrieve view id (android:id)
//Node idNode = attrMap.getNamedItem(ID_ATTR);
Node idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
int guiId = -1;
String id = null;
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> pair = parseAndroidId(txt, isSys);
id = pair.getO1();
Integer guiIdObj = pair.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
} else {
guiId = guiIdObj.intValue();
if (lookupNameInGeneralMap("id", guiId, isSys) == null) {
extraId2ViewMap.put(guiIdObj, view);
}
}
}
// Retrieve view type
String guiName = node.getNodeName();
if ("view".equals(guiName)) {
// view without class attribute.
// It does happen.
if (attrMap.getNamedItem("class") == null)
continue;
guiName = attrMap.getNamedItem("class").getTextContent();
} else if (guiName.equals("MenuItemView")) {
// FIXME(tony): this is an "approximation".
guiName = "android.view.MenuItem";
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
//Retrieve callback (android:onClick)
String callback = readAndroidCallback(attrMap, "onClick");
if (callback != null) {
view.setInlineClickHandler(callback);
}
// Retrieve text (android:text)
String text = readAndroidTextOrTitle(attrMap, "text");
// hailong: add hint support
// Retrieve hint (android:hint)
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
if(attrMap.getNamedItem("app:menu") != null){
String menuName = attrMap.getNamedItem("app:menu").getTextContent();
if (menuName != null) {
Pair<String, Integer> pair = parseAndroidId(menuName, isSys);
Integer menuId = pair.getO2();
if (menuId != null) {
view.addAttr(AndroidView.Type.APP_MENU, String.valueOf(menuId));
menuId2View.put(menuId, view);
}
}
if (attrMap.getNamedItem("app:headerLayout") != null) {
String headerName = attrMap.getNamedItem("app:headerLayout").getTextContent();
if (headerName != null) {
Pair<String, Integer> pair = parseAndroidId(headerName, isSys);
Integer headerId = pair.getO2();
if (headerId != null) {
view.addAttr(AndroidView.Type.APP_HEADER_LAYOUT, String.valueOf(headerId));
menuHeaderId2View.put(headerId, view);
}
}
}
}
if ("fragment".equals(guiName)) {
Node fragmentNodeAttr = attrMap.getNamedItem("android:name");
if (fragmentNodeAttr != null) {
String fragmentClass = fragmentNodeAttr.getTextContent();
if (fragmentClass.isEmpty()) {
fragmentNodeAttr = attrMap.getNamedItem("class");
if (fragmentNodeAttr != null) {
fragmentClass = fragmentNodeAttr.getTextContent();
}
}
view.addAttr(AndroidView.Type.ANDROID_NAME, fragmentClass);
}
}
String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
}
if (nodeName.equals("requestFocus")) {
continue;
}
if (!newNode.hasAttributes() && !"TableRow".equals(nodeName)
&& !"View".equals(nodeName)) {
Logger.warn(this.getClass().getSimpleName(),
"no attribute node "
+ newNode.getNodeName());
continue;
}
if (newNode.getNodeName().equals("include")) {
attrMap = newNode.getAttributes();
if (attrMap.getNamedItem("layout") == null) {
Logger.warn("XML", "layout not exist in include");
for (int j = 0; j < attrMap.getLength(); j++) {
Logger.trace("XML", attrMap.item(j).getNodeName());
}
Logger.trace("XML", "filename" + file);
continue;
}
String layoutTxt = attrMap.getNamedItem("layout").getTextContent();
String layoutId = null;
if (layoutTxt.startsWith("@layout/")) {
layoutId = layoutTxt.substring("@layout/".length());
} else if (layoutTxt.startsWith("@android:layout/")) {
layoutId = layoutTxt.substring("@android:layout/".length());
} else if (layoutTxt.matches("@\\*android:layout\\/(\\w)+")) {
layoutId = layoutTxt.substring("@*android:layout/".length());
} else {
throw new RuntimeException("[WARNING] Unhandled layout id "
+ layoutTxt + "," + file);
}
Integer includeeId = null;
id = null;
idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> pair = parseAndroidId(txt, isSys);
id = pair.getO1();
Integer guiIdObj = pair.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id
+ " in " + file);
}
} else {
includeeId = guiIdObj;
}
}
// view.saveInclude(layoutId, includeeId);
IncludeAndroidView iav = new IncludeAndroidView(layoutId, includeeId);
iav.setParent(view);
} else {
AndroidView newView = new AndroidView();
newView.setParent(view);
work.add(new Pair<Node, AndroidView>(newNode, newView));
}
}
}
} | DEFECT | true | guiName = attrMap.getNamedItem("class").getTextContent();
} else if (guiName.equals("MenuItemView")) {
// FIXME(tony): this is an "approximation".
guiName = "android.view.MenuItem";
} | }
// Retrieve view type
String guiName = node.getNodeName();
if ("view".equals(guiName)) {
// view without class attribute.
// It does happen.
if (attrMap.getNamedItem("class") == null)
continue;
guiName = attrMap.getNamedItem("class").getTextContent();
} else if (guiName.equals("MenuItemView")) {
// FIXME(tony): this is an "approximation".
guiName = "android.view.MenuItem";
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
//Retrieve callback (android:onClick)
String callback = readAndroidCallback(attrMap, "onClick");
if (callback != null) {
view.setInlineClickHandler(callback);
} | Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
} else {
guiId = guiIdObj.intValue();
if (lookupNameInGeneralMap("id", guiId, isSys) == null) {
extraId2ViewMap.put(guiIdObj, view);
}
}
}
// Retrieve view type
String guiName = node.getNodeName();
if ("view".equals(guiName)) {
// view without class attribute.
// It does happen.
if (attrMap.getNamedItem("class") == null)
continue;
guiName = attrMap.getNamedItem("class").getTextContent();
} else if (guiName.equals("MenuItemView")) {
// FIXME(tony): this is an "approximation".
guiName = "android.view.MenuItem";
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
//Retrieve callback (android:onClick)
String callback = readAndroidCallback(attrMap, "onClick");
if (callback != null) {
view.setInlineClickHandler(callback);
}
// Retrieve text (android:text)
String text = readAndroidTextOrTitle(attrMap, "text");
// hailong: add hint support
// Retrieve hint (android:hint)
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
if(attrMap.getNamedItem("app:menu") != null){
String menuName = attrMap.getNamedItem("app:menu").getTextContent(); |
17,635 | 5 | //Retrieve callback (android:onClick) | private void readLayout(String file, AndroidView root, boolean isSys) {
Document doc;
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(file);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
Element rootElement = doc.getDocumentElement();
// In older versions, Preference could be put in layout folder and we do
// not support Prefernce yet.
if (rootElement.getTagName().equals("PreferenceScreen")) {
return;
}
LinkedList<Pair<Node, AndroidView>> work = Lists.newLinkedList();
work.add(new Pair<Node, AndroidView>(rootElement, root));
while (!work.isEmpty()) {
Pair<Node, AndroidView> p = work.removeFirst();
Node node = p.getO1();
AndroidView view = p.getO2();
view.setOrigin(file);
NamedNodeMap attrMap = node.getAttributes();
if (attrMap == null) {
Logger.verb(this.getClass().getSimpleName(), file + "!!!" + node.getClass() + "!!!"
+ node.toString() + "!!!" + node.getTextContent());
}
// Retrieve view id (android:id)
//Node idNode = attrMap.getNamedItem(ID_ATTR);
Node idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
int guiId = -1;
String id = null;
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> pair = parseAndroidId(txt, isSys);
id = pair.getO1();
Integer guiIdObj = pair.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
} else {
guiId = guiIdObj.intValue();
if (lookupNameInGeneralMap("id", guiId, isSys) == null) {
extraId2ViewMap.put(guiIdObj, view);
}
}
}
// Retrieve view type
String guiName = node.getNodeName();
if ("view".equals(guiName)) {
// view without class attribute.
// It does happen.
if (attrMap.getNamedItem("class") == null)
continue;
guiName = attrMap.getNamedItem("class").getTextContent();
} else if (guiName.equals("MenuItemView")) {
// FIXME(tony): this is an "approximation".
guiName = "android.view.MenuItem";
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
//Retrieve callback (android:onClick)
String callback = readAndroidCallback(attrMap, "onClick");
if (callback != null) {
view.setInlineClickHandler(callback);
}
// Retrieve text (android:text)
String text = readAndroidTextOrTitle(attrMap, "text");
// hailong: add hint support
// Retrieve hint (android:hint)
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
if(attrMap.getNamedItem("app:menu") != null){
String menuName = attrMap.getNamedItem("app:menu").getTextContent();
if (menuName != null) {
Pair<String, Integer> pair = parseAndroidId(menuName, isSys);
Integer menuId = pair.getO2();
if (menuId != null) {
view.addAttr(AndroidView.Type.APP_MENU, String.valueOf(menuId));
menuId2View.put(menuId, view);
}
}
if (attrMap.getNamedItem("app:headerLayout") != null) {
String headerName = attrMap.getNamedItem("app:headerLayout").getTextContent();
if (headerName != null) {
Pair<String, Integer> pair = parseAndroidId(headerName, isSys);
Integer headerId = pair.getO2();
if (headerId != null) {
view.addAttr(AndroidView.Type.APP_HEADER_LAYOUT, String.valueOf(headerId));
menuHeaderId2View.put(headerId, view);
}
}
}
}
if ("fragment".equals(guiName)) {
Node fragmentNodeAttr = attrMap.getNamedItem("android:name");
if (fragmentNodeAttr != null) {
String fragmentClass = fragmentNodeAttr.getTextContent();
if (fragmentClass.isEmpty()) {
fragmentNodeAttr = attrMap.getNamedItem("class");
if (fragmentNodeAttr != null) {
fragmentClass = fragmentNodeAttr.getTextContent();
}
}
view.addAttr(AndroidView.Type.ANDROID_NAME, fragmentClass);
}
}
String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
}
if (nodeName.equals("requestFocus")) {
continue;
}
if (!newNode.hasAttributes() && !"TableRow".equals(nodeName)
&& !"View".equals(nodeName)) {
Logger.warn(this.getClass().getSimpleName(),
"no attribute node "
+ newNode.getNodeName());
continue;
}
if (newNode.getNodeName().equals("include")) {
attrMap = newNode.getAttributes();
if (attrMap.getNamedItem("layout") == null) {
Logger.warn("XML", "layout not exist in include");
for (int j = 0; j < attrMap.getLength(); j++) {
Logger.trace("XML", attrMap.item(j).getNodeName());
}
Logger.trace("XML", "filename" + file);
continue;
}
String layoutTxt = attrMap.getNamedItem("layout").getTextContent();
String layoutId = null;
if (layoutTxt.startsWith("@layout/")) {
layoutId = layoutTxt.substring("@layout/".length());
} else if (layoutTxt.startsWith("@android:layout/")) {
layoutId = layoutTxt.substring("@android:layout/".length());
} else if (layoutTxt.matches("@\\*android:layout\\/(\\w)+")) {
layoutId = layoutTxt.substring("@*android:layout/".length());
} else {
throw new RuntimeException("[WARNING] Unhandled layout id "
+ layoutTxt + "," + file);
}
Integer includeeId = null;
id = null;
idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> pair = parseAndroidId(txt, isSys);
id = pair.getO1();
Integer guiIdObj = pair.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id
+ " in " + file);
}
} else {
includeeId = guiIdObj;
}
}
// view.saveInclude(layoutId, includeeId);
IncludeAndroidView iav = new IncludeAndroidView(layoutId, includeeId);
iav.setParent(view);
} else {
AndroidView newView = new AndroidView();
newView.setParent(view);
work.add(new Pair<Node, AndroidView>(newNode, newView));
}
}
}
} | NONSATD | true | Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
//Retrieve callback (android:onClick)
String callback = readAndroidCallback(attrMap, "onClick");
if (callback != null) { | if (attrMap.getNamedItem("class") == null)
continue;
guiName = attrMap.getNamedItem("class").getTextContent();
} else if (guiName.equals("MenuItemView")) {
// FIXME(tony): this is an "approximation".
guiName = "android.view.MenuItem";
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
//Retrieve callback (android:onClick)
String callback = readAndroidCallback(attrMap, "onClick");
if (callback != null) {
view.setInlineClickHandler(callback);
}
// Retrieve text (android:text)
String text = readAndroidTextOrTitle(attrMap, "text");
// hailong: add hint support
// Retrieve hint (android:hint)
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints"); | if (lookupNameInGeneralMap("id", guiId, isSys) == null) {
extraId2ViewMap.put(guiIdObj, view);
}
}
}
// Retrieve view type
String guiName = node.getNodeName();
if ("view".equals(guiName)) {
// view without class attribute.
// It does happen.
if (attrMap.getNamedItem("class") == null)
continue;
guiName = attrMap.getNamedItem("class").getTextContent();
} else if (guiName.equals("MenuItemView")) {
// FIXME(tony): this is an "approximation".
guiName = "android.view.MenuItem";
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
//Retrieve callback (android:onClick)
String callback = readAndroidCallback(attrMap, "onClick");
if (callback != null) {
view.setInlineClickHandler(callback);
}
// Retrieve text (android:text)
String text = readAndroidTextOrTitle(attrMap, "text");
// hailong: add hint support
// Retrieve hint (android:hint)
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
if(attrMap.getNamedItem("app:menu") != null){
String menuName = attrMap.getNamedItem("app:menu").getTextContent();
if (menuName != null) {
Pair<String, Integer> pair = parseAndroidId(menuName, isSys);
Integer menuId = pair.getO2();
if (menuId != null) {
view.addAttr(AndroidView.Type.APP_MENU, String.valueOf(menuId));
menuId2View.put(menuId, view); |
17,635 | 6 | // Retrieve text (android:text) | private void readLayout(String file, AndroidView root, boolean isSys) {
Document doc;
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(file);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
Element rootElement = doc.getDocumentElement();
// In older versions, Preference could be put in layout folder and we do
// not support Prefernce yet.
if (rootElement.getTagName().equals("PreferenceScreen")) {
return;
}
LinkedList<Pair<Node, AndroidView>> work = Lists.newLinkedList();
work.add(new Pair<Node, AndroidView>(rootElement, root));
while (!work.isEmpty()) {
Pair<Node, AndroidView> p = work.removeFirst();
Node node = p.getO1();
AndroidView view = p.getO2();
view.setOrigin(file);
NamedNodeMap attrMap = node.getAttributes();
if (attrMap == null) {
Logger.verb(this.getClass().getSimpleName(), file + "!!!" + node.getClass() + "!!!"
+ node.toString() + "!!!" + node.getTextContent());
}
// Retrieve view id (android:id)
//Node idNode = attrMap.getNamedItem(ID_ATTR);
Node idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
int guiId = -1;
String id = null;
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> pair = parseAndroidId(txt, isSys);
id = pair.getO1();
Integer guiIdObj = pair.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
} else {
guiId = guiIdObj.intValue();
if (lookupNameInGeneralMap("id", guiId, isSys) == null) {
extraId2ViewMap.put(guiIdObj, view);
}
}
}
// Retrieve view type
String guiName = node.getNodeName();
if ("view".equals(guiName)) {
// view without class attribute.
// It does happen.
if (attrMap.getNamedItem("class") == null)
continue;
guiName = attrMap.getNamedItem("class").getTextContent();
} else if (guiName.equals("MenuItemView")) {
// FIXME(tony): this is an "approximation".
guiName = "android.view.MenuItem";
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
//Retrieve callback (android:onClick)
String callback = readAndroidCallback(attrMap, "onClick");
if (callback != null) {
view.setInlineClickHandler(callback);
}
// Retrieve text (android:text)
String text = readAndroidTextOrTitle(attrMap, "text");
// hailong: add hint support
// Retrieve hint (android:hint)
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
if(attrMap.getNamedItem("app:menu") != null){
String menuName = attrMap.getNamedItem("app:menu").getTextContent();
if (menuName != null) {
Pair<String, Integer> pair = parseAndroidId(menuName, isSys);
Integer menuId = pair.getO2();
if (menuId != null) {
view.addAttr(AndroidView.Type.APP_MENU, String.valueOf(menuId));
menuId2View.put(menuId, view);
}
}
if (attrMap.getNamedItem("app:headerLayout") != null) {
String headerName = attrMap.getNamedItem("app:headerLayout").getTextContent();
if (headerName != null) {
Pair<String, Integer> pair = parseAndroidId(headerName, isSys);
Integer headerId = pair.getO2();
if (headerId != null) {
view.addAttr(AndroidView.Type.APP_HEADER_LAYOUT, String.valueOf(headerId));
menuHeaderId2View.put(headerId, view);
}
}
}
}
if ("fragment".equals(guiName)) {
Node fragmentNodeAttr = attrMap.getNamedItem("android:name");
if (fragmentNodeAttr != null) {
String fragmentClass = fragmentNodeAttr.getTextContent();
if (fragmentClass.isEmpty()) {
fragmentNodeAttr = attrMap.getNamedItem("class");
if (fragmentNodeAttr != null) {
fragmentClass = fragmentNodeAttr.getTextContent();
}
}
view.addAttr(AndroidView.Type.ANDROID_NAME, fragmentClass);
}
}
String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
}
if (nodeName.equals("requestFocus")) {
continue;
}
if (!newNode.hasAttributes() && !"TableRow".equals(nodeName)
&& !"View".equals(nodeName)) {
Logger.warn(this.getClass().getSimpleName(),
"no attribute node "
+ newNode.getNodeName());
continue;
}
if (newNode.getNodeName().equals("include")) {
attrMap = newNode.getAttributes();
if (attrMap.getNamedItem("layout") == null) {
Logger.warn("XML", "layout not exist in include");
for (int j = 0; j < attrMap.getLength(); j++) {
Logger.trace("XML", attrMap.item(j).getNodeName());
}
Logger.trace("XML", "filename" + file);
continue;
}
String layoutTxt = attrMap.getNamedItem("layout").getTextContent();
String layoutId = null;
if (layoutTxt.startsWith("@layout/")) {
layoutId = layoutTxt.substring("@layout/".length());
} else if (layoutTxt.startsWith("@android:layout/")) {
layoutId = layoutTxt.substring("@android:layout/".length());
} else if (layoutTxt.matches("@\\*android:layout\\/(\\w)+")) {
layoutId = layoutTxt.substring("@*android:layout/".length());
} else {
throw new RuntimeException("[WARNING] Unhandled layout id "
+ layoutTxt + "," + file);
}
Integer includeeId = null;
id = null;
idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> pair = parseAndroidId(txt, isSys);
id = pair.getO1();
Integer guiIdObj = pair.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id
+ " in " + file);
}
} else {
includeeId = guiIdObj;
}
}
// view.saveInclude(layoutId, includeeId);
IncludeAndroidView iav = new IncludeAndroidView(layoutId, includeeId);
iav.setParent(view);
} else {
AndroidView newView = new AndroidView();
newView.setParent(view);
work.add(new Pair<Node, AndroidView>(newNode, newView));
}
}
}
} | NONSATD | true | view.setInlineClickHandler(callback);
}
// Retrieve text (android:text)
String text = readAndroidTextOrTitle(attrMap, "text");
// hailong: add hint support | guiName = "android.view.MenuItem";
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
//Retrieve callback (android:onClick)
String callback = readAndroidCallback(attrMap, "onClick");
if (callback != null) {
view.setInlineClickHandler(callback);
}
// Retrieve text (android:text)
String text = readAndroidTextOrTitle(attrMap, "text");
// hailong: add hint support
// Retrieve hint (android:hint)
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
if(attrMap.getNamedItem("app:menu") != null){
String menuName = attrMap.getNamedItem("app:menu").getTextContent();
if (menuName != null) { | // Retrieve view type
String guiName = node.getNodeName();
if ("view".equals(guiName)) {
// view without class attribute.
// It does happen.
if (attrMap.getNamedItem("class") == null)
continue;
guiName = attrMap.getNamedItem("class").getTextContent();
} else if (guiName.equals("MenuItemView")) {
// FIXME(tony): this is an "approximation".
guiName = "android.view.MenuItem";
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
//Retrieve callback (android:onClick)
String callback = readAndroidCallback(attrMap, "onClick");
if (callback != null) {
view.setInlineClickHandler(callback);
}
// Retrieve text (android:text)
String text = readAndroidTextOrTitle(attrMap, "text");
// hailong: add hint support
// Retrieve hint (android:hint)
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
if(attrMap.getNamedItem("app:menu") != null){
String menuName = attrMap.getNamedItem("app:menu").getTextContent();
if (menuName != null) {
Pair<String, Integer> pair = parseAndroidId(menuName, isSys);
Integer menuId = pair.getO2();
if (menuId != null) {
view.addAttr(AndroidView.Type.APP_MENU, String.valueOf(menuId));
menuId2View.put(menuId, view);
}
}
if (attrMap.getNamedItem("app:headerLayout") != null) {
String headerName = attrMap.getNamedItem("app:headerLayout").getTextContent();
if (headerName != null) { |
17,635 | 7 | // hailong: add hint support
// Retrieve hint (android:hint) | private void readLayout(String file, AndroidView root, boolean isSys) {
Document doc;
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(file);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
Element rootElement = doc.getDocumentElement();
// In older versions, Preference could be put in layout folder and we do
// not support Prefernce yet.
if (rootElement.getTagName().equals("PreferenceScreen")) {
return;
}
LinkedList<Pair<Node, AndroidView>> work = Lists.newLinkedList();
work.add(new Pair<Node, AndroidView>(rootElement, root));
while (!work.isEmpty()) {
Pair<Node, AndroidView> p = work.removeFirst();
Node node = p.getO1();
AndroidView view = p.getO2();
view.setOrigin(file);
NamedNodeMap attrMap = node.getAttributes();
if (attrMap == null) {
Logger.verb(this.getClass().getSimpleName(), file + "!!!" + node.getClass() + "!!!"
+ node.toString() + "!!!" + node.getTextContent());
}
// Retrieve view id (android:id)
//Node idNode = attrMap.getNamedItem(ID_ATTR);
Node idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
int guiId = -1;
String id = null;
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> pair = parseAndroidId(txt, isSys);
id = pair.getO1();
Integer guiIdObj = pair.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
} else {
guiId = guiIdObj.intValue();
if (lookupNameInGeneralMap("id", guiId, isSys) == null) {
extraId2ViewMap.put(guiIdObj, view);
}
}
}
// Retrieve view type
String guiName = node.getNodeName();
if ("view".equals(guiName)) {
// view without class attribute.
// It does happen.
if (attrMap.getNamedItem("class") == null)
continue;
guiName = attrMap.getNamedItem("class").getTextContent();
} else if (guiName.equals("MenuItemView")) {
// FIXME(tony): this is an "approximation".
guiName = "android.view.MenuItem";
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
//Retrieve callback (android:onClick)
String callback = readAndroidCallback(attrMap, "onClick");
if (callback != null) {
view.setInlineClickHandler(callback);
}
// Retrieve text (android:text)
String text = readAndroidTextOrTitle(attrMap, "text");
// hailong: add hint support
// Retrieve hint (android:hint)
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
if(attrMap.getNamedItem("app:menu") != null){
String menuName = attrMap.getNamedItem("app:menu").getTextContent();
if (menuName != null) {
Pair<String, Integer> pair = parseAndroidId(menuName, isSys);
Integer menuId = pair.getO2();
if (menuId != null) {
view.addAttr(AndroidView.Type.APP_MENU, String.valueOf(menuId));
menuId2View.put(menuId, view);
}
}
if (attrMap.getNamedItem("app:headerLayout") != null) {
String headerName = attrMap.getNamedItem("app:headerLayout").getTextContent();
if (headerName != null) {
Pair<String, Integer> pair = parseAndroidId(headerName, isSys);
Integer headerId = pair.getO2();
if (headerId != null) {
view.addAttr(AndroidView.Type.APP_HEADER_LAYOUT, String.valueOf(headerId));
menuHeaderId2View.put(headerId, view);
}
}
}
}
if ("fragment".equals(guiName)) {
Node fragmentNodeAttr = attrMap.getNamedItem("android:name");
if (fragmentNodeAttr != null) {
String fragmentClass = fragmentNodeAttr.getTextContent();
if (fragmentClass.isEmpty()) {
fragmentNodeAttr = attrMap.getNamedItem("class");
if (fragmentNodeAttr != null) {
fragmentClass = fragmentNodeAttr.getTextContent();
}
}
view.addAttr(AndroidView.Type.ANDROID_NAME, fragmentClass);
}
}
String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
}
if (nodeName.equals("requestFocus")) {
continue;
}
if (!newNode.hasAttributes() && !"TableRow".equals(nodeName)
&& !"View".equals(nodeName)) {
Logger.warn(this.getClass().getSimpleName(),
"no attribute node "
+ newNode.getNodeName());
continue;
}
if (newNode.getNodeName().equals("include")) {
attrMap = newNode.getAttributes();
if (attrMap.getNamedItem("layout") == null) {
Logger.warn("XML", "layout not exist in include");
for (int j = 0; j < attrMap.getLength(); j++) {
Logger.trace("XML", attrMap.item(j).getNodeName());
}
Logger.trace("XML", "filename" + file);
continue;
}
String layoutTxt = attrMap.getNamedItem("layout").getTextContent();
String layoutId = null;
if (layoutTxt.startsWith("@layout/")) {
layoutId = layoutTxt.substring("@layout/".length());
} else if (layoutTxt.startsWith("@android:layout/")) {
layoutId = layoutTxt.substring("@android:layout/".length());
} else if (layoutTxt.matches("@\\*android:layout\\/(\\w)+")) {
layoutId = layoutTxt.substring("@*android:layout/".length());
} else {
throw new RuntimeException("[WARNING] Unhandled layout id "
+ layoutTxt + "," + file);
}
Integer includeeId = null;
id = null;
idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> pair = parseAndroidId(txt, isSys);
id = pair.getO1();
Integer guiIdObj = pair.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id
+ " in " + file);
}
} else {
includeeId = guiIdObj;
}
}
// view.saveInclude(layoutId, includeeId);
IncludeAndroidView iav = new IncludeAndroidView(layoutId, includeeId);
iav.setParent(view);
} else {
AndroidView newView = new AndroidView();
newView.setParent(view);
work.add(new Pair<Node, AndroidView>(newNode, newView));
}
}
}
} | NONSATD | true | // Retrieve text (android:text)
String text = readAndroidTextOrTitle(attrMap, "text");
// hailong: add hint support
// Retrieve hint (android:hint)
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints"); | if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
//Retrieve callback (android:onClick)
String callback = readAndroidCallback(attrMap, "onClick");
if (callback != null) {
view.setInlineClickHandler(callback);
}
// Retrieve text (android:text)
String text = readAndroidTextOrTitle(attrMap, "text");
// hailong: add hint support
// Retrieve hint (android:hint)
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
if(attrMap.getNamedItem("app:menu") != null){
String menuName = attrMap.getNamedItem("app:menu").getTextContent();
if (menuName != null) {
Pair<String, Integer> pair = parseAndroidId(menuName, isSys);
Integer menuId = pair.getO2();
if (menuId != null) { | if ("view".equals(guiName)) {
// view without class attribute.
// It does happen.
if (attrMap.getNamedItem("class") == null)
continue;
guiName = attrMap.getNamedItem("class").getTextContent();
} else if (guiName.equals("MenuItemView")) {
// FIXME(tony): this is an "approximation".
guiName = "android.view.MenuItem";
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
//Retrieve callback (android:onClick)
String callback = readAndroidCallback(attrMap, "onClick");
if (callback != null) {
view.setInlineClickHandler(callback);
}
// Retrieve text (android:text)
String text = readAndroidTextOrTitle(attrMap, "text");
// hailong: add hint support
// Retrieve hint (android:hint)
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
if(attrMap.getNamedItem("app:menu") != null){
String menuName = attrMap.getNamedItem("app:menu").getTextContent();
if (menuName != null) {
Pair<String, Integer> pair = parseAndroidId(menuName, isSys);
Integer menuId = pair.getO2();
if (menuId != null) {
view.addAttr(AndroidView.Type.APP_MENU, String.valueOf(menuId));
menuId2View.put(menuId, view);
}
}
if (attrMap.getNamedItem("app:headerLayout") != null) {
String headerName = attrMap.getNamedItem("app:headerLayout").getTextContent();
if (headerName != null) {
Pair<String, Integer> pair = parseAndroidId(headerName, isSys);
Integer headerId = pair.getO2();
if (headerId != null) { |
17,635 | 8 | //view.save(guiId, text, hint, guiName); | private void readLayout(String file, AndroidView root, boolean isSys) {
Document doc;
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(file);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
Element rootElement = doc.getDocumentElement();
// In older versions, Preference could be put in layout folder and we do
// not support Prefernce yet.
if (rootElement.getTagName().equals("PreferenceScreen")) {
return;
}
LinkedList<Pair<Node, AndroidView>> work = Lists.newLinkedList();
work.add(new Pair<Node, AndroidView>(rootElement, root));
while (!work.isEmpty()) {
Pair<Node, AndroidView> p = work.removeFirst();
Node node = p.getO1();
AndroidView view = p.getO2();
view.setOrigin(file);
NamedNodeMap attrMap = node.getAttributes();
if (attrMap == null) {
Logger.verb(this.getClass().getSimpleName(), file + "!!!" + node.getClass() + "!!!"
+ node.toString() + "!!!" + node.getTextContent());
}
// Retrieve view id (android:id)
//Node idNode = attrMap.getNamedItem(ID_ATTR);
Node idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
int guiId = -1;
String id = null;
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> pair = parseAndroidId(txt, isSys);
id = pair.getO1();
Integer guiIdObj = pair.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
} else {
guiId = guiIdObj.intValue();
if (lookupNameInGeneralMap("id", guiId, isSys) == null) {
extraId2ViewMap.put(guiIdObj, view);
}
}
}
// Retrieve view type
String guiName = node.getNodeName();
if ("view".equals(guiName)) {
// view without class attribute.
// It does happen.
if (attrMap.getNamedItem("class") == null)
continue;
guiName = attrMap.getNamedItem("class").getTextContent();
} else if (guiName.equals("MenuItemView")) {
// FIXME(tony): this is an "approximation".
guiName = "android.view.MenuItem";
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
//Retrieve callback (android:onClick)
String callback = readAndroidCallback(attrMap, "onClick");
if (callback != null) {
view.setInlineClickHandler(callback);
}
// Retrieve text (android:text)
String text = readAndroidTextOrTitle(attrMap, "text");
// hailong: add hint support
// Retrieve hint (android:hint)
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
if(attrMap.getNamedItem("app:menu") != null){
String menuName = attrMap.getNamedItem("app:menu").getTextContent();
if (menuName != null) {
Pair<String, Integer> pair = parseAndroidId(menuName, isSys);
Integer menuId = pair.getO2();
if (menuId != null) {
view.addAttr(AndroidView.Type.APP_MENU, String.valueOf(menuId));
menuId2View.put(menuId, view);
}
}
if (attrMap.getNamedItem("app:headerLayout") != null) {
String headerName = attrMap.getNamedItem("app:headerLayout").getTextContent();
if (headerName != null) {
Pair<String, Integer> pair = parseAndroidId(headerName, isSys);
Integer headerId = pair.getO2();
if (headerId != null) {
view.addAttr(AndroidView.Type.APP_HEADER_LAYOUT, String.valueOf(headerId));
menuHeaderId2View.put(headerId, view);
}
}
}
}
if ("fragment".equals(guiName)) {
Node fragmentNodeAttr = attrMap.getNamedItem("android:name");
if (fragmentNodeAttr != null) {
String fragmentClass = fragmentNodeAttr.getTextContent();
if (fragmentClass.isEmpty()) {
fragmentNodeAttr = attrMap.getNamedItem("class");
if (fragmentNodeAttr != null) {
fragmentClass = fragmentNodeAttr.getTextContent();
}
}
view.addAttr(AndroidView.Type.ANDROID_NAME, fragmentClass);
}
}
String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
}
if (nodeName.equals("requestFocus")) {
continue;
}
if (!newNode.hasAttributes() && !"TableRow".equals(nodeName)
&& !"View".equals(nodeName)) {
Logger.warn(this.getClass().getSimpleName(),
"no attribute node "
+ newNode.getNodeName());
continue;
}
if (newNode.getNodeName().equals("include")) {
attrMap = newNode.getAttributes();
if (attrMap.getNamedItem("layout") == null) {
Logger.warn("XML", "layout not exist in include");
for (int j = 0; j < attrMap.getLength(); j++) {
Logger.trace("XML", attrMap.item(j).getNodeName());
}
Logger.trace("XML", "filename" + file);
continue;
}
String layoutTxt = attrMap.getNamedItem("layout").getTextContent();
String layoutId = null;
if (layoutTxt.startsWith("@layout/")) {
layoutId = layoutTxt.substring("@layout/".length());
} else if (layoutTxt.startsWith("@android:layout/")) {
layoutId = layoutTxt.substring("@android:layout/".length());
} else if (layoutTxt.matches("@\\*android:layout\\/(\\w)+")) {
layoutId = layoutTxt.substring("@*android:layout/".length());
} else {
throw new RuntimeException("[WARNING] Unhandled layout id "
+ layoutTxt + "," + file);
}
Integer includeeId = null;
id = null;
idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> pair = parseAndroidId(txt, isSys);
id = pair.getO1();
Integer guiIdObj = pair.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id
+ " in " + file);
}
} else {
includeeId = guiIdObj;
}
}
// view.saveInclude(layoutId, includeeId);
IncludeAndroidView iav = new IncludeAndroidView(layoutId, includeeId);
iav.setParent(view);
} else {
AndroidView newView = new AndroidView();
newView.setParent(view);
work.add(new Pair<Node, AndroidView>(newNode, newView));
}
}
}
} | NONSATD | true | String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) { | }
view.addAttr(AndroidView.Type.ANDROID_NAME, fragmentClass);
}
}
String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on | }
if ("fragment".equals(guiName)) {
Node fragmentNodeAttr = attrMap.getNamedItem("android:name");
if (fragmentNodeAttr != null) {
String fragmentClass = fragmentNodeAttr.getTextContent();
if (fragmentClass.isEmpty()) {
fragmentNodeAttr = attrMap.getNamedItem("class");
if (fragmentNodeAttr != null) {
fragmentClass = fragmentNodeAttr.getTextContent();
}
}
view.addAttr(AndroidView.Type.ANDROID_NAME, fragmentClass);
}
}
String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
}
if (nodeName.equals("requestFocus")) {
continue;
}
if (!newNode.hasAttributes() && !"TableRow".equals(nodeName)
&& !"View".equals(nodeName)) {
Logger.warn(this.getClass().getSimpleName(),
"no attribute node "
+ newNode.getNodeName()); |
17,635 | 9 | // possible for XML files created on a different operating system
// than the one our analysis is run on | private void readLayout(String file, AndroidView root, boolean isSys) {
Document doc;
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(file);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
Element rootElement = doc.getDocumentElement();
// In older versions, Preference could be put in layout folder and we do
// not support Prefernce yet.
if (rootElement.getTagName().equals("PreferenceScreen")) {
return;
}
LinkedList<Pair<Node, AndroidView>> work = Lists.newLinkedList();
work.add(new Pair<Node, AndroidView>(rootElement, root));
while (!work.isEmpty()) {
Pair<Node, AndroidView> p = work.removeFirst();
Node node = p.getO1();
AndroidView view = p.getO2();
view.setOrigin(file);
NamedNodeMap attrMap = node.getAttributes();
if (attrMap == null) {
Logger.verb(this.getClass().getSimpleName(), file + "!!!" + node.getClass() + "!!!"
+ node.toString() + "!!!" + node.getTextContent());
}
// Retrieve view id (android:id)
//Node idNode = attrMap.getNamedItem(ID_ATTR);
Node idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
int guiId = -1;
String id = null;
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> pair = parseAndroidId(txt, isSys);
id = pair.getO1();
Integer guiIdObj = pair.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
} else {
guiId = guiIdObj.intValue();
if (lookupNameInGeneralMap("id", guiId, isSys) == null) {
extraId2ViewMap.put(guiIdObj, view);
}
}
}
// Retrieve view type
String guiName = node.getNodeName();
if ("view".equals(guiName)) {
// view without class attribute.
// It does happen.
if (attrMap.getNamedItem("class") == null)
continue;
guiName = attrMap.getNamedItem("class").getTextContent();
} else if (guiName.equals("MenuItemView")) {
// FIXME(tony): this is an "approximation".
guiName = "android.view.MenuItem";
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
//Retrieve callback (android:onClick)
String callback = readAndroidCallback(attrMap, "onClick");
if (callback != null) {
view.setInlineClickHandler(callback);
}
// Retrieve text (android:text)
String text = readAndroidTextOrTitle(attrMap, "text");
// hailong: add hint support
// Retrieve hint (android:hint)
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
if(attrMap.getNamedItem("app:menu") != null){
String menuName = attrMap.getNamedItem("app:menu").getTextContent();
if (menuName != null) {
Pair<String, Integer> pair = parseAndroidId(menuName, isSys);
Integer menuId = pair.getO2();
if (menuId != null) {
view.addAttr(AndroidView.Type.APP_MENU, String.valueOf(menuId));
menuId2View.put(menuId, view);
}
}
if (attrMap.getNamedItem("app:headerLayout") != null) {
String headerName = attrMap.getNamedItem("app:headerLayout").getTextContent();
if (headerName != null) {
Pair<String, Integer> pair = parseAndroidId(headerName, isSys);
Integer headerId = pair.getO2();
if (headerId != null) {
view.addAttr(AndroidView.Type.APP_HEADER_LAYOUT, String.valueOf(headerId));
menuHeaderId2View.put(headerId, view);
}
}
}
}
if ("fragment".equals(guiName)) {
Node fragmentNodeAttr = attrMap.getNamedItem("android:name");
if (fragmentNodeAttr != null) {
String fragmentClass = fragmentNodeAttr.getTextContent();
if (fragmentClass.isEmpty()) {
fragmentNodeAttr = attrMap.getNamedItem("class");
if (fragmentNodeAttr != null) {
fragmentClass = fragmentNodeAttr.getTextContent();
}
}
view.addAttr(AndroidView.Type.ANDROID_NAME, fragmentClass);
}
}
String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
}
if (nodeName.equals("requestFocus")) {
continue;
}
if (!newNode.hasAttributes() && !"TableRow".equals(nodeName)
&& !"View".equals(nodeName)) {
Logger.warn(this.getClass().getSimpleName(),
"no attribute node "
+ newNode.getNodeName());
continue;
}
if (newNode.getNodeName().equals("include")) {
attrMap = newNode.getAttributes();
if (attrMap.getNamedItem("layout") == null) {
Logger.warn("XML", "layout not exist in include");
for (int j = 0; j < attrMap.getLength(); j++) {
Logger.trace("XML", attrMap.item(j).getNodeName());
}
Logger.trace("XML", "filename" + file);
continue;
}
String layoutTxt = attrMap.getNamedItem("layout").getTextContent();
String layoutId = null;
if (layoutTxt.startsWith("@layout/")) {
layoutId = layoutTxt.substring("@layout/".length());
} else if (layoutTxt.startsWith("@android:layout/")) {
layoutId = layoutTxt.substring("@android:layout/".length());
} else if (layoutTxt.matches("@\\*android:layout\\/(\\w)+")) {
layoutId = layoutTxt.substring("@*android:layout/".length());
} else {
throw new RuntimeException("[WARNING] Unhandled layout id "
+ layoutTxt + "," + file);
}
Integer includeeId = null;
id = null;
idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> pair = parseAndroidId(txt, isSys);
id = pair.getO1();
Integer guiIdObj = pair.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id
+ " in " + file);
}
} else {
includeeId = guiIdObj;
}
}
// view.saveInclude(layoutId, includeeId);
IncludeAndroidView iav = new IncludeAndroidView(layoutId, includeeId);
iav.setParent(view);
} else {
AndroidView newView = new AndroidView();
newView.setParent(view);
work.add(new Pair<Node, AndroidView>(newNode, newView));
}
}
}
} | NONSATD | true | }
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
} | view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
}
if (nodeName.equals("requestFocus")) {
continue;
}
if (!newNode.hasAttributes() && !"TableRow".equals(nodeName)
&& !"View".equals(nodeName)) {
Logger.warn(this.getClass().getSimpleName(),
"no attribute node "
+ newNode.getNodeName()); | }
}
view.addAttr(AndroidView.Type.ANDROID_NAME, fragmentClass);
}
}
String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
}
if (nodeName.equals("requestFocus")) {
continue;
}
if (!newNode.hasAttributes() && !"TableRow".equals(nodeName)
&& !"View".equals(nodeName)) {
Logger.warn(this.getClass().getSimpleName(),
"no attribute node "
+ newNode.getNodeName());
continue;
}
if (newNode.getNodeName().equals("include")) {
attrMap = newNode.getAttributes();
if (attrMap.getNamedItem("layout") == null) {
Logger.warn("XML", "layout not exist in include");
for (int j = 0; j < attrMap.getLength(); j++) {
Logger.trace("XML", attrMap.item(j).getNodeName());
}
Logger.trace("XML", "filename" + file); |
17,635 | 10 | // view.saveInclude(layoutId, includeeId); | private void readLayout(String file, AndroidView root, boolean isSys) {
Document doc;
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(file);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
Element rootElement = doc.getDocumentElement();
// In older versions, Preference could be put in layout folder and we do
// not support Prefernce yet.
if (rootElement.getTagName().equals("PreferenceScreen")) {
return;
}
LinkedList<Pair<Node, AndroidView>> work = Lists.newLinkedList();
work.add(new Pair<Node, AndroidView>(rootElement, root));
while (!work.isEmpty()) {
Pair<Node, AndroidView> p = work.removeFirst();
Node node = p.getO1();
AndroidView view = p.getO2();
view.setOrigin(file);
NamedNodeMap attrMap = node.getAttributes();
if (attrMap == null) {
Logger.verb(this.getClass().getSimpleName(), file + "!!!" + node.getClass() + "!!!"
+ node.toString() + "!!!" + node.getTextContent());
}
// Retrieve view id (android:id)
//Node idNode = attrMap.getNamedItem(ID_ATTR);
Node idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
int guiId = -1;
String id = null;
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> pair = parseAndroidId(txt, isSys);
id = pair.getO1();
Integer guiIdObj = pair.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
} else {
guiId = guiIdObj.intValue();
if (lookupNameInGeneralMap("id", guiId, isSys) == null) {
extraId2ViewMap.put(guiIdObj, view);
}
}
}
// Retrieve view type
String guiName = node.getNodeName();
if ("view".equals(guiName)) {
// view without class attribute.
// It does happen.
if (attrMap.getNamedItem("class") == null)
continue;
guiName = attrMap.getNamedItem("class").getTextContent();
} else if (guiName.equals("MenuItemView")) {
// FIXME(tony): this is an "approximation".
guiName = "android.view.MenuItem";
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
//Retrieve callback (android:onClick)
String callback = readAndroidCallback(attrMap, "onClick");
if (callback != null) {
view.setInlineClickHandler(callback);
}
// Retrieve text (android:text)
String text = readAndroidTextOrTitle(attrMap, "text");
// hailong: add hint support
// Retrieve hint (android:hint)
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
if(attrMap.getNamedItem("app:menu") != null){
String menuName = attrMap.getNamedItem("app:menu").getTextContent();
if (menuName != null) {
Pair<String, Integer> pair = parseAndroidId(menuName, isSys);
Integer menuId = pair.getO2();
if (menuId != null) {
view.addAttr(AndroidView.Type.APP_MENU, String.valueOf(menuId));
menuId2View.put(menuId, view);
}
}
if (attrMap.getNamedItem("app:headerLayout") != null) {
String headerName = attrMap.getNamedItem("app:headerLayout").getTextContent();
if (headerName != null) {
Pair<String, Integer> pair = parseAndroidId(headerName, isSys);
Integer headerId = pair.getO2();
if (headerId != null) {
view.addAttr(AndroidView.Type.APP_HEADER_LAYOUT, String.valueOf(headerId));
menuHeaderId2View.put(headerId, view);
}
}
}
}
if ("fragment".equals(guiName)) {
Node fragmentNodeAttr = attrMap.getNamedItem("android:name");
if (fragmentNodeAttr != null) {
String fragmentClass = fragmentNodeAttr.getTextContent();
if (fragmentClass.isEmpty()) {
fragmentNodeAttr = attrMap.getNamedItem("class");
if (fragmentNodeAttr != null) {
fragmentClass = fragmentNodeAttr.getTextContent();
}
}
view.addAttr(AndroidView.Type.ANDROID_NAME, fragmentClass);
}
}
String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
}
if (nodeName.equals("requestFocus")) {
continue;
}
if (!newNode.hasAttributes() && !"TableRow".equals(nodeName)
&& !"View".equals(nodeName)) {
Logger.warn(this.getClass().getSimpleName(),
"no attribute node "
+ newNode.getNodeName());
continue;
}
if (newNode.getNodeName().equals("include")) {
attrMap = newNode.getAttributes();
if (attrMap.getNamedItem("layout") == null) {
Logger.warn("XML", "layout not exist in include");
for (int j = 0; j < attrMap.getLength(); j++) {
Logger.trace("XML", attrMap.item(j).getNodeName());
}
Logger.trace("XML", "filename" + file);
continue;
}
String layoutTxt = attrMap.getNamedItem("layout").getTextContent();
String layoutId = null;
if (layoutTxt.startsWith("@layout/")) {
layoutId = layoutTxt.substring("@layout/".length());
} else if (layoutTxt.startsWith("@android:layout/")) {
layoutId = layoutTxt.substring("@android:layout/".length());
} else if (layoutTxt.matches("@\\*android:layout\\/(\\w)+")) {
layoutId = layoutTxt.substring("@*android:layout/".length());
} else {
throw new RuntimeException("[WARNING] Unhandled layout id "
+ layoutTxt + "," + file);
}
Integer includeeId = null;
id = null;
idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> pair = parseAndroidId(txt, isSys);
id = pair.getO1();
Integer guiIdObj = pair.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id
+ " in " + file);
}
} else {
includeeId = guiIdObj;
}
}
// view.saveInclude(layoutId, includeeId);
IncludeAndroidView iav = new IncludeAndroidView(layoutId, includeeId);
iav.setParent(view);
} else {
AndroidView newView = new AndroidView();
newView.setParent(view);
work.add(new Pair<Node, AndroidView>(newNode, newView));
}
}
}
} | NONSATD | true | }
}
// view.saveInclude(layoutId, includeeId);
IncludeAndroidView iav = new IncludeAndroidView(layoutId, includeeId);
iav.setParent(view); | if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id
+ " in " + file);
}
} else {
includeeId = guiIdObj;
}
}
// view.saveInclude(layoutId, includeeId);
IncludeAndroidView iav = new IncludeAndroidView(layoutId, includeeId);
iav.setParent(view);
} else {
AndroidView newView = new AndroidView();
newView.setParent(view);
work.add(new Pair<Node, AndroidView>(newNode, newView));
}
}
}
} | + layoutTxt + "," + file);
}
Integer includeeId = null;
id = null;
idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> pair = parseAndroidId(txt, isSys);
id = pair.getO1();
Integer guiIdObj = pair.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id
+ " in " + file);
}
} else {
includeeId = guiIdObj;
}
}
// view.saveInclude(layoutId, includeeId);
IncludeAndroidView iav = new IncludeAndroidView(layoutId, includeeId);
iav.setParent(view);
} else {
AndroidView newView = new AndroidView();
newView.setParent(view);
work.add(new Pair<Node, AndroidView>(newNode, newView));
}
}
}
} |
9,444 | 0 | /**
* 处理 监控文件夹 的事件.
*/ | public void dealWithEvent(WatchEvent<?> event) {
// could expand more processes here
LOG.info("{}:\t {} event.", event.context(), event.kind());
} | NONSATD | true | public void dealWithEvent(WatchEvent<?> event) {
// could expand more processes here
LOG.info("{}:\t {} event.", event.context(), event.kind());
} | public void dealWithEvent(WatchEvent<?> event) {
// could expand more processes here
LOG.info("{}:\t {} event.", event.context(), event.kind());
} | public void dealWithEvent(WatchEvent<?> event) {
// could expand more processes here
LOG.info("{}:\t {} event.", event.context(), event.kind());
} |
9,444 | 1 | // could expand more processes here | public void dealWithEvent(WatchEvent<?> event) {
// could expand more processes here
LOG.info("{}:\t {} event.", event.context(), event.kind());
} | IMPLEMENTATION | true | public void dealWithEvent(WatchEvent<?> event) {
// could expand more processes here
LOG.info("{}:\t {} event.", event.context(), event.kind());
} | public void dealWithEvent(WatchEvent<?> event) {
// could expand more processes here
LOG.info("{}:\t {} event.", event.context(), event.kind());
} | public void dealWithEvent(WatchEvent<?> event) {
// could expand more processes here
LOG.info("{}:\t {} event.", event.context(), event.kind());
} |
17,637 | 0 | // negative value to indicate it is a unique id but | private void readMenu(String file, AndroidView root, boolean isSys) {
Document doc;
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(file);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
LinkedList<Pair<Node, AndroidView>> worklist = Lists.newLinkedList();
worklist.add(new Pair<Node, AndroidView>(doc.getDocumentElement(), root));
root = null;
while (!worklist.isEmpty()) {
Pair<Node, AndroidView> pair = worklist.remove();
Node node = pair.getO1();
AndroidView view = pair.getO2();
NamedNodeMap attrMap = node.getAttributes();
Node idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
int guiId = -1;
String id = null;
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> p = parseAndroidId(txt, isSys);
id = p.getO1();
Integer guiIdObj = p.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
guiId = nonRId--; // negative value to indicate it is a unique id but
// we don't know its value
feedIdIntoGeneralMap("id", id, guiId, isSys);
// if (isSys) {
// sysRIdMap.put(id, guiId);
// invSysRIdMap.put(guiId, id);
// } else {
// rIdMap.put(id, guiId);
// invRIdMap.put(guiId, id);
// }
} else {
guiId = guiIdObj.intValue();
}
}
// FIXME(tony): this is an "approximation"
String guiName = node.getNodeName();
if (guiName.equals("menu")) {
guiName = "android.view.Menu";
} else if (guiName.equals("item")) {
guiName = "android.view.MenuItem";
NodeList childNodes = node.getChildNodes();
if(childNodes!=null) {
for (int i = 0; i < childNodes.getLength(); i++) {
Node newNode = childNodes.item(i);
String nodeName = newNode.getNodeName();
if("menu".equals(nodeName)) {
guiName = "android.view.ViewGroup";
}
}
}
} else if (guiName.equals("group")) {
// TODO(tony): we might want to create a special fake class to
// represent menu groups. But for now, let's simply pretend it's
// a ViewGroup. Also, print a warning when we do see <group>
Logger.trace(this.getClass().getSimpleName(), "[TODO] <group> used in " + file);
guiName = "android.view.ViewGroup";
} else {
Logger.trace("XML", "Unhandled menu tag " + guiName);
//throw new RuntimeException("Unhandled menu tag " + guiName);
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
String text = readAndroidTextOrTitle(attrMap, "title");
// hailong: add hint support
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
}
AndroidView newView = new AndroidView();
// FIXME: we assume that every node has attributes, may be wrong
if (!newNode.hasAttributes()) {
Logger.verb("WARNING", "xml node " + newNode + " has no attributes");
// continue;
} else {
NamedNodeMap attrs = newNode.getAttributes();
for (int idx = 0; idx < attrs.getLength(); idx += 1) {
Node attr = attrs.item(idx);
String name = attr.getNodeName();
String value = attr.getNodeValue();
newView.addAttr(name, value);
}
}
newView.setParent(view);
worklist.add(new Pair<Node, AndroidView>(newNode, newView));
}
}
} | NONSATD | true | + file);
}
guiId = nonRId--; // negative value to indicate it is a unique id but
// we don't know its value
feedIdIntoGeneralMap("id", id, guiId, isSys); | String txt = idNode.getTextContent();
Pair<String, Integer> p = parseAndroidId(txt, isSys);
id = p.getO1();
Integer guiIdObj = p.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
guiId = nonRId--; // negative value to indicate it is a unique id but
// we don't know its value
feedIdIntoGeneralMap("id", id, guiId, isSys);
// if (isSys) {
// sysRIdMap.put(id, guiId);
// invSysRIdMap.put(guiId, id);
// } else {
// rIdMap.put(id, guiId);
// invRIdMap.put(guiId, id);
// }
} else { | root = null;
while (!worklist.isEmpty()) {
Pair<Node, AndroidView> pair = worklist.remove();
Node node = pair.getO1();
AndroidView view = pair.getO2();
NamedNodeMap attrMap = node.getAttributes();
Node idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
int guiId = -1;
String id = null;
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> p = parseAndroidId(txt, isSys);
id = p.getO1();
Integer guiIdObj = p.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
guiId = nonRId--; // negative value to indicate it is a unique id but
// we don't know its value
feedIdIntoGeneralMap("id", id, guiId, isSys);
// if (isSys) {
// sysRIdMap.put(id, guiId);
// invSysRIdMap.put(guiId, id);
// } else {
// rIdMap.put(id, guiId);
// invRIdMap.put(guiId, id);
// }
} else {
guiId = guiIdObj.intValue();
}
}
// FIXME(tony): this is an "approximation"
String guiName = node.getNodeName();
if (guiName.equals("menu")) {
guiName = "android.view.Menu";
} else if (guiName.equals("item")) {
guiName = "android.view.MenuItem";
NodeList childNodes = node.getChildNodes(); |
17,637 | 1 | // we don't know its value | private void readMenu(String file, AndroidView root, boolean isSys) {
Document doc;
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(file);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
LinkedList<Pair<Node, AndroidView>> worklist = Lists.newLinkedList();
worklist.add(new Pair<Node, AndroidView>(doc.getDocumentElement(), root));
root = null;
while (!worklist.isEmpty()) {
Pair<Node, AndroidView> pair = worklist.remove();
Node node = pair.getO1();
AndroidView view = pair.getO2();
NamedNodeMap attrMap = node.getAttributes();
Node idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
int guiId = -1;
String id = null;
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> p = parseAndroidId(txt, isSys);
id = p.getO1();
Integer guiIdObj = p.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
guiId = nonRId--; // negative value to indicate it is a unique id but
// we don't know its value
feedIdIntoGeneralMap("id", id, guiId, isSys);
// if (isSys) {
// sysRIdMap.put(id, guiId);
// invSysRIdMap.put(guiId, id);
// } else {
// rIdMap.put(id, guiId);
// invRIdMap.put(guiId, id);
// }
} else {
guiId = guiIdObj.intValue();
}
}
// FIXME(tony): this is an "approximation"
String guiName = node.getNodeName();
if (guiName.equals("menu")) {
guiName = "android.view.Menu";
} else if (guiName.equals("item")) {
guiName = "android.view.MenuItem";
NodeList childNodes = node.getChildNodes();
if(childNodes!=null) {
for (int i = 0; i < childNodes.getLength(); i++) {
Node newNode = childNodes.item(i);
String nodeName = newNode.getNodeName();
if("menu".equals(nodeName)) {
guiName = "android.view.ViewGroup";
}
}
}
} else if (guiName.equals("group")) {
// TODO(tony): we might want to create a special fake class to
// represent menu groups. But for now, let's simply pretend it's
// a ViewGroup. Also, print a warning when we do see <group>
Logger.trace(this.getClass().getSimpleName(), "[TODO] <group> used in " + file);
guiName = "android.view.ViewGroup";
} else {
Logger.trace("XML", "Unhandled menu tag " + guiName);
//throw new RuntimeException("Unhandled menu tag " + guiName);
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
String text = readAndroidTextOrTitle(attrMap, "title");
// hailong: add hint support
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
}
AndroidView newView = new AndroidView();
// FIXME: we assume that every node has attributes, may be wrong
if (!newNode.hasAttributes()) {
Logger.verb("WARNING", "xml node " + newNode + " has no attributes");
// continue;
} else {
NamedNodeMap attrs = newNode.getAttributes();
for (int idx = 0; idx < attrs.getLength(); idx += 1) {
Node attr = attrs.item(idx);
String name = attr.getNodeName();
String value = attr.getNodeValue();
newView.addAttr(name, value);
}
}
newView.setParent(view);
worklist.add(new Pair<Node, AndroidView>(newNode, newView));
}
}
} | NONSATD | true | }
guiId = nonRId--; // negative value to indicate it is a unique id but
// we don't know its value
feedIdIntoGeneralMap("id", id, guiId, isSys);
// if (isSys) { | Pair<String, Integer> p = parseAndroidId(txt, isSys);
id = p.getO1();
Integer guiIdObj = p.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
guiId = nonRId--; // negative value to indicate it is a unique id but
// we don't know its value
feedIdIntoGeneralMap("id", id, guiId, isSys);
// if (isSys) {
// sysRIdMap.put(id, guiId);
// invSysRIdMap.put(guiId, id);
// } else {
// rIdMap.put(id, guiId);
// invRIdMap.put(guiId, id);
// }
} else {
guiId = guiIdObj.intValue(); | while (!worklist.isEmpty()) {
Pair<Node, AndroidView> pair = worklist.remove();
Node node = pair.getO1();
AndroidView view = pair.getO2();
NamedNodeMap attrMap = node.getAttributes();
Node idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
int guiId = -1;
String id = null;
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> p = parseAndroidId(txt, isSys);
id = p.getO1();
Integer guiIdObj = p.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
guiId = nonRId--; // negative value to indicate it is a unique id but
// we don't know its value
feedIdIntoGeneralMap("id", id, guiId, isSys);
// if (isSys) {
// sysRIdMap.put(id, guiId);
// invSysRIdMap.put(guiId, id);
// } else {
// rIdMap.put(id, guiId);
// invRIdMap.put(guiId, id);
// }
} else {
guiId = guiIdObj.intValue();
}
}
// FIXME(tony): this is an "approximation"
String guiName = node.getNodeName();
if (guiName.equals("menu")) {
guiName = "android.view.Menu";
} else if (guiName.equals("item")) {
guiName = "android.view.MenuItem";
NodeList childNodes = node.getChildNodes();
if(childNodes!=null) { |
17,637 | 2 | // if (isSys) {
// sysRIdMap.put(id, guiId);
// invSysRIdMap.put(guiId, id);
// } else {
// rIdMap.put(id, guiId);
// invRIdMap.put(guiId, id);
// } | private void readMenu(String file, AndroidView root, boolean isSys) {
Document doc;
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(file);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
LinkedList<Pair<Node, AndroidView>> worklist = Lists.newLinkedList();
worklist.add(new Pair<Node, AndroidView>(doc.getDocumentElement(), root));
root = null;
while (!worklist.isEmpty()) {
Pair<Node, AndroidView> pair = worklist.remove();
Node node = pair.getO1();
AndroidView view = pair.getO2();
NamedNodeMap attrMap = node.getAttributes();
Node idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
int guiId = -1;
String id = null;
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> p = parseAndroidId(txt, isSys);
id = p.getO1();
Integer guiIdObj = p.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
guiId = nonRId--; // negative value to indicate it is a unique id but
// we don't know its value
feedIdIntoGeneralMap("id", id, guiId, isSys);
// if (isSys) {
// sysRIdMap.put(id, guiId);
// invSysRIdMap.put(guiId, id);
// } else {
// rIdMap.put(id, guiId);
// invRIdMap.put(guiId, id);
// }
} else {
guiId = guiIdObj.intValue();
}
}
// FIXME(tony): this is an "approximation"
String guiName = node.getNodeName();
if (guiName.equals("menu")) {
guiName = "android.view.Menu";
} else if (guiName.equals("item")) {
guiName = "android.view.MenuItem";
NodeList childNodes = node.getChildNodes();
if(childNodes!=null) {
for (int i = 0; i < childNodes.getLength(); i++) {
Node newNode = childNodes.item(i);
String nodeName = newNode.getNodeName();
if("menu".equals(nodeName)) {
guiName = "android.view.ViewGroup";
}
}
}
} else if (guiName.equals("group")) {
// TODO(tony): we might want to create a special fake class to
// represent menu groups. But for now, let's simply pretend it's
// a ViewGroup. Also, print a warning when we do see <group>
Logger.trace(this.getClass().getSimpleName(), "[TODO] <group> used in " + file);
guiName = "android.view.ViewGroup";
} else {
Logger.trace("XML", "Unhandled menu tag " + guiName);
//throw new RuntimeException("Unhandled menu tag " + guiName);
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
String text = readAndroidTextOrTitle(attrMap, "title");
// hailong: add hint support
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
}
AndroidView newView = new AndroidView();
// FIXME: we assume that every node has attributes, may be wrong
if (!newNode.hasAttributes()) {
Logger.verb("WARNING", "xml node " + newNode + " has no attributes");
// continue;
} else {
NamedNodeMap attrs = newNode.getAttributes();
for (int idx = 0; idx < attrs.getLength(); idx += 1) {
Node attr = attrs.item(idx);
String name = attr.getNodeName();
String value = attr.getNodeValue();
newView.addAttr(name, value);
}
}
newView.setParent(view);
worklist.add(new Pair<Node, AndroidView>(newNode, newView));
}
}
} | NONSATD | true | // we don't know its value
feedIdIntoGeneralMap("id", id, guiId, isSys);
// if (isSys) {
// sysRIdMap.put(id, guiId);
// invSysRIdMap.put(guiId, id);
// } else {
// rIdMap.put(id, guiId);
// invRIdMap.put(guiId, id);
// }
} else {
guiId = guiIdObj.intValue(); | Integer guiIdObj = p.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
guiId = nonRId--; // negative value to indicate it is a unique id but
// we don't know its value
feedIdIntoGeneralMap("id", id, guiId, isSys);
// if (isSys) {
// sysRIdMap.put(id, guiId);
// invSysRIdMap.put(guiId, id);
// } else {
// rIdMap.put(id, guiId);
// invRIdMap.put(guiId, id);
// }
} else {
guiId = guiIdObj.intValue();
}
}
// FIXME(tony): this is an "approximation"
String guiName = node.getNodeName();
if (guiName.equals("menu")) {
guiName = "android.view.Menu";
} else if (guiName.equals("item")) {
guiName = "android.view.MenuItem"; | Node node = pair.getO1();
AndroidView view = pair.getO2();
NamedNodeMap attrMap = node.getAttributes();
Node idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
int guiId = -1;
String id = null;
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> p = parseAndroidId(txt, isSys);
id = p.getO1();
Integer guiIdObj = p.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
guiId = nonRId--; // negative value to indicate it is a unique id but
// we don't know its value
feedIdIntoGeneralMap("id", id, guiId, isSys);
// if (isSys) {
// sysRIdMap.put(id, guiId);
// invSysRIdMap.put(guiId, id);
// } else {
// rIdMap.put(id, guiId);
// invRIdMap.put(guiId, id);
// }
} else {
guiId = guiIdObj.intValue();
}
}
// FIXME(tony): this is an "approximation"
String guiName = node.getNodeName();
if (guiName.equals("menu")) {
guiName = "android.view.Menu";
} else if (guiName.equals("item")) {
guiName = "android.view.MenuItem";
NodeList childNodes = node.getChildNodes();
if(childNodes!=null) {
for (int i = 0; i < childNodes.getLength(); i++) {
Node newNode = childNodes.item(i);
String nodeName = newNode.getNodeName();
if("menu".equals(nodeName)) {
guiName = "android.view.ViewGroup";
}
}
} |
17,637 | 3 | // FIXME(tony): this is an "approximation" | private void readMenu(String file, AndroidView root, boolean isSys) {
Document doc;
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(file);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
LinkedList<Pair<Node, AndroidView>> worklist = Lists.newLinkedList();
worklist.add(new Pair<Node, AndroidView>(doc.getDocumentElement(), root));
root = null;
while (!worklist.isEmpty()) {
Pair<Node, AndroidView> pair = worklist.remove();
Node node = pair.getO1();
AndroidView view = pair.getO2();
NamedNodeMap attrMap = node.getAttributes();
Node idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
int guiId = -1;
String id = null;
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> p = parseAndroidId(txt, isSys);
id = p.getO1();
Integer guiIdObj = p.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
guiId = nonRId--; // negative value to indicate it is a unique id but
// we don't know its value
feedIdIntoGeneralMap("id", id, guiId, isSys);
// if (isSys) {
// sysRIdMap.put(id, guiId);
// invSysRIdMap.put(guiId, id);
// } else {
// rIdMap.put(id, guiId);
// invRIdMap.put(guiId, id);
// }
} else {
guiId = guiIdObj.intValue();
}
}
// FIXME(tony): this is an "approximation"
String guiName = node.getNodeName();
if (guiName.equals("menu")) {
guiName = "android.view.Menu";
} else if (guiName.equals("item")) {
guiName = "android.view.MenuItem";
NodeList childNodes = node.getChildNodes();
if(childNodes!=null) {
for (int i = 0; i < childNodes.getLength(); i++) {
Node newNode = childNodes.item(i);
String nodeName = newNode.getNodeName();
if("menu".equals(nodeName)) {
guiName = "android.view.ViewGroup";
}
}
}
} else if (guiName.equals("group")) {
// TODO(tony): we might want to create a special fake class to
// represent menu groups. But for now, let's simply pretend it's
// a ViewGroup. Also, print a warning when we do see <group>
Logger.trace(this.getClass().getSimpleName(), "[TODO] <group> used in " + file);
guiName = "android.view.ViewGroup";
} else {
Logger.trace("XML", "Unhandled menu tag " + guiName);
//throw new RuntimeException("Unhandled menu tag " + guiName);
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
String text = readAndroidTextOrTitle(attrMap, "title");
// hailong: add hint support
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
}
AndroidView newView = new AndroidView();
// FIXME: we assume that every node has attributes, may be wrong
if (!newNode.hasAttributes()) {
Logger.verb("WARNING", "xml node " + newNode + " has no attributes");
// continue;
} else {
NamedNodeMap attrs = newNode.getAttributes();
for (int idx = 0; idx < attrs.getLength(); idx += 1) {
Node attr = attrs.item(idx);
String name = attr.getNodeName();
String value = attr.getNodeValue();
newView.addAttr(name, value);
}
}
newView.setParent(view);
worklist.add(new Pair<Node, AndroidView>(newNode, newView));
}
}
} | DEFECT | true | }
}
// FIXME(tony): this is an "approximation"
String guiName = node.getNodeName();
if (guiName.equals("menu")) { | // sysRIdMap.put(id, guiId);
// invSysRIdMap.put(guiId, id);
// } else {
// rIdMap.put(id, guiId);
// invRIdMap.put(guiId, id);
// }
} else {
guiId = guiIdObj.intValue();
}
}
// FIXME(tony): this is an "approximation"
String guiName = node.getNodeName();
if (guiName.equals("menu")) {
guiName = "android.view.Menu";
} else if (guiName.equals("item")) {
guiName = "android.view.MenuItem";
NodeList childNodes = node.getChildNodes();
if(childNodes!=null) {
for (int i = 0; i < childNodes.getLength(); i++) {
Node newNode = childNodes.item(i);
String nodeName = newNode.getNodeName(); | if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
guiId = nonRId--; // negative value to indicate it is a unique id but
// we don't know its value
feedIdIntoGeneralMap("id", id, guiId, isSys);
// if (isSys) {
// sysRIdMap.put(id, guiId);
// invSysRIdMap.put(guiId, id);
// } else {
// rIdMap.put(id, guiId);
// invRIdMap.put(guiId, id);
// }
} else {
guiId = guiIdObj.intValue();
}
}
// FIXME(tony): this is an "approximation"
String guiName = node.getNodeName();
if (guiName.equals("menu")) {
guiName = "android.view.Menu";
} else if (guiName.equals("item")) {
guiName = "android.view.MenuItem";
NodeList childNodes = node.getChildNodes();
if(childNodes!=null) {
for (int i = 0; i < childNodes.getLength(); i++) {
Node newNode = childNodes.item(i);
String nodeName = newNode.getNodeName();
if("menu".equals(nodeName)) {
guiName = "android.view.ViewGroup";
}
}
}
} else if (guiName.equals("group")) {
// TODO(tony): we might want to create a special fake class to
// represent menu groups. But for now, let's simply pretend it's
// a ViewGroup. Also, print a warning when we do see <group>
Logger.trace(this.getClass().getSimpleName(), "[TODO] <group> used in " + file); |
17,637 | 4 | // TODO(tony): we might want to create a special fake class to
// represent menu groups. But for now, let's simply pretend it's
// a ViewGroup. Also, print a warning when we do see <group> | private void readMenu(String file, AndroidView root, boolean isSys) {
Document doc;
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(file);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
LinkedList<Pair<Node, AndroidView>> worklist = Lists.newLinkedList();
worklist.add(new Pair<Node, AndroidView>(doc.getDocumentElement(), root));
root = null;
while (!worklist.isEmpty()) {
Pair<Node, AndroidView> pair = worklist.remove();
Node node = pair.getO1();
AndroidView view = pair.getO2();
NamedNodeMap attrMap = node.getAttributes();
Node idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
int guiId = -1;
String id = null;
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> p = parseAndroidId(txt, isSys);
id = p.getO1();
Integer guiIdObj = p.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
guiId = nonRId--; // negative value to indicate it is a unique id but
// we don't know its value
feedIdIntoGeneralMap("id", id, guiId, isSys);
// if (isSys) {
// sysRIdMap.put(id, guiId);
// invSysRIdMap.put(guiId, id);
// } else {
// rIdMap.put(id, guiId);
// invRIdMap.put(guiId, id);
// }
} else {
guiId = guiIdObj.intValue();
}
}
// FIXME(tony): this is an "approximation"
String guiName = node.getNodeName();
if (guiName.equals("menu")) {
guiName = "android.view.Menu";
} else if (guiName.equals("item")) {
guiName = "android.view.MenuItem";
NodeList childNodes = node.getChildNodes();
if(childNodes!=null) {
for (int i = 0; i < childNodes.getLength(); i++) {
Node newNode = childNodes.item(i);
String nodeName = newNode.getNodeName();
if("menu".equals(nodeName)) {
guiName = "android.view.ViewGroup";
}
}
}
} else if (guiName.equals("group")) {
// TODO(tony): we might want to create a special fake class to
// represent menu groups. But for now, let's simply pretend it's
// a ViewGroup. Also, print a warning when we do see <group>
Logger.trace(this.getClass().getSimpleName(), "[TODO] <group> used in " + file);
guiName = "android.view.ViewGroup";
} else {
Logger.trace("XML", "Unhandled menu tag " + guiName);
//throw new RuntimeException("Unhandled menu tag " + guiName);
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
String text = readAndroidTextOrTitle(attrMap, "title");
// hailong: add hint support
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
}
AndroidView newView = new AndroidView();
// FIXME: we assume that every node has attributes, may be wrong
if (!newNode.hasAttributes()) {
Logger.verb("WARNING", "xml node " + newNode + " has no attributes");
// continue;
} else {
NamedNodeMap attrs = newNode.getAttributes();
for (int idx = 0; idx < attrs.getLength(); idx += 1) {
Node attr = attrs.item(idx);
String name = attr.getNodeName();
String value = attr.getNodeValue();
newView.addAttr(name, value);
}
}
newView.setParent(view);
worklist.add(new Pair<Node, AndroidView>(newNode, newView));
}
}
} | DESIGN | true | }
} else if (guiName.equals("group")) {
// TODO(tony): we might want to create a special fake class to
// represent menu groups. But for now, let's simply pretend it's
// a ViewGroup. Also, print a warning when we do see <group>
Logger.trace(this.getClass().getSimpleName(), "[TODO] <group> used in " + file);
guiName = "android.view.ViewGroup"; | if(childNodes!=null) {
for (int i = 0; i < childNodes.getLength(); i++) {
Node newNode = childNodes.item(i);
String nodeName = newNode.getNodeName();
if("menu".equals(nodeName)) {
guiName = "android.view.ViewGroup";
}
}
}
} else if (guiName.equals("group")) {
// TODO(tony): we might want to create a special fake class to
// represent menu groups. But for now, let's simply pretend it's
// a ViewGroup. Also, print a warning when we do see <group>
Logger.trace(this.getClass().getSimpleName(), "[TODO] <group> used in " + file);
guiName = "android.view.ViewGroup";
} else {
Logger.trace("XML", "Unhandled menu tag " + guiName);
//throw new RuntimeException("Unhandled menu tag " + guiName);
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
String text = readAndroidTextOrTitle(attrMap, "title"); | guiId = guiIdObj.intValue();
}
}
// FIXME(tony): this is an "approximation"
String guiName = node.getNodeName();
if (guiName.equals("menu")) {
guiName = "android.view.Menu";
} else if (guiName.equals("item")) {
guiName = "android.view.MenuItem";
NodeList childNodes = node.getChildNodes();
if(childNodes!=null) {
for (int i = 0; i < childNodes.getLength(); i++) {
Node newNode = childNodes.item(i);
String nodeName = newNode.getNodeName();
if("menu".equals(nodeName)) {
guiName = "android.view.ViewGroup";
}
}
}
} else if (guiName.equals("group")) {
// TODO(tony): we might want to create a special fake class to
// represent menu groups. But for now, let's simply pretend it's
// a ViewGroup. Also, print a warning when we do see <group>
Logger.trace(this.getClass().getSimpleName(), "[TODO] <group> used in " + file);
guiName = "android.view.ViewGroup";
} else {
Logger.trace("XML", "Unhandled menu tag " + guiName);
//throw new RuntimeException("Unhandled menu tag " + guiName);
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
String text = readAndroidTextOrTitle(attrMap, "title");
// hailong: add hint support
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap); |
17,637 | 5 | //throw new RuntimeException("Unhandled menu tag " + guiName); | private void readMenu(String file, AndroidView root, boolean isSys) {
Document doc;
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(file);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
LinkedList<Pair<Node, AndroidView>> worklist = Lists.newLinkedList();
worklist.add(new Pair<Node, AndroidView>(doc.getDocumentElement(), root));
root = null;
while (!worklist.isEmpty()) {
Pair<Node, AndroidView> pair = worklist.remove();
Node node = pair.getO1();
AndroidView view = pair.getO2();
NamedNodeMap attrMap = node.getAttributes();
Node idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
int guiId = -1;
String id = null;
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> p = parseAndroidId(txt, isSys);
id = p.getO1();
Integer guiIdObj = p.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
guiId = nonRId--; // negative value to indicate it is a unique id but
// we don't know its value
feedIdIntoGeneralMap("id", id, guiId, isSys);
// if (isSys) {
// sysRIdMap.put(id, guiId);
// invSysRIdMap.put(guiId, id);
// } else {
// rIdMap.put(id, guiId);
// invRIdMap.put(guiId, id);
// }
} else {
guiId = guiIdObj.intValue();
}
}
// FIXME(tony): this is an "approximation"
String guiName = node.getNodeName();
if (guiName.equals("menu")) {
guiName = "android.view.Menu";
} else if (guiName.equals("item")) {
guiName = "android.view.MenuItem";
NodeList childNodes = node.getChildNodes();
if(childNodes!=null) {
for (int i = 0; i < childNodes.getLength(); i++) {
Node newNode = childNodes.item(i);
String nodeName = newNode.getNodeName();
if("menu".equals(nodeName)) {
guiName = "android.view.ViewGroup";
}
}
}
} else if (guiName.equals("group")) {
// TODO(tony): we might want to create a special fake class to
// represent menu groups. But for now, let's simply pretend it's
// a ViewGroup. Also, print a warning when we do see <group>
Logger.trace(this.getClass().getSimpleName(), "[TODO] <group> used in " + file);
guiName = "android.view.ViewGroup";
} else {
Logger.trace("XML", "Unhandled menu tag " + guiName);
//throw new RuntimeException("Unhandled menu tag " + guiName);
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
String text = readAndroidTextOrTitle(attrMap, "title");
// hailong: add hint support
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
}
AndroidView newView = new AndroidView();
// FIXME: we assume that every node has attributes, may be wrong
if (!newNode.hasAttributes()) {
Logger.verb("WARNING", "xml node " + newNode + " has no attributes");
// continue;
} else {
NamedNodeMap attrs = newNode.getAttributes();
for (int idx = 0; idx < attrs.getLength(); idx += 1) {
Node attr = attrs.item(idx);
String name = attr.getNodeName();
String value = attr.getNodeValue();
newView.addAttr(name, value);
}
}
newView.setParent(view);
worklist.add(new Pair<Node, AndroidView>(newNode, newView));
}
}
} | NONSATD | true | } else {
Logger.trace("XML", "Unhandled menu tag " + guiName);
//throw new RuntimeException("Unhandled menu tag " + guiName);
}
if (debug) { | }
}
} else if (guiName.equals("group")) {
// TODO(tony): we might want to create a special fake class to
// represent menu groups. But for now, let's simply pretend it's
// a ViewGroup. Also, print a warning when we do see <group>
Logger.trace(this.getClass().getSimpleName(), "[TODO] <group> used in " + file);
guiName = "android.view.ViewGroup";
} else {
Logger.trace("XML", "Unhandled menu tag " + guiName);
//throw new RuntimeException("Unhandled menu tag " + guiName);
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
String text = readAndroidTextOrTitle(attrMap, "title");
// hailong: add hint support
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints; | } else if (guiName.equals("item")) {
guiName = "android.view.MenuItem";
NodeList childNodes = node.getChildNodes();
if(childNodes!=null) {
for (int i = 0; i < childNodes.getLength(); i++) {
Node newNode = childNodes.item(i);
String nodeName = newNode.getNodeName();
if("menu".equals(nodeName)) {
guiName = "android.view.ViewGroup";
}
}
}
} else if (guiName.equals("group")) {
// TODO(tony): we might want to create a special fake class to
// represent menu groups. But for now, let's simply pretend it's
// a ViewGroup. Also, print a warning when we do see <group>
Logger.trace(this.getClass().getSimpleName(), "[TODO] <group> used in " + file);
guiName = "android.view.ViewGroup";
} else {
Logger.trace("XML", "Unhandled menu tag " + guiName);
//throw new RuntimeException("Unhandled menu tag " + guiName);
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
String text = readAndroidTextOrTitle(attrMap, "title");
// hailong: add hint support
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i); |
17,637 | 6 | // hailong: add hint support | private void readMenu(String file, AndroidView root, boolean isSys) {
Document doc;
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(file);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
LinkedList<Pair<Node, AndroidView>> worklist = Lists.newLinkedList();
worklist.add(new Pair<Node, AndroidView>(doc.getDocumentElement(), root));
root = null;
while (!worklist.isEmpty()) {
Pair<Node, AndroidView> pair = worklist.remove();
Node node = pair.getO1();
AndroidView view = pair.getO2();
NamedNodeMap attrMap = node.getAttributes();
Node idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
int guiId = -1;
String id = null;
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> p = parseAndroidId(txt, isSys);
id = p.getO1();
Integer guiIdObj = p.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
guiId = nonRId--; // negative value to indicate it is a unique id but
// we don't know its value
feedIdIntoGeneralMap("id", id, guiId, isSys);
// if (isSys) {
// sysRIdMap.put(id, guiId);
// invSysRIdMap.put(guiId, id);
// } else {
// rIdMap.put(id, guiId);
// invRIdMap.put(guiId, id);
// }
} else {
guiId = guiIdObj.intValue();
}
}
// FIXME(tony): this is an "approximation"
String guiName = node.getNodeName();
if (guiName.equals("menu")) {
guiName = "android.view.Menu";
} else if (guiName.equals("item")) {
guiName = "android.view.MenuItem";
NodeList childNodes = node.getChildNodes();
if(childNodes!=null) {
for (int i = 0; i < childNodes.getLength(); i++) {
Node newNode = childNodes.item(i);
String nodeName = newNode.getNodeName();
if("menu".equals(nodeName)) {
guiName = "android.view.ViewGroup";
}
}
}
} else if (guiName.equals("group")) {
// TODO(tony): we might want to create a special fake class to
// represent menu groups. But for now, let's simply pretend it's
// a ViewGroup. Also, print a warning when we do see <group>
Logger.trace(this.getClass().getSimpleName(), "[TODO] <group> used in " + file);
guiName = "android.view.ViewGroup";
} else {
Logger.trace("XML", "Unhandled menu tag " + guiName);
//throw new RuntimeException("Unhandled menu tag " + guiName);
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
String text = readAndroidTextOrTitle(attrMap, "title");
// hailong: add hint support
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
}
AndroidView newView = new AndroidView();
// FIXME: we assume that every node has attributes, may be wrong
if (!newNode.hasAttributes()) {
Logger.verb("WARNING", "xml node " + newNode + " has no attributes");
// continue;
} else {
NamedNodeMap attrs = newNode.getAttributes();
for (int idx = 0; idx < attrs.getLength(); idx += 1) {
Node attr = attrs.item(idx);
String name = attr.getNodeName();
String value = attr.getNodeValue();
newView.addAttr(name, value);
}
}
newView.setParent(view);
worklist.add(new Pair<Node, AndroidView>(newNode, newView));
}
}
} | NONSATD | true | }
String text = readAndroidTextOrTitle(attrMap, "title");
// hailong: add hint support
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints"); | Logger.trace(this.getClass().getSimpleName(), "[TODO] <group> used in " + file);
guiName = "android.view.ViewGroup";
} else {
Logger.trace("XML", "Unhandled menu tag " + guiName);
//throw new RuntimeException("Unhandled menu tag " + guiName);
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
String text = readAndroidTextOrTitle(attrMap, "title");
// hailong: add hint support
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName); | String nodeName = newNode.getNodeName();
if("menu".equals(nodeName)) {
guiName = "android.view.ViewGroup";
}
}
}
} else if (guiName.equals("group")) {
// TODO(tony): we might want to create a special fake class to
// represent menu groups. But for now, let's simply pretend it's
// a ViewGroup. Also, print a warning when we do see <group>
Logger.trace(this.getClass().getSimpleName(), "[TODO] <group> used in " + file);
guiName = "android.view.ViewGroup";
} else {
Logger.trace("XML", "Unhandled menu tag " + guiName);
//throw new RuntimeException("Unhandled menu tag " + guiName);
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
String text = readAndroidTextOrTitle(attrMap, "title");
// hailong: add hint support
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system |
17,637 | 7 | //view.save(guiId, text, hint, guiName); | private void readMenu(String file, AndroidView root, boolean isSys) {
Document doc;
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(file);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
LinkedList<Pair<Node, AndroidView>> worklist = Lists.newLinkedList();
worklist.add(new Pair<Node, AndroidView>(doc.getDocumentElement(), root));
root = null;
while (!worklist.isEmpty()) {
Pair<Node, AndroidView> pair = worklist.remove();
Node node = pair.getO1();
AndroidView view = pair.getO2();
NamedNodeMap attrMap = node.getAttributes();
Node idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
int guiId = -1;
String id = null;
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> p = parseAndroidId(txt, isSys);
id = p.getO1();
Integer guiIdObj = p.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
guiId = nonRId--; // negative value to indicate it is a unique id but
// we don't know its value
feedIdIntoGeneralMap("id", id, guiId, isSys);
// if (isSys) {
// sysRIdMap.put(id, guiId);
// invSysRIdMap.put(guiId, id);
// } else {
// rIdMap.put(id, guiId);
// invRIdMap.put(guiId, id);
// }
} else {
guiId = guiIdObj.intValue();
}
}
// FIXME(tony): this is an "approximation"
String guiName = node.getNodeName();
if (guiName.equals("menu")) {
guiName = "android.view.Menu";
} else if (guiName.equals("item")) {
guiName = "android.view.MenuItem";
NodeList childNodes = node.getChildNodes();
if(childNodes!=null) {
for (int i = 0; i < childNodes.getLength(); i++) {
Node newNode = childNodes.item(i);
String nodeName = newNode.getNodeName();
if("menu".equals(nodeName)) {
guiName = "android.view.ViewGroup";
}
}
}
} else if (guiName.equals("group")) {
// TODO(tony): we might want to create a special fake class to
// represent menu groups. But for now, let's simply pretend it's
// a ViewGroup. Also, print a warning when we do see <group>
Logger.trace(this.getClass().getSimpleName(), "[TODO] <group> used in " + file);
guiName = "android.view.ViewGroup";
} else {
Logger.trace("XML", "Unhandled menu tag " + guiName);
//throw new RuntimeException("Unhandled menu tag " + guiName);
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
String text = readAndroidTextOrTitle(attrMap, "title");
// hailong: add hint support
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
}
AndroidView newView = new AndroidView();
// FIXME: we assume that every node has attributes, may be wrong
if (!newNode.hasAttributes()) {
Logger.verb("WARNING", "xml node " + newNode + " has no attributes");
// continue;
} else {
NamedNodeMap attrs = newNode.getAttributes();
for (int idx = 0; idx < attrs.getLength(); idx += 1) {
Node attr = attrs.item(idx);
String name = attr.getNodeName();
String value = attr.getNodeValue();
newView.addAttr(name, value);
}
}
newView.setParent(view);
worklist.add(new Pair<Node, AndroidView>(newNode, newView));
}
}
} | NONSATD | true | String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) { | String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on | guiName = "android.view.ViewGroup";
} else {
Logger.trace("XML", "Unhandled menu tag " + guiName);
//throw new RuntimeException("Unhandled menu tag " + guiName);
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
String text = readAndroidTextOrTitle(attrMap, "title");
// hailong: add hint support
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
}
AndroidView newView = new AndroidView();
// FIXME: we assume that every node has attributes, may be wrong
if (!newNode.hasAttributes()) {
Logger.verb("WARNING", "xml node " + newNode + " has no attributes");
// continue;
} else {
NamedNodeMap attrs = newNode.getAttributes();
for (int idx = 0; idx < attrs.getLength(); idx += 1) { |
17,637 | 8 | // possible for XML files created on a different operating system
// than the one our analysis is run on | private void readMenu(String file, AndroidView root, boolean isSys) {
Document doc;
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(file);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
LinkedList<Pair<Node, AndroidView>> worklist = Lists.newLinkedList();
worklist.add(new Pair<Node, AndroidView>(doc.getDocumentElement(), root));
root = null;
while (!worklist.isEmpty()) {
Pair<Node, AndroidView> pair = worklist.remove();
Node node = pair.getO1();
AndroidView view = pair.getO2();
NamedNodeMap attrMap = node.getAttributes();
Node idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
int guiId = -1;
String id = null;
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> p = parseAndroidId(txt, isSys);
id = p.getO1();
Integer guiIdObj = p.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
guiId = nonRId--; // negative value to indicate it is a unique id but
// we don't know its value
feedIdIntoGeneralMap("id", id, guiId, isSys);
// if (isSys) {
// sysRIdMap.put(id, guiId);
// invSysRIdMap.put(guiId, id);
// } else {
// rIdMap.put(id, guiId);
// invRIdMap.put(guiId, id);
// }
} else {
guiId = guiIdObj.intValue();
}
}
// FIXME(tony): this is an "approximation"
String guiName = node.getNodeName();
if (guiName.equals("menu")) {
guiName = "android.view.Menu";
} else if (guiName.equals("item")) {
guiName = "android.view.MenuItem";
NodeList childNodes = node.getChildNodes();
if(childNodes!=null) {
for (int i = 0; i < childNodes.getLength(); i++) {
Node newNode = childNodes.item(i);
String nodeName = newNode.getNodeName();
if("menu".equals(nodeName)) {
guiName = "android.view.ViewGroup";
}
}
}
} else if (guiName.equals("group")) {
// TODO(tony): we might want to create a special fake class to
// represent menu groups. But for now, let's simply pretend it's
// a ViewGroup. Also, print a warning when we do see <group>
Logger.trace(this.getClass().getSimpleName(), "[TODO] <group> used in " + file);
guiName = "android.view.ViewGroup";
} else {
Logger.trace("XML", "Unhandled menu tag " + guiName);
//throw new RuntimeException("Unhandled menu tag " + guiName);
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
String text = readAndroidTextOrTitle(attrMap, "title");
// hailong: add hint support
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
}
AndroidView newView = new AndroidView();
// FIXME: we assume that every node has attributes, may be wrong
if (!newNode.hasAttributes()) {
Logger.verb("WARNING", "xml node " + newNode + " has no attributes");
// continue;
} else {
NamedNodeMap attrs = newNode.getAttributes();
for (int idx = 0; idx < attrs.getLength(); idx += 1) {
Node attr = attrs.item(idx);
String name = attr.getNodeName();
String value = attr.getNodeValue();
newView.addAttr(name, value);
}
}
newView.setParent(view);
worklist.add(new Pair<Node, AndroidView>(newNode, newView));
}
}
} | NONSATD | true | }
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
} | view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
}
AndroidView newView = new AndroidView();
// FIXME: we assume that every node has attributes, may be wrong
if (!newNode.hasAttributes()) {
Logger.verb("WARNING", "xml node " + newNode + " has no attributes");
// continue;
} else {
NamedNodeMap attrs = newNode.getAttributes();
for (int idx = 0; idx < attrs.getLength(); idx += 1) { | // hailong: add hint support
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
}
AndroidView newView = new AndroidView();
// FIXME: we assume that every node has attributes, may be wrong
if (!newNode.hasAttributes()) {
Logger.verb("WARNING", "xml node " + newNode + " has no attributes");
// continue;
} else {
NamedNodeMap attrs = newNode.getAttributes();
for (int idx = 0; idx < attrs.getLength(); idx += 1) {
Node attr = attrs.item(idx);
String name = attr.getNodeName();
String value = attr.getNodeValue();
newView.addAttr(name, value);
}
}
newView.setParent(view);
worklist.add(new Pair<Node, AndroidView>(newNode, newView));
}
} |
17,637 | 9 | // FIXME: we assume that every node has attributes, may be wrong | private void readMenu(String file, AndroidView root, boolean isSys) {
Document doc;
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(file);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
LinkedList<Pair<Node, AndroidView>> worklist = Lists.newLinkedList();
worklist.add(new Pair<Node, AndroidView>(doc.getDocumentElement(), root));
root = null;
while (!worklist.isEmpty()) {
Pair<Node, AndroidView> pair = worklist.remove();
Node node = pair.getO1();
AndroidView view = pair.getO2();
NamedNodeMap attrMap = node.getAttributes();
Node idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
int guiId = -1;
String id = null;
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> p = parseAndroidId(txt, isSys);
id = p.getO1();
Integer guiIdObj = p.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
guiId = nonRId--; // negative value to indicate it is a unique id but
// we don't know its value
feedIdIntoGeneralMap("id", id, guiId, isSys);
// if (isSys) {
// sysRIdMap.put(id, guiId);
// invSysRIdMap.put(guiId, id);
// } else {
// rIdMap.put(id, guiId);
// invRIdMap.put(guiId, id);
// }
} else {
guiId = guiIdObj.intValue();
}
}
// FIXME(tony): this is an "approximation"
String guiName = node.getNodeName();
if (guiName.equals("menu")) {
guiName = "android.view.Menu";
} else if (guiName.equals("item")) {
guiName = "android.view.MenuItem";
NodeList childNodes = node.getChildNodes();
if(childNodes!=null) {
for (int i = 0; i < childNodes.getLength(); i++) {
Node newNode = childNodes.item(i);
String nodeName = newNode.getNodeName();
if("menu".equals(nodeName)) {
guiName = "android.view.ViewGroup";
}
}
}
} else if (guiName.equals("group")) {
// TODO(tony): we might want to create a special fake class to
// represent menu groups. But for now, let's simply pretend it's
// a ViewGroup. Also, print a warning when we do see <group>
Logger.trace(this.getClass().getSimpleName(), "[TODO] <group> used in " + file);
guiName = "android.view.ViewGroup";
} else {
Logger.trace("XML", "Unhandled menu tag " + guiName);
//throw new RuntimeException("Unhandled menu tag " + guiName);
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
String text = readAndroidTextOrTitle(attrMap, "title");
// hailong: add hint support
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
}
AndroidView newView = new AndroidView();
// FIXME: we assume that every node has attributes, may be wrong
if (!newNode.hasAttributes()) {
Logger.verb("WARNING", "xml node " + newNode + " has no attributes");
// continue;
} else {
NamedNodeMap attrs = newNode.getAttributes();
for (int idx = 0; idx < attrs.getLength(); idx += 1) {
Node attr = attrs.item(idx);
String name = attr.getNodeName();
String value = attr.getNodeValue();
newView.addAttr(name, value);
}
}
newView.setParent(view);
worklist.add(new Pair<Node, AndroidView>(newNode, newView));
}
}
} | DEFECT | true | }
AndroidView newView = new AndroidView();
// FIXME: we assume that every node has attributes, may be wrong
if (!newNode.hasAttributes()) {
Logger.verb("WARNING", "xml node " + newNode + " has no attributes"); | String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
}
AndroidView newView = new AndroidView();
// FIXME: we assume that every node has attributes, may be wrong
if (!newNode.hasAttributes()) {
Logger.verb("WARNING", "xml node " + newNode + " has no attributes");
// continue;
} else {
NamedNodeMap attrs = newNode.getAttributes();
for (int idx = 0; idx < attrs.getLength(); idx += 1) {
Node attr = attrs.item(idx);
String name = attr.getNodeName();
String value = attr.getNodeValue();
newView.addAttr(name, value); | String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
}
AndroidView newView = new AndroidView();
// FIXME: we assume that every node has attributes, may be wrong
if (!newNode.hasAttributes()) {
Logger.verb("WARNING", "xml node " + newNode + " has no attributes");
// continue;
} else {
NamedNodeMap attrs = newNode.getAttributes();
for (int idx = 0; idx < attrs.getLength(); idx += 1) {
Node attr = attrs.item(idx);
String name = attr.getNodeName();
String value = attr.getNodeValue();
newView.addAttr(name, value);
}
}
newView.setParent(view);
worklist.add(new Pair<Node, AndroidView>(newNode, newView));
}
}
} |
17,637 | 10 | // continue; | private void readMenu(String file, AndroidView root, boolean isSys) {
Document doc;
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(file);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
LinkedList<Pair<Node, AndroidView>> worklist = Lists.newLinkedList();
worklist.add(new Pair<Node, AndroidView>(doc.getDocumentElement(), root));
root = null;
while (!worklist.isEmpty()) {
Pair<Node, AndroidView> pair = worklist.remove();
Node node = pair.getO1();
AndroidView view = pair.getO2();
NamedNodeMap attrMap = node.getAttributes();
Node idNode = attrMap.getNamedItemNS(ANDROID_NS, "id");
int guiId = -1;
String id = null;
if (idNode != null) {
String txt = idNode.getTextContent();
Pair<String, Integer> p = parseAndroidId(txt, isSys);
id = p.getO1();
Integer guiIdObj = p.getO2();
if (guiIdObj == null) {
if (!isSys) {
Logger.warn(this.getClass().getSimpleName(),
"unresolved android:id " + id + " in "
+ file);
}
guiId = nonRId--; // negative value to indicate it is a unique id but
// we don't know its value
feedIdIntoGeneralMap("id", id, guiId, isSys);
// if (isSys) {
// sysRIdMap.put(id, guiId);
// invSysRIdMap.put(guiId, id);
// } else {
// rIdMap.put(id, guiId);
// invRIdMap.put(guiId, id);
// }
} else {
guiId = guiIdObj.intValue();
}
}
// FIXME(tony): this is an "approximation"
String guiName = node.getNodeName();
if (guiName.equals("menu")) {
guiName = "android.view.Menu";
} else if (guiName.equals("item")) {
guiName = "android.view.MenuItem";
NodeList childNodes = node.getChildNodes();
if(childNodes!=null) {
for (int i = 0; i < childNodes.getLength(); i++) {
Node newNode = childNodes.item(i);
String nodeName = newNode.getNodeName();
if("menu".equals(nodeName)) {
guiName = "android.view.ViewGroup";
}
}
}
} else if (guiName.equals("group")) {
// TODO(tony): we might want to create a special fake class to
// represent menu groups. But for now, let's simply pretend it's
// a ViewGroup. Also, print a warning when we do see <group>
Logger.trace(this.getClass().getSimpleName(), "[TODO] <group> used in " + file);
guiName = "android.view.ViewGroup";
} else {
Logger.trace("XML", "Unhandled menu tag " + guiName);
//throw new RuntimeException("Unhandled menu tag " + guiName);
}
if (debug) {
Logger.verb(this.getClass().getSimpleName(), guiName + " (" + guiId + ", " + id + ")");
}
String text = readAndroidTextOrTitle(attrMap, "title");
// hailong: add hint support
String hint = readAndroidTextOrTitle(attrMap, "hint");
String autofillHints = readAndroidTextOrTitle(attrMap, "autofillHints");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String tooltip = readAndroidTextOrTitle(attrMap, "tooltipText");
String contentDescription = readAndroidTextOrTitle(attrMap, "contentDescription");
if (hint != null && autofillHints != null) hint += PropertyManager.SEPARATOR + autofillHints;
else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
}
AndroidView newView = new AndroidView();
// FIXME: we assume that every node has attributes, may be wrong
if (!newNode.hasAttributes()) {
Logger.verb("WARNING", "xml node " + newNode + " has no attributes");
// continue;
} else {
NamedNodeMap attrs = newNode.getAttributes();
for (int idx = 0; idx < attrs.getLength(); idx += 1) {
Node attr = attrs.item(idx);
String name = attr.getNodeName();
String value = attr.getNodeValue();
newView.addAttr(name, value);
}
}
newView.setParent(view);
worklist.add(new Pair<Node, AndroidView>(newNode, newView));
}
}
} | NONSATD | true | if (!newNode.hasAttributes()) {
Logger.verb("WARNING", "xml node " + newNode + " has no attributes");
// continue;
} else {
NamedNodeMap attrs = newNode.getAttributes(); | }
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
}
AndroidView newView = new AndroidView();
// FIXME: we assume that every node has attributes, may be wrong
if (!newNode.hasAttributes()) {
Logger.verb("WARNING", "xml node " + newNode + " has no attributes");
// continue;
} else {
NamedNodeMap attrs = newNode.getAttributes();
for (int idx = 0; idx < attrs.getLength(); idx += 1) {
Node attr = attrs.item(idx);
String name = attr.getNodeName();
String value = attr.getNodeValue();
newView.addAttr(name, value);
}
}
newView.setParent(view); | else if (autofillHints != null) hint = autofillHints;
String images = readAndroidImageResource(attrMap);
view.save(guiId, text, hint, tooltip, contentDescription, images, guiName);
//view.save(guiId, text, hint, guiName);
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node newNode = children.item(i);
String nodeName = newNode.getNodeName();
if ("#comment".equals(nodeName)) {
continue;
}
if ("#text".equals(nodeName)) {
// possible for XML files created on a different operating system
// than the one our analysis is run on
continue;
}
AndroidView newView = new AndroidView();
// FIXME: we assume that every node has attributes, may be wrong
if (!newNode.hasAttributes()) {
Logger.verb("WARNING", "xml node " + newNode + " has no attributes");
// continue;
} else {
NamedNodeMap attrs = newNode.getAttributes();
for (int idx = 0; idx < attrs.getLength(); idx += 1) {
Node attr = attrs.item(idx);
String name = attr.getNodeName();
String value = attr.getNodeValue();
newView.addAttr(name, value);
}
}
newView.setParent(view);
worklist.add(new Pair<Node, AndroidView>(newNode, newView));
}
}
} |
34,021 | 0 | /**
* Convert a color name to a color value.
* @param colorName a string repr of the color.
* @return the color value.
* @todo refactor to use an EnumeratedAttribute (maybe?)
*/ | public static Color getColorByName(String colorName) {
switch (colorName.toLowerCase()) {
case COLOR_BLUE:
return Color.blue;
case COLOR_CYAN:
return Color.cyan;
case COLOR_DARKGRAY:
case COLOR_DARKGREY:
return Color.darkGray;
case COLOR_GRAY:
case COLOR_GREY:
return Color.gray;
case COLOR_LIGHTGRAY:
case COLOR_LIGHTGREY:
return Color.lightGray;
case COLOR_GREEN:
return Color.green;
case COLOR_MAGENTA:
return Color.magenta;
case COLOR_ORANGE:
return Color.orange;
case COLOR_PINK:
return Color.pink;
case COLOR_RED:
return Color.red;
case COLOR_WHITE:
return Color.white;
case COLOR_YELLOW:
return Color.yellow;
case COLOR_BLACK:
default:
return Color.black;
}
} | DESIGN | true | public static Color getColorByName(String colorName) {
switch (colorName.toLowerCase()) {
case COLOR_BLUE:
return Color.blue;
case COLOR_CYAN:
return Color.cyan;
case COLOR_DARKGRAY:
case COLOR_DARKGREY:
return Color.darkGray;
case COLOR_GRAY:
case COLOR_GREY:
return Color.gray;
case COLOR_LIGHTGRAY:
case COLOR_LIGHTGREY:
return Color.lightGray;
case COLOR_GREEN:
return Color.green;
case COLOR_MAGENTA:
return Color.magenta;
case COLOR_ORANGE:
return Color.orange;
case COLOR_PINK:
return Color.pink;
case COLOR_RED:
return Color.red;
case COLOR_WHITE:
return Color.white;
case COLOR_YELLOW:
return Color.yellow;
case COLOR_BLACK:
default:
return Color.black;
}
} | public static Color getColorByName(String colorName) {
switch (colorName.toLowerCase()) {
case COLOR_BLUE:
return Color.blue;
case COLOR_CYAN:
return Color.cyan;
case COLOR_DARKGRAY:
case COLOR_DARKGREY:
return Color.darkGray;
case COLOR_GRAY:
case COLOR_GREY:
return Color.gray;
case COLOR_LIGHTGRAY:
case COLOR_LIGHTGREY:
return Color.lightGray;
case COLOR_GREEN:
return Color.green;
case COLOR_MAGENTA:
return Color.magenta;
case COLOR_ORANGE:
return Color.orange;
case COLOR_PINK:
return Color.pink;
case COLOR_RED:
return Color.red;
case COLOR_WHITE:
return Color.white;
case COLOR_YELLOW:
return Color.yellow;
case COLOR_BLACK:
default:
return Color.black;
}
} | public static Color getColorByName(String colorName) {
switch (colorName.toLowerCase()) {
case COLOR_BLUE:
return Color.blue;
case COLOR_CYAN:
return Color.cyan;
case COLOR_DARKGRAY:
case COLOR_DARKGREY:
return Color.darkGray;
case COLOR_GRAY:
case COLOR_GREY:
return Color.gray;
case COLOR_LIGHTGRAY:
case COLOR_LIGHTGREY:
return Color.lightGray;
case COLOR_GREEN:
return Color.green;
case COLOR_MAGENTA:
return Color.magenta;
case COLOR_ORANGE:
return Color.orange;
case COLOR_PINK:
return Color.pink;
case COLOR_RED:
return Color.red;
case COLOR_WHITE:
return Color.white;
case COLOR_YELLOW:
return Color.yellow;
case COLOR_BLACK:
default:
return Color.black;
}
} |
34,026 | 0 | /**
*/ | public View getView(int position, View convertView, ViewGroup parent)
{
mView = convertView;
if (mView == null)
{
LayoutInflater viewInflator;
viewInflator = LayoutInflater.from(mContext);
mView = viewInflator.inflate(R.layout.adapter_category_tile, null);
}
//TODO add a view holder
mCaptionTextView = (TextView) mView.findViewById(R.id.month_analytics_top_category_name);
mCategoryImageView = (ImageView) mView.findViewById(R.id.month_analytics_top_category_image);
mCategorySum = (TextView) mView.findViewById(R.id.month_analytics_top_category_sum);
if(mCategoryList.get(position) != null)
{
String valueStr = Utils.sumAsCurrency(mCategoryList.get(position).mSecondField);
int resIndex = mCategoryList.get(position).mFirstField;
int resource = Images.getImageByPosition(resIndex, Images.getUnsorted());
mCaptionTextView.setText(Images.getCaptionByImage(resource, Images.getSorted()));
mCategoryImageView.setImageResource(resource);
mCategorySum.setText(valueStr);
}
return mView;
} | NONSATD | true | public View getView(int position, View convertView, ViewGroup parent)
{
mView = convertView;
if (mView == null)
{
LayoutInflater viewInflator;
viewInflator = LayoutInflater.from(mContext);
mView = viewInflator.inflate(R.layout.adapter_category_tile, null);
}
//TODO add a view holder
mCaptionTextView = (TextView) mView.findViewById(R.id.month_analytics_top_category_name);
mCategoryImageView = (ImageView) mView.findViewById(R.id.month_analytics_top_category_image);
mCategorySum = (TextView) mView.findViewById(R.id.month_analytics_top_category_sum);
if(mCategoryList.get(position) != null)
{
String valueStr = Utils.sumAsCurrency(mCategoryList.get(position).mSecondField);
int resIndex = mCategoryList.get(position).mFirstField;
int resource = Images.getImageByPosition(resIndex, Images.getUnsorted());
mCaptionTextView.setText(Images.getCaptionByImage(resource, Images.getSorted()));
mCategoryImageView.setImageResource(resource);
mCategorySum.setText(valueStr);
}
return mView;
} | public View getView(int position, View convertView, ViewGroup parent)
{
mView = convertView;
if (mView == null)
{
LayoutInflater viewInflator;
viewInflator = LayoutInflater.from(mContext);
mView = viewInflator.inflate(R.layout.adapter_category_tile, null);
}
//TODO add a view holder
mCaptionTextView = (TextView) mView.findViewById(R.id.month_analytics_top_category_name);
mCategoryImageView = (ImageView) mView.findViewById(R.id.month_analytics_top_category_image);
mCategorySum = (TextView) mView.findViewById(R.id.month_analytics_top_category_sum);
if(mCategoryList.get(position) != null)
{
String valueStr = Utils.sumAsCurrency(mCategoryList.get(position).mSecondField);
int resIndex = mCategoryList.get(position).mFirstField;
int resource = Images.getImageByPosition(resIndex, Images.getUnsorted());
mCaptionTextView.setText(Images.getCaptionByImage(resource, Images.getSorted()));
mCategoryImageView.setImageResource(resource);
mCategorySum.setText(valueStr);
}
return mView;
} | public View getView(int position, View convertView, ViewGroup parent)
{
mView = convertView;
if (mView == null)
{
LayoutInflater viewInflator;
viewInflator = LayoutInflater.from(mContext);
mView = viewInflator.inflate(R.layout.adapter_category_tile, null);
}
//TODO add a view holder
mCaptionTextView = (TextView) mView.findViewById(R.id.month_analytics_top_category_name);
mCategoryImageView = (ImageView) mView.findViewById(R.id.month_analytics_top_category_image);
mCategorySum = (TextView) mView.findViewById(R.id.month_analytics_top_category_sum);
if(mCategoryList.get(position) != null)
{
String valueStr = Utils.sumAsCurrency(mCategoryList.get(position).mSecondField);
int resIndex = mCategoryList.get(position).mFirstField;
int resource = Images.getImageByPosition(resIndex, Images.getUnsorted());
mCaptionTextView.setText(Images.getCaptionByImage(resource, Images.getSorted()));
mCategoryImageView.setImageResource(resource);
mCategorySum.setText(valueStr);
}
return mView;
} |
34,026 | 1 | //TODO add a view holder | public View getView(int position, View convertView, ViewGroup parent)
{
mView = convertView;
if (mView == null)
{
LayoutInflater viewInflator;
viewInflator = LayoutInflater.from(mContext);
mView = viewInflator.inflate(R.layout.adapter_category_tile, null);
}
//TODO add a view holder
mCaptionTextView = (TextView) mView.findViewById(R.id.month_analytics_top_category_name);
mCategoryImageView = (ImageView) mView.findViewById(R.id.month_analytics_top_category_image);
mCategorySum = (TextView) mView.findViewById(R.id.month_analytics_top_category_sum);
if(mCategoryList.get(position) != null)
{
String valueStr = Utils.sumAsCurrency(mCategoryList.get(position).mSecondField);
int resIndex = mCategoryList.get(position).mFirstField;
int resource = Images.getImageByPosition(resIndex, Images.getUnsorted());
mCaptionTextView.setText(Images.getCaptionByImage(resource, Images.getSorted()));
mCategoryImageView.setImageResource(resource);
mCategorySum.setText(valueStr);
}
return mView;
} | IMPLEMENTATION | true | mView = viewInflator.inflate(R.layout.adapter_category_tile, null);
}
//TODO add a view holder
mCaptionTextView = (TextView) mView.findViewById(R.id.month_analytics_top_category_name);
mCategoryImageView = (ImageView) mView.findViewById(R.id.month_analytics_top_category_image); | public View getView(int position, View convertView, ViewGroup parent)
{
mView = convertView;
if (mView == null)
{
LayoutInflater viewInflator;
viewInflator = LayoutInflater.from(mContext);
mView = viewInflator.inflate(R.layout.adapter_category_tile, null);
}
//TODO add a view holder
mCaptionTextView = (TextView) mView.findViewById(R.id.month_analytics_top_category_name);
mCategoryImageView = (ImageView) mView.findViewById(R.id.month_analytics_top_category_image);
mCategorySum = (TextView) mView.findViewById(R.id.month_analytics_top_category_sum);
if(mCategoryList.get(position) != null)
{
String valueStr = Utils.sumAsCurrency(mCategoryList.get(position).mSecondField);
int resIndex = mCategoryList.get(position).mFirstField;
int resource = Images.getImageByPosition(resIndex, Images.getUnsorted());
mCaptionTextView.setText(Images.getCaptionByImage(resource, Images.getSorted()));
mCategoryImageView.setImageResource(resource); | public View getView(int position, View convertView, ViewGroup parent)
{
mView = convertView;
if (mView == null)
{
LayoutInflater viewInflator;
viewInflator = LayoutInflater.from(mContext);
mView = viewInflator.inflate(R.layout.adapter_category_tile, null);
}
//TODO add a view holder
mCaptionTextView = (TextView) mView.findViewById(R.id.month_analytics_top_category_name);
mCategoryImageView = (ImageView) mView.findViewById(R.id.month_analytics_top_category_image);
mCategorySum = (TextView) mView.findViewById(R.id.month_analytics_top_category_sum);
if(mCategoryList.get(position) != null)
{
String valueStr = Utils.sumAsCurrency(mCategoryList.get(position).mSecondField);
int resIndex = mCategoryList.get(position).mFirstField;
int resource = Images.getImageByPosition(resIndex, Images.getUnsorted());
mCaptionTextView.setText(Images.getCaptionByImage(resource, Images.getSorted()));
mCategoryImageView.setImageResource(resource);
mCategorySum.setText(valueStr);
}
return mView;
} |
17,643 | 0 | /**
* Creates a new connection and a new session to activeMQ
*/ | public void bootstrapMessagingSystem(){
try{
messagingSystem = new MessagingSystem(ACTIVEMQ_BROKER_URI, ACTIVEMQ_BROKER_PORT);
messagingSystem.createConnection();
messagingSystem.createSession();
//TODO: handle topics, not just queues
messagingSystem.createDestination(ACTIVEMQ_DESTINATION_NAME);
messagingSystem.createProducer();
System.out.println("SolrToActiveMQComponent: Bootstrapping messaging system done.");
messagingSystem.validateConnection();
}
catch (JMSException e){
System.out.println("SolrToActiveMQComponent: Bootstrapping messaging system failed.\n" + e);
messagingSystem.invalidateConnection();
}
} | NONSATD | true | public void bootstrapMessagingSystem(){
try{
messagingSystem = new MessagingSystem(ACTIVEMQ_BROKER_URI, ACTIVEMQ_BROKER_PORT);
messagingSystem.createConnection();
messagingSystem.createSession();
//TODO: handle topics, not just queues
messagingSystem.createDestination(ACTIVEMQ_DESTINATION_NAME);
messagingSystem.createProducer();
System.out.println("SolrToActiveMQComponent: Bootstrapping messaging system done.");
messagingSystem.validateConnection();
}
catch (JMSException e){
System.out.println("SolrToActiveMQComponent: Bootstrapping messaging system failed.\n" + e);
messagingSystem.invalidateConnection();
}
} | public void bootstrapMessagingSystem(){
try{
messagingSystem = new MessagingSystem(ACTIVEMQ_BROKER_URI, ACTIVEMQ_BROKER_PORT);
messagingSystem.createConnection();
messagingSystem.createSession();
//TODO: handle topics, not just queues
messagingSystem.createDestination(ACTIVEMQ_DESTINATION_NAME);
messagingSystem.createProducer();
System.out.println("SolrToActiveMQComponent: Bootstrapping messaging system done.");
messagingSystem.validateConnection();
}
catch (JMSException e){
System.out.println("SolrToActiveMQComponent: Bootstrapping messaging system failed.\n" + e);
messagingSystem.invalidateConnection();
}
} | public void bootstrapMessagingSystem(){
try{
messagingSystem = new MessagingSystem(ACTIVEMQ_BROKER_URI, ACTIVEMQ_BROKER_PORT);
messagingSystem.createConnection();
messagingSystem.createSession();
//TODO: handle topics, not just queues
messagingSystem.createDestination(ACTIVEMQ_DESTINATION_NAME);
messagingSystem.createProducer();
System.out.println("SolrToActiveMQComponent: Bootstrapping messaging system done.");
messagingSystem.validateConnection();
}
catch (JMSException e){
System.out.println("SolrToActiveMQComponent: Bootstrapping messaging system failed.\n" + e);
messagingSystem.invalidateConnection();
}
} |
17,643 | 1 | //TODO: handle topics, not just queues | public void bootstrapMessagingSystem(){
try{
messagingSystem = new MessagingSystem(ACTIVEMQ_BROKER_URI, ACTIVEMQ_BROKER_PORT);
messagingSystem.createConnection();
messagingSystem.createSession();
//TODO: handle topics, not just queues
messagingSystem.createDestination(ACTIVEMQ_DESTINATION_NAME);
messagingSystem.createProducer();
System.out.println("SolrToActiveMQComponent: Bootstrapping messaging system done.");
messagingSystem.validateConnection();
}
catch (JMSException e){
System.out.println("SolrToActiveMQComponent: Bootstrapping messaging system failed.\n" + e);
messagingSystem.invalidateConnection();
}
} | IMPLEMENTATION | true | messagingSystem.createConnection();
messagingSystem.createSession();
//TODO: handle topics, not just queues
messagingSystem.createDestination(ACTIVEMQ_DESTINATION_NAME);
messagingSystem.createProducer(); | public void bootstrapMessagingSystem(){
try{
messagingSystem = new MessagingSystem(ACTIVEMQ_BROKER_URI, ACTIVEMQ_BROKER_PORT);
messagingSystem.createConnection();
messagingSystem.createSession();
//TODO: handle topics, not just queues
messagingSystem.createDestination(ACTIVEMQ_DESTINATION_NAME);
messagingSystem.createProducer();
System.out.println("SolrToActiveMQComponent: Bootstrapping messaging system done.");
messagingSystem.validateConnection();
}
catch (JMSException e){
System.out.println("SolrToActiveMQComponent: Bootstrapping messaging system failed.\n" + e);
messagingSystem.invalidateConnection();
}
} | public void bootstrapMessagingSystem(){
try{
messagingSystem = new MessagingSystem(ACTIVEMQ_BROKER_URI, ACTIVEMQ_BROKER_PORT);
messagingSystem.createConnection();
messagingSystem.createSession();
//TODO: handle topics, not just queues
messagingSystem.createDestination(ACTIVEMQ_DESTINATION_NAME);
messagingSystem.createProducer();
System.out.println("SolrToActiveMQComponent: Bootstrapping messaging system done.");
messagingSystem.validateConnection();
}
catch (JMSException e){
System.out.println("SolrToActiveMQComponent: Bootstrapping messaging system failed.\n" + e);
messagingSystem.invalidateConnection();
}
} |
17,649 | 0 | /**
* Rollup the parameters of the given source parameter group.
*
* @param sourceParamGroup the parameter group to be rolled up
* @param targetParamGroup the group that will receive the rolled up content
* @param referenceHandler the rollup reference handler instance
* @param cloner used for cloning model element as required
*/ | private void rollupParameters(TLParamGroup sourceParamGroup, TLParamGroup targetParamGroup,
RollupReferenceHandler referenceHandler, ModelElementCloner cloner) {
for (TLParameter sourceParam : sourceParamGroup.getParameters()) {
TLMemberField<?> sourceFieldRef = sourceParam.getFieldRef();
if (sourceFieldRef != null) {
TLParameter targetParam = targetParamGroup.getParameter( sourceFieldRef.getName() );
if (targetParam == null) {
targetParam = cloner.clone( sourceParam ); // TODO: After cloning, targetParam.fieldRef is null
targetParamGroup.addParameter( targetParam );
referenceHandler.captureRollupReferences( targetParam );
}
if (targetParam.getDocumentation() == null) {
targetParam.setDocumentation( cloner.clone( sourceParam.getDocumentation() ) );
}
}
}
} | NONSATD | true | private void rollupParameters(TLParamGroup sourceParamGroup, TLParamGroup targetParamGroup,
RollupReferenceHandler referenceHandler, ModelElementCloner cloner) {
for (TLParameter sourceParam : sourceParamGroup.getParameters()) {
TLMemberField<?> sourceFieldRef = sourceParam.getFieldRef();
if (sourceFieldRef != null) {
TLParameter targetParam = targetParamGroup.getParameter( sourceFieldRef.getName() );
if (targetParam == null) {
targetParam = cloner.clone( sourceParam ); // TODO: After cloning, targetParam.fieldRef is null
targetParamGroup.addParameter( targetParam );
referenceHandler.captureRollupReferences( targetParam );
}
if (targetParam.getDocumentation() == null) {
targetParam.setDocumentation( cloner.clone( sourceParam.getDocumentation() ) );
}
}
}
} | private void rollupParameters(TLParamGroup sourceParamGroup, TLParamGroup targetParamGroup,
RollupReferenceHandler referenceHandler, ModelElementCloner cloner) {
for (TLParameter sourceParam : sourceParamGroup.getParameters()) {
TLMemberField<?> sourceFieldRef = sourceParam.getFieldRef();
if (sourceFieldRef != null) {
TLParameter targetParam = targetParamGroup.getParameter( sourceFieldRef.getName() );
if (targetParam == null) {
targetParam = cloner.clone( sourceParam ); // TODO: After cloning, targetParam.fieldRef is null
targetParamGroup.addParameter( targetParam );
referenceHandler.captureRollupReferences( targetParam );
}
if (targetParam.getDocumentation() == null) {
targetParam.setDocumentation( cloner.clone( sourceParam.getDocumentation() ) );
}
}
}
} | private void rollupParameters(TLParamGroup sourceParamGroup, TLParamGroup targetParamGroup,
RollupReferenceHandler referenceHandler, ModelElementCloner cloner) {
for (TLParameter sourceParam : sourceParamGroup.getParameters()) {
TLMemberField<?> sourceFieldRef = sourceParam.getFieldRef();
if (sourceFieldRef != null) {
TLParameter targetParam = targetParamGroup.getParameter( sourceFieldRef.getName() );
if (targetParam == null) {
targetParam = cloner.clone( sourceParam ); // TODO: After cloning, targetParam.fieldRef is null
targetParamGroup.addParameter( targetParam );
referenceHandler.captureRollupReferences( targetParam );
}
if (targetParam.getDocumentation() == null) {
targetParam.setDocumentation( cloner.clone( sourceParam.getDocumentation() ) );
}
}
}
} |
17,649 | 1 | // TODO: After cloning, targetParam.fieldRef is null | private void rollupParameters(TLParamGroup sourceParamGroup, TLParamGroup targetParamGroup,
RollupReferenceHandler referenceHandler, ModelElementCloner cloner) {
for (TLParameter sourceParam : sourceParamGroup.getParameters()) {
TLMemberField<?> sourceFieldRef = sourceParam.getFieldRef();
if (sourceFieldRef != null) {
TLParameter targetParam = targetParamGroup.getParameter( sourceFieldRef.getName() );
if (targetParam == null) {
targetParam = cloner.clone( sourceParam ); // TODO: After cloning, targetParam.fieldRef is null
targetParamGroup.addParameter( targetParam );
referenceHandler.captureRollupReferences( targetParam );
}
if (targetParam.getDocumentation() == null) {
targetParam.setDocumentation( cloner.clone( sourceParam.getDocumentation() ) );
}
}
}
} | IMPLEMENTATION | true | TLParameter targetParam = targetParamGroup.getParameter( sourceFieldRef.getName() );
if (targetParam == null) {
targetParam = cloner.clone( sourceParam ); // TODO: After cloning, targetParam.fieldRef is null
targetParamGroup.addParameter( targetParam );
referenceHandler.captureRollupReferences( targetParam ); | private void rollupParameters(TLParamGroup sourceParamGroup, TLParamGroup targetParamGroup,
RollupReferenceHandler referenceHandler, ModelElementCloner cloner) {
for (TLParameter sourceParam : sourceParamGroup.getParameters()) {
TLMemberField<?> sourceFieldRef = sourceParam.getFieldRef();
if (sourceFieldRef != null) {
TLParameter targetParam = targetParamGroup.getParameter( sourceFieldRef.getName() );
if (targetParam == null) {
targetParam = cloner.clone( sourceParam ); // TODO: After cloning, targetParam.fieldRef is null
targetParamGroup.addParameter( targetParam );
referenceHandler.captureRollupReferences( targetParam );
}
if (targetParam.getDocumentation() == null) {
targetParam.setDocumentation( cloner.clone( sourceParam.getDocumentation() ) );
}
}
}
} | private void rollupParameters(TLParamGroup sourceParamGroup, TLParamGroup targetParamGroup,
RollupReferenceHandler referenceHandler, ModelElementCloner cloner) {
for (TLParameter sourceParam : sourceParamGroup.getParameters()) {
TLMemberField<?> sourceFieldRef = sourceParam.getFieldRef();
if (sourceFieldRef != null) {
TLParameter targetParam = targetParamGroup.getParameter( sourceFieldRef.getName() );
if (targetParam == null) {
targetParam = cloner.clone( sourceParam ); // TODO: After cloning, targetParam.fieldRef is null
targetParamGroup.addParameter( targetParam );
referenceHandler.captureRollupReferences( targetParam );
}
if (targetParam.getDocumentation() == null) {
targetParam.setDocumentation( cloner.clone( sourceParam.getDocumentation() ) );
}
}
}
} |
9,474 | 0 | // Find proper device and raise event. | @Override
protected void channelRead0(ChannelHandlerContext ctx,
CoapMessage msg) {
try {
// Find proper device and raise event.
Device targetDevice = ctx.channel().attr(keyDevice).get();
if (targetDevice == null) {
throw new InternalServerErrorException(
"Unable to find device");
}
if (msg instanceof CoapRequest) {
onRequestReceived(targetDevice, (CoapRequest) msg);
} else if (msg instanceof CoapResponse) {
// TODO: Re-architecturing required
IRequestChannel reqChannel = ((CoapDevice) targetDevice)
.getRequestChannel();
CoapClient coapClient = (CoapClient) reqChannel;
coapClient.onResponseReceived(msg);
}
} catch (ServerException e) {
ctx.writeAndFlush(MessageBuilder.createResponse(msg,
e.getErrorResponse()));
Log.f(ctx.channel(), e);
} catch (ClientException e) {
Log.f(ctx.channel(), e);
} catch (Throwable t) {
Log.f(ctx.channel(), t);
if (msg instanceof CoapRequest) {
ctx.writeAndFlush(MessageBuilder.createResponse(msg,
ResponseStatus.INTERNAL_SERVER_ERROR));
}
}
} | NONSATD | true | CoapMessage msg) {
try {
// Find proper device and raise event.
Device targetDevice = ctx.channel().attr(keyDevice).get();
if (targetDevice == null) { | @Override
protected void channelRead0(ChannelHandlerContext ctx,
CoapMessage msg) {
try {
// Find proper device and raise event.
Device targetDevice = ctx.channel().attr(keyDevice).get();
if (targetDevice == null) {
throw new InternalServerErrorException(
"Unable to find device");
}
if (msg instanceof CoapRequest) {
onRequestReceived(targetDevice, (CoapRequest) msg);
} else if (msg instanceof CoapResponse) {
// TODO: Re-architecturing required
IRequestChannel reqChannel = ((CoapDevice) targetDevice) | @Override
protected void channelRead0(ChannelHandlerContext ctx,
CoapMessage msg) {
try {
// Find proper device and raise event.
Device targetDevice = ctx.channel().attr(keyDevice).get();
if (targetDevice == null) {
throw new InternalServerErrorException(
"Unable to find device");
}
if (msg instanceof CoapRequest) {
onRequestReceived(targetDevice, (CoapRequest) msg);
} else if (msg instanceof CoapResponse) {
// TODO: Re-architecturing required
IRequestChannel reqChannel = ((CoapDevice) targetDevice)
.getRequestChannel();
CoapClient coapClient = (CoapClient) reqChannel;
coapClient.onResponseReceived(msg);
}
} catch (ServerException e) {
ctx.writeAndFlush(MessageBuilder.createResponse(msg,
e.getErrorResponse()));
Log.f(ctx.channel(), e);
} catch (ClientException e) {
Log.f(ctx.channel(), e); |
9,474 | 1 | // TODO: Re-architecturing required | @Override
protected void channelRead0(ChannelHandlerContext ctx,
CoapMessage msg) {
try {
// Find proper device and raise event.
Device targetDevice = ctx.channel().attr(keyDevice).get();
if (targetDevice == null) {
throw new InternalServerErrorException(
"Unable to find device");
}
if (msg instanceof CoapRequest) {
onRequestReceived(targetDevice, (CoapRequest) msg);
} else if (msg instanceof CoapResponse) {
// TODO: Re-architecturing required
IRequestChannel reqChannel = ((CoapDevice) targetDevice)
.getRequestChannel();
CoapClient coapClient = (CoapClient) reqChannel;
coapClient.onResponseReceived(msg);
}
} catch (ServerException e) {
ctx.writeAndFlush(MessageBuilder.createResponse(msg,
e.getErrorResponse()));
Log.f(ctx.channel(), e);
} catch (ClientException e) {
Log.f(ctx.channel(), e);
} catch (Throwable t) {
Log.f(ctx.channel(), t);
if (msg instanceof CoapRequest) {
ctx.writeAndFlush(MessageBuilder.createResponse(msg,
ResponseStatus.INTERNAL_SERVER_ERROR));
}
}
} | DESIGN | true | onRequestReceived(targetDevice, (CoapRequest) msg);
} else if (msg instanceof CoapResponse) {
// TODO: Re-architecturing required
IRequestChannel reqChannel = ((CoapDevice) targetDevice)
.getRequestChannel(); | try {
// Find proper device and raise event.
Device targetDevice = ctx.channel().attr(keyDevice).get();
if (targetDevice == null) {
throw new InternalServerErrorException(
"Unable to find device");
}
if (msg instanceof CoapRequest) {
onRequestReceived(targetDevice, (CoapRequest) msg);
} else if (msg instanceof CoapResponse) {
// TODO: Re-architecturing required
IRequestChannel reqChannel = ((CoapDevice) targetDevice)
.getRequestChannel();
CoapClient coapClient = (CoapClient) reqChannel;
coapClient.onResponseReceived(msg);
}
} catch (ServerException e) {
ctx.writeAndFlush(MessageBuilder.createResponse(msg,
e.getErrorResponse()));
Log.f(ctx.channel(), e);
} catch (ClientException e) { | @Override
protected void channelRead0(ChannelHandlerContext ctx,
CoapMessage msg) {
try {
// Find proper device and raise event.
Device targetDevice = ctx.channel().attr(keyDevice).get();
if (targetDevice == null) {
throw new InternalServerErrorException(
"Unable to find device");
}
if (msg instanceof CoapRequest) {
onRequestReceived(targetDevice, (CoapRequest) msg);
} else if (msg instanceof CoapResponse) {
// TODO: Re-architecturing required
IRequestChannel reqChannel = ((CoapDevice) targetDevice)
.getRequestChannel();
CoapClient coapClient = (CoapClient) reqChannel;
coapClient.onResponseReceived(msg);
}
} catch (ServerException e) {
ctx.writeAndFlush(MessageBuilder.createResponse(msg,
e.getErrorResponse()));
Log.f(ctx.channel(), e);
} catch (ClientException e) {
Log.f(ctx.channel(), e);
} catch (Throwable t) {
Log.f(ctx.channel(), t);
if (msg instanceof CoapRequest) {
ctx.writeAndFlush(MessageBuilder.createResponse(msg,
ResponseStatus.INTERNAL_SERVER_ERROR));
}
}
} |
9,475 | 0 | /**
* Returns a {@link List} of additional {@link TestConfiguration} instances that should be run
* along with the default {@code TestConfiguration} instances.
*
* <p>This typically includes a configuration to test Google Play Services (if available) and
* any other device specific configurations.
*/ | private static List<TestConfiguration> getAdditionalConfigurations(Activity activity) {
List<TestConfiguration> additionalConfigurations = new ArrayList<>();
if (Constants.USE_GMS_CONFIGURATION) {
additionalConfigurations.add(new GmsPermissionConfiguration(activity));
}
// TODO: Any custom configurations that are intended to be run as part of this test should
// be added here.
return additionalConfigurations;
} | NONSATD | true | private static List<TestConfiguration> getAdditionalConfigurations(Activity activity) {
List<TestConfiguration> additionalConfigurations = new ArrayList<>();
if (Constants.USE_GMS_CONFIGURATION) {
additionalConfigurations.add(new GmsPermissionConfiguration(activity));
}
// TODO: Any custom configurations that are intended to be run as part of this test should
// be added here.
return additionalConfigurations;
} | private static List<TestConfiguration> getAdditionalConfigurations(Activity activity) {
List<TestConfiguration> additionalConfigurations = new ArrayList<>();
if (Constants.USE_GMS_CONFIGURATION) {
additionalConfigurations.add(new GmsPermissionConfiguration(activity));
}
// TODO: Any custom configurations that are intended to be run as part of this test should
// be added here.
return additionalConfigurations;
} | private static List<TestConfiguration> getAdditionalConfigurations(Activity activity) {
List<TestConfiguration> additionalConfigurations = new ArrayList<>();
if (Constants.USE_GMS_CONFIGURATION) {
additionalConfigurations.add(new GmsPermissionConfiguration(activity));
}
// TODO: Any custom configurations that are intended to be run as part of this test should
// be added here.
return additionalConfigurations;
} |
9,475 | 1 | // TODO: Any custom configurations that are intended to be run as part of this test should
// be added here. | private static List<TestConfiguration> getAdditionalConfigurations(Activity activity) {
List<TestConfiguration> additionalConfigurations = new ArrayList<>();
if (Constants.USE_GMS_CONFIGURATION) {
additionalConfigurations.add(new GmsPermissionConfiguration(activity));
}
// TODO: Any custom configurations that are intended to be run as part of this test should
// be added here.
return additionalConfigurations;
} | DESIGN | true | additionalConfigurations.add(new GmsPermissionConfiguration(activity));
}
// TODO: Any custom configurations that are intended to be run as part of this test should
// be added here.
return additionalConfigurations;
} | private static List<TestConfiguration> getAdditionalConfigurations(Activity activity) {
List<TestConfiguration> additionalConfigurations = new ArrayList<>();
if (Constants.USE_GMS_CONFIGURATION) {
additionalConfigurations.add(new GmsPermissionConfiguration(activity));
}
// TODO: Any custom configurations that are intended to be run as part of this test should
// be added here.
return additionalConfigurations;
} | private static List<TestConfiguration> getAdditionalConfigurations(Activity activity) {
List<TestConfiguration> additionalConfigurations = new ArrayList<>();
if (Constants.USE_GMS_CONFIGURATION) {
additionalConfigurations.add(new GmsPermissionConfiguration(activity));
}
// TODO: Any custom configurations that are intended to be run as part of this test should
// be added here.
return additionalConfigurations;
} |
9,486 | 0 | // the org.robolectric.res package lives in the base classloader, but not its tests; yuck. | public boolean shouldAcquire(String name) {
// the org.robolectric.res package lives in the base classloader, but not its tests; yuck.
int lastDot = name.lastIndexOf('.');
String pkgName = name.substring(0, lastDot == -1 ? 0 : lastDot);
if (pkgName.equals("org.robolectric.res")) {
return name.contains("Test");
}
if (name.matches("com\\.android\\.internal\\.R(\\$.*)?")) return true;
// Android SDK code almost universally refers to com.android.internal.R, except
// when refering to android.R.stylable, as in HorizontalScrollView. arghgh.
// See https://github.com/robolectric/robolectric/issues/521
if (name.equals("android.R$styleable")) return true;
return !(
name.matches(".*\\.R(|\\$[a-z]+)$")
|| CLASSES_TO_ALWAYS_DELEGATE.contains(name)
|| name.startsWith("java.")
|| name.startsWith("javax.")
|| name.startsWith("sun.")
|| name.startsWith("com.sun.")
|| name.startsWith("org.w3c.")
|| name.startsWith("org.xml.")
|| name.startsWith("org.junit")
|| name.startsWith("org.hamcrest")
|| name.startsWith("org.specs2") // allows for android projects with mixed scala\java tests to be
|| name.startsWith("scala.") // run with Maven Surefire (see the RoboSpecs project on github)
|| name.startsWith("org.sqlite.") // ugh, we're barfing while loading org.sqlite now for some reason?!? todo: still?
);
} | DESIGN | true | public boolean shouldAcquire(String name) {
// the org.robolectric.res package lives in the base classloader, but not its tests; yuck.
int lastDot = name.lastIndexOf('.');
String pkgName = name.substring(0, lastDot == -1 ? 0 : lastDot); | public boolean shouldAcquire(String name) {
// the org.robolectric.res package lives in the base classloader, but not its tests; yuck.
int lastDot = name.lastIndexOf('.');
String pkgName = name.substring(0, lastDot == -1 ? 0 : lastDot);
if (pkgName.equals("org.robolectric.res")) {
return name.contains("Test");
}
if (name.matches("com\\.android\\.internal\\.R(\\$.*)?")) return true;
// Android SDK code almost universally refers to com.android.internal.R, except
// when refering to android.R.stylable, as in HorizontalScrollView. arghgh.
// See https://github.com/robolectric/robolectric/issues/521
if (name.equals("android.R$styleable")) return true; | public boolean shouldAcquire(String name) {
// the org.robolectric.res package lives in the base classloader, but not its tests; yuck.
int lastDot = name.lastIndexOf('.');
String pkgName = name.substring(0, lastDot == -1 ? 0 : lastDot);
if (pkgName.equals("org.robolectric.res")) {
return name.contains("Test");
}
if (name.matches("com\\.android\\.internal\\.R(\\$.*)?")) return true;
// Android SDK code almost universally refers to com.android.internal.R, except
// when refering to android.R.stylable, as in HorizontalScrollView. arghgh.
// See https://github.com/robolectric/robolectric/issues/521
if (name.equals("android.R$styleable")) return true;
return !(
name.matches(".*\\.R(|\\$[a-z]+)$")
|| CLASSES_TO_ALWAYS_DELEGATE.contains(name)
|| name.startsWith("java.")
|| name.startsWith("javax.")
|| name.startsWith("sun.")
|| name.startsWith("com.sun.")
|| name.startsWith("org.w3c.")
|| name.startsWith("org.xml.")
|| name.startsWith("org.junit") |
9,486 | 1 | // Android SDK code almost universally refers to com.android.internal.R, except
// when refering to android.R.stylable, as in HorizontalScrollView. arghgh.
// See https://github.com/robolectric/robolectric/issues/521 | public boolean shouldAcquire(String name) {
// the org.robolectric.res package lives in the base classloader, but not its tests; yuck.
int lastDot = name.lastIndexOf('.');
String pkgName = name.substring(0, lastDot == -1 ? 0 : lastDot);
if (pkgName.equals("org.robolectric.res")) {
return name.contains("Test");
}
if (name.matches("com\\.android\\.internal\\.R(\\$.*)?")) return true;
// Android SDK code almost universally refers to com.android.internal.R, except
// when refering to android.R.stylable, as in HorizontalScrollView. arghgh.
// See https://github.com/robolectric/robolectric/issues/521
if (name.equals("android.R$styleable")) return true;
return !(
name.matches(".*\\.R(|\\$[a-z]+)$")
|| CLASSES_TO_ALWAYS_DELEGATE.contains(name)
|| name.startsWith("java.")
|| name.startsWith("javax.")
|| name.startsWith("sun.")
|| name.startsWith("com.sun.")
|| name.startsWith("org.w3c.")
|| name.startsWith("org.xml.")
|| name.startsWith("org.junit")
|| name.startsWith("org.hamcrest")
|| name.startsWith("org.specs2") // allows for android projects with mixed scala\java tests to be
|| name.startsWith("scala.") // run with Maven Surefire (see the RoboSpecs project on github)
|| name.startsWith("org.sqlite.") // ugh, we're barfing while loading org.sqlite now for some reason?!? todo: still?
);
} | DESIGN | true | }
if (name.matches("com\\.android\\.internal\\.R(\\$.*)?")) return true;
// Android SDK code almost universally refers to com.android.internal.R, except
// when refering to android.R.stylable, as in HorizontalScrollView. arghgh.
// See https://github.com/robolectric/robolectric/issues/521
if (name.equals("android.R$styleable")) return true;
return !( | public boolean shouldAcquire(String name) {
// the org.robolectric.res package lives in the base classloader, but not its tests; yuck.
int lastDot = name.lastIndexOf('.');
String pkgName = name.substring(0, lastDot == -1 ? 0 : lastDot);
if (pkgName.equals("org.robolectric.res")) {
return name.contains("Test");
}
if (name.matches("com\\.android\\.internal\\.R(\\$.*)?")) return true;
// Android SDK code almost universally refers to com.android.internal.R, except
// when refering to android.R.stylable, as in HorizontalScrollView. arghgh.
// See https://github.com/robolectric/robolectric/issues/521
if (name.equals("android.R$styleable")) return true;
return !(
name.matches(".*\\.R(|\\$[a-z]+)$")
|| CLASSES_TO_ALWAYS_DELEGATE.contains(name)
|| name.startsWith("java.")
|| name.startsWith("javax.")
|| name.startsWith("sun.")
|| name.startsWith("com.sun.")
|| name.startsWith("org.w3c.")
|| name.startsWith("org.xml.") | public boolean shouldAcquire(String name) {
// the org.robolectric.res package lives in the base classloader, but not its tests; yuck.
int lastDot = name.lastIndexOf('.');
String pkgName = name.substring(0, lastDot == -1 ? 0 : lastDot);
if (pkgName.equals("org.robolectric.res")) {
return name.contains("Test");
}
if (name.matches("com\\.android\\.internal\\.R(\\$.*)?")) return true;
// Android SDK code almost universally refers to com.android.internal.R, except
// when refering to android.R.stylable, as in HorizontalScrollView. arghgh.
// See https://github.com/robolectric/robolectric/issues/521
if (name.equals("android.R$styleable")) return true;
return !(
name.matches(".*\\.R(|\\$[a-z]+)$")
|| CLASSES_TO_ALWAYS_DELEGATE.contains(name)
|| name.startsWith("java.")
|| name.startsWith("javax.")
|| name.startsWith("sun.")
|| name.startsWith("com.sun.")
|| name.startsWith("org.w3c.")
|| name.startsWith("org.xml.")
|| name.startsWith("org.junit")
|| name.startsWith("org.hamcrest")
|| name.startsWith("org.specs2") // allows for android projects with mixed scala\java tests to be
|| name.startsWith("scala.") // run with Maven Surefire (see the RoboSpecs project on github)
|| name.startsWith("org.sqlite.") // ugh, we're barfing while loading org.sqlite now for some reason?!? todo: still?
);
} |
9,486 | 2 | // allows for android projects with mixed scala\java tests to be | public boolean shouldAcquire(String name) {
// the org.robolectric.res package lives in the base classloader, but not its tests; yuck.
int lastDot = name.lastIndexOf('.');
String pkgName = name.substring(0, lastDot == -1 ? 0 : lastDot);
if (pkgName.equals("org.robolectric.res")) {
return name.contains("Test");
}
if (name.matches("com\\.android\\.internal\\.R(\\$.*)?")) return true;
// Android SDK code almost universally refers to com.android.internal.R, except
// when refering to android.R.stylable, as in HorizontalScrollView. arghgh.
// See https://github.com/robolectric/robolectric/issues/521
if (name.equals("android.R$styleable")) return true;
return !(
name.matches(".*\\.R(|\\$[a-z]+)$")
|| CLASSES_TO_ALWAYS_DELEGATE.contains(name)
|| name.startsWith("java.")
|| name.startsWith("javax.")
|| name.startsWith("sun.")
|| name.startsWith("com.sun.")
|| name.startsWith("org.w3c.")
|| name.startsWith("org.xml.")
|| name.startsWith("org.junit")
|| name.startsWith("org.hamcrest")
|| name.startsWith("org.specs2") // allows for android projects with mixed scala\java tests to be
|| name.startsWith("scala.") // run with Maven Surefire (see the RoboSpecs project on github)
|| name.startsWith("org.sqlite.") // ugh, we're barfing while loading org.sqlite now for some reason?!? todo: still?
);
} | NONSATD | true | || name.startsWith("org.junit")
|| name.startsWith("org.hamcrest")
|| name.startsWith("org.specs2") // allows for android projects with mixed scala\java tests to be
|| name.startsWith("scala.") // run with Maven Surefire (see the RoboSpecs project on github)
|| name.startsWith("org.sqlite.") // ugh, we're barfing while loading org.sqlite now for some reason?!? todo: still? | name.matches(".*\\.R(|\\$[a-z]+)$")
|| CLASSES_TO_ALWAYS_DELEGATE.contains(name)
|| name.startsWith("java.")
|| name.startsWith("javax.")
|| name.startsWith("sun.")
|| name.startsWith("com.sun.")
|| name.startsWith("org.w3c.")
|| name.startsWith("org.xml.")
|| name.startsWith("org.junit")
|| name.startsWith("org.hamcrest")
|| name.startsWith("org.specs2") // allows for android projects with mixed scala\java tests to be
|| name.startsWith("scala.") // run with Maven Surefire (see the RoboSpecs project on github)
|| name.startsWith("org.sqlite.") // ugh, we're barfing while loading org.sqlite now for some reason?!? todo: still?
);
} | String pkgName = name.substring(0, lastDot == -1 ? 0 : lastDot);
if (pkgName.equals("org.robolectric.res")) {
return name.contains("Test");
}
if (name.matches("com\\.android\\.internal\\.R(\\$.*)?")) return true;
// Android SDK code almost universally refers to com.android.internal.R, except
// when refering to android.R.stylable, as in HorizontalScrollView. arghgh.
// See https://github.com/robolectric/robolectric/issues/521
if (name.equals("android.R$styleable")) return true;
return !(
name.matches(".*\\.R(|\\$[a-z]+)$")
|| CLASSES_TO_ALWAYS_DELEGATE.contains(name)
|| name.startsWith("java.")
|| name.startsWith("javax.")
|| name.startsWith("sun.")
|| name.startsWith("com.sun.")
|| name.startsWith("org.w3c.")
|| name.startsWith("org.xml.")
|| name.startsWith("org.junit")
|| name.startsWith("org.hamcrest")
|| name.startsWith("org.specs2") // allows for android projects with mixed scala\java tests to be
|| name.startsWith("scala.") // run with Maven Surefire (see the RoboSpecs project on github)
|| name.startsWith("org.sqlite.") // ugh, we're barfing while loading org.sqlite now for some reason?!? todo: still?
);
} |
9,486 | 3 | // run with Maven Surefire (see the RoboSpecs project on github) | public boolean shouldAcquire(String name) {
// the org.robolectric.res package lives in the base classloader, but not its tests; yuck.
int lastDot = name.lastIndexOf('.');
String pkgName = name.substring(0, lastDot == -1 ? 0 : lastDot);
if (pkgName.equals("org.robolectric.res")) {
return name.contains("Test");
}
if (name.matches("com\\.android\\.internal\\.R(\\$.*)?")) return true;
// Android SDK code almost universally refers to com.android.internal.R, except
// when refering to android.R.stylable, as in HorizontalScrollView. arghgh.
// See https://github.com/robolectric/robolectric/issues/521
if (name.equals("android.R$styleable")) return true;
return !(
name.matches(".*\\.R(|\\$[a-z]+)$")
|| CLASSES_TO_ALWAYS_DELEGATE.contains(name)
|| name.startsWith("java.")
|| name.startsWith("javax.")
|| name.startsWith("sun.")
|| name.startsWith("com.sun.")
|| name.startsWith("org.w3c.")
|| name.startsWith("org.xml.")
|| name.startsWith("org.junit")
|| name.startsWith("org.hamcrest")
|| name.startsWith("org.specs2") // allows for android projects with mixed scala\java tests to be
|| name.startsWith("scala.") // run with Maven Surefire (see the RoboSpecs project on github)
|| name.startsWith("org.sqlite.") // ugh, we're barfing while loading org.sqlite now for some reason?!? todo: still?
);
} | NONSATD | true | || name.startsWith("org.hamcrest")
|| name.startsWith("org.specs2") // allows for android projects with mixed scala\java tests to be
|| name.startsWith("scala.") // run with Maven Surefire (see the RoboSpecs project on github)
|| name.startsWith("org.sqlite.") // ugh, we're barfing while loading org.sqlite now for some reason?!? todo: still?
); | || CLASSES_TO_ALWAYS_DELEGATE.contains(name)
|| name.startsWith("java.")
|| name.startsWith("javax.")
|| name.startsWith("sun.")
|| name.startsWith("com.sun.")
|| name.startsWith("org.w3c.")
|| name.startsWith("org.xml.")
|| name.startsWith("org.junit")
|| name.startsWith("org.hamcrest")
|| name.startsWith("org.specs2") // allows for android projects with mixed scala\java tests to be
|| name.startsWith("scala.") // run with Maven Surefire (see the RoboSpecs project on github)
|| name.startsWith("org.sqlite.") // ugh, we're barfing while loading org.sqlite now for some reason?!? todo: still?
);
} | if (pkgName.equals("org.robolectric.res")) {
return name.contains("Test");
}
if (name.matches("com\\.android\\.internal\\.R(\\$.*)?")) return true;
// Android SDK code almost universally refers to com.android.internal.R, except
// when refering to android.R.stylable, as in HorizontalScrollView. arghgh.
// See https://github.com/robolectric/robolectric/issues/521
if (name.equals("android.R$styleable")) return true;
return !(
name.matches(".*\\.R(|\\$[a-z]+)$")
|| CLASSES_TO_ALWAYS_DELEGATE.contains(name)
|| name.startsWith("java.")
|| name.startsWith("javax.")
|| name.startsWith("sun.")
|| name.startsWith("com.sun.")
|| name.startsWith("org.w3c.")
|| name.startsWith("org.xml.")
|| name.startsWith("org.junit")
|| name.startsWith("org.hamcrest")
|| name.startsWith("org.specs2") // allows for android projects with mixed scala\java tests to be
|| name.startsWith("scala.") // run with Maven Surefire (see the RoboSpecs project on github)
|| name.startsWith("org.sqlite.") // ugh, we're barfing while loading org.sqlite now for some reason?!? todo: still?
);
} |
9,486 | 4 | // ugh, we're barfing while loading org.sqlite now for some reason?!? todo: still? | public boolean shouldAcquire(String name) {
// the org.robolectric.res package lives in the base classloader, but not its tests; yuck.
int lastDot = name.lastIndexOf('.');
String pkgName = name.substring(0, lastDot == -1 ? 0 : lastDot);
if (pkgName.equals("org.robolectric.res")) {
return name.contains("Test");
}
if (name.matches("com\\.android\\.internal\\.R(\\$.*)?")) return true;
// Android SDK code almost universally refers to com.android.internal.R, except
// when refering to android.R.stylable, as in HorizontalScrollView. arghgh.
// See https://github.com/robolectric/robolectric/issues/521
if (name.equals("android.R$styleable")) return true;
return !(
name.matches(".*\\.R(|\\$[a-z]+)$")
|| CLASSES_TO_ALWAYS_DELEGATE.contains(name)
|| name.startsWith("java.")
|| name.startsWith("javax.")
|| name.startsWith("sun.")
|| name.startsWith("com.sun.")
|| name.startsWith("org.w3c.")
|| name.startsWith("org.xml.")
|| name.startsWith("org.junit")
|| name.startsWith("org.hamcrest")
|| name.startsWith("org.specs2") // allows for android projects with mixed scala\java tests to be
|| name.startsWith("scala.") // run with Maven Surefire (see the RoboSpecs project on github)
|| name.startsWith("org.sqlite.") // ugh, we're barfing while loading org.sqlite now for some reason?!? todo: still?
);
} | DESIGN | true | || name.startsWith("org.specs2") // allows for android projects with mixed scala\java tests to be
|| name.startsWith("scala.") // run with Maven Surefire (see the RoboSpecs project on github)
|| name.startsWith("org.sqlite.") // ugh, we're barfing while loading org.sqlite now for some reason?!? todo: still?
);
} | || name.startsWith("java.")
|| name.startsWith("javax.")
|| name.startsWith("sun.")
|| name.startsWith("com.sun.")
|| name.startsWith("org.w3c.")
|| name.startsWith("org.xml.")
|| name.startsWith("org.junit")
|| name.startsWith("org.hamcrest")
|| name.startsWith("org.specs2") // allows for android projects with mixed scala\java tests to be
|| name.startsWith("scala.") // run with Maven Surefire (see the RoboSpecs project on github)
|| name.startsWith("org.sqlite.") // ugh, we're barfing while loading org.sqlite now for some reason?!? todo: still?
);
} | return name.contains("Test");
}
if (name.matches("com\\.android\\.internal\\.R(\\$.*)?")) return true;
// Android SDK code almost universally refers to com.android.internal.R, except
// when refering to android.R.stylable, as in HorizontalScrollView. arghgh.
// See https://github.com/robolectric/robolectric/issues/521
if (name.equals("android.R$styleable")) return true;
return !(
name.matches(".*\\.R(|\\$[a-z]+)$")
|| CLASSES_TO_ALWAYS_DELEGATE.contains(name)
|| name.startsWith("java.")
|| name.startsWith("javax.")
|| name.startsWith("sun.")
|| name.startsWith("com.sun.")
|| name.startsWith("org.w3c.")
|| name.startsWith("org.xml.")
|| name.startsWith("org.junit")
|| name.startsWith("org.hamcrest")
|| name.startsWith("org.specs2") // allows for android projects with mixed scala\java tests to be
|| name.startsWith("scala.") // run with Maven Surefire (see the RoboSpecs project on github)
|| name.startsWith("org.sqlite.") // ugh, we're barfing while loading org.sqlite now for some reason?!? todo: still?
);
} |
17,679 | 0 | /**
* Called when loading successfully finishes.
*/ | public void onFinished(JavaScriptObject jso) {
applFormItems.clear();
applFormItems.addAll(JsonUtils.<ApplicationFormItemWithPrefilledValue>jsoAsList(jso));
applFormGenerators.clear();
if (applFormItems == null || applFormItems.isEmpty()) {
// when there are no application form items
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + ApplicationMessages.INSTANCE.noFormDefined());
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
contents.setWidget(ft);
} else if (PerunEntity.VIRTUAL_ORGANIZATION.equals(entity) && "EXTENSION".equalsIgnoreCase(type) && Location.getParameter("targetexisting") != null) {
// FIXME - this is probably not good, since it prevents vo extension when targetexisting is specified.
if (Location.getParameter("targetexisting") != null) {
Location.replace(Location.getParameter("targetexisting"));
}
// when there are no application form items
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + ApplicationMessages.INSTANCE.alreadyVoMember());
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
contents.setWidget(ft);
} else {
// create application form
prepareApplicationForm();
}
session.getUiElements().setLogText("Loading " + type + " application form items in selected VO finished:" + applFormItems.size());
events.onFinished(jso);
loaderImage.loadingFinished();
} | NONSATD | true | public void onFinished(JavaScriptObject jso) {
applFormItems.clear();
applFormItems.addAll(JsonUtils.<ApplicationFormItemWithPrefilledValue>jsoAsList(jso));
applFormGenerators.clear();
if (applFormItems == null || applFormItems.isEmpty()) {
// when there are no application form items
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + ApplicationMessages.INSTANCE.noFormDefined());
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
contents.setWidget(ft);
} else if (PerunEntity.VIRTUAL_ORGANIZATION.equals(entity) && "EXTENSION".equalsIgnoreCase(type) && Location.getParameter("targetexisting") != null) {
// FIXME - this is probably not good, since it prevents vo extension when targetexisting is specified.
if (Location.getParameter("targetexisting") != null) {
Location.replace(Location.getParameter("targetexisting"));
}
// when there are no application form items
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + ApplicationMessages.INSTANCE.alreadyVoMember());
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
contents.setWidget(ft);
} else {
// create application form
prepareApplicationForm();
}
session.getUiElements().setLogText("Loading " + type + " application form items in selected VO finished:" + applFormItems.size());
events.onFinished(jso);
loaderImage.loadingFinished();
} | public void onFinished(JavaScriptObject jso) {
applFormItems.clear();
applFormItems.addAll(JsonUtils.<ApplicationFormItemWithPrefilledValue>jsoAsList(jso));
applFormGenerators.clear();
if (applFormItems == null || applFormItems.isEmpty()) {
// when there are no application form items
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + ApplicationMessages.INSTANCE.noFormDefined());
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
contents.setWidget(ft);
} else if (PerunEntity.VIRTUAL_ORGANIZATION.equals(entity) && "EXTENSION".equalsIgnoreCase(type) && Location.getParameter("targetexisting") != null) {
// FIXME - this is probably not good, since it prevents vo extension when targetexisting is specified.
if (Location.getParameter("targetexisting") != null) {
Location.replace(Location.getParameter("targetexisting"));
}
// when there are no application form items
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + ApplicationMessages.INSTANCE.alreadyVoMember());
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
contents.setWidget(ft);
} else {
// create application form
prepareApplicationForm();
}
session.getUiElements().setLogText("Loading " + type + " application form items in selected VO finished:" + applFormItems.size());
events.onFinished(jso);
loaderImage.loadingFinished();
} | public void onFinished(JavaScriptObject jso) {
applFormItems.clear();
applFormItems.addAll(JsonUtils.<ApplicationFormItemWithPrefilledValue>jsoAsList(jso));
applFormGenerators.clear();
if (applFormItems == null || applFormItems.isEmpty()) {
// when there are no application form items
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + ApplicationMessages.INSTANCE.noFormDefined());
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
contents.setWidget(ft);
} else if (PerunEntity.VIRTUAL_ORGANIZATION.equals(entity) && "EXTENSION".equalsIgnoreCase(type) && Location.getParameter("targetexisting") != null) {
// FIXME - this is probably not good, since it prevents vo extension when targetexisting is specified.
if (Location.getParameter("targetexisting") != null) {
Location.replace(Location.getParameter("targetexisting"));
}
// when there are no application form items
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + ApplicationMessages.INSTANCE.alreadyVoMember());
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
contents.setWidget(ft);
} else {
// create application form
prepareApplicationForm();
}
session.getUiElements().setLogText("Loading " + type + " application form items in selected VO finished:" + applFormItems.size());
events.onFinished(jso);
loaderImage.loadingFinished();
} |
17,679 | 1 | // when there are no application form items | public void onFinished(JavaScriptObject jso) {
applFormItems.clear();
applFormItems.addAll(JsonUtils.<ApplicationFormItemWithPrefilledValue>jsoAsList(jso));
applFormGenerators.clear();
if (applFormItems == null || applFormItems.isEmpty()) {
// when there are no application form items
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + ApplicationMessages.INSTANCE.noFormDefined());
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
contents.setWidget(ft);
} else if (PerunEntity.VIRTUAL_ORGANIZATION.equals(entity) && "EXTENSION".equalsIgnoreCase(type) && Location.getParameter("targetexisting") != null) {
// FIXME - this is probably not good, since it prevents vo extension when targetexisting is specified.
if (Location.getParameter("targetexisting") != null) {
Location.replace(Location.getParameter("targetexisting"));
}
// when there are no application form items
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + ApplicationMessages.INSTANCE.alreadyVoMember());
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
contents.setWidget(ft);
} else {
// create application form
prepareApplicationForm();
}
session.getUiElements().setLogText("Loading " + type + " application form items in selected VO finished:" + applFormItems.size());
events.onFinished(jso);
loaderImage.loadingFinished();
} | NONSATD | true | applFormGenerators.clear();
if (applFormItems == null || applFormItems.isEmpty()) {
// when there are no application form items
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px"); | public void onFinished(JavaScriptObject jso) {
applFormItems.clear();
applFormItems.addAll(JsonUtils.<ApplicationFormItemWithPrefilledValue>jsoAsList(jso));
applFormGenerators.clear();
if (applFormItems == null || applFormItems.isEmpty()) {
// when there are no application form items
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + ApplicationMessages.INSTANCE.noFormDefined());
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
contents.setWidget(ft);
} else if (PerunEntity.VIRTUAL_ORGANIZATION.equals(entity) && "EXTENSION".equalsIgnoreCase(type) && Location.getParameter("targetexisting") != null) {
// FIXME - this is probably not good, since it prevents vo extension when targetexisting is specified.
if (Location.getParameter("targetexisting") != null) {
Location.replace(Location.getParameter("targetexisting")); | public void onFinished(JavaScriptObject jso) {
applFormItems.clear();
applFormItems.addAll(JsonUtils.<ApplicationFormItemWithPrefilledValue>jsoAsList(jso));
applFormGenerators.clear();
if (applFormItems == null || applFormItems.isEmpty()) {
// when there are no application form items
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + ApplicationMessages.INSTANCE.noFormDefined());
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
contents.setWidget(ft);
} else if (PerunEntity.VIRTUAL_ORGANIZATION.equals(entity) && "EXTENSION".equalsIgnoreCase(type) && Location.getParameter("targetexisting") != null) {
// FIXME - this is probably not good, since it prevents vo extension when targetexisting is specified.
if (Location.getParameter("targetexisting") != null) {
Location.replace(Location.getParameter("targetexisting"));
}
// when there are no application form items
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + ApplicationMessages.INSTANCE.alreadyVoMember());
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
contents.setWidget(ft);
} else {
// create application form |
17,679 | 2 | // FIXME - this is probably not good, since it prevents vo extension when targetexisting is specified. | public void onFinished(JavaScriptObject jso) {
applFormItems.clear();
applFormItems.addAll(JsonUtils.<ApplicationFormItemWithPrefilledValue>jsoAsList(jso));
applFormGenerators.clear();
if (applFormItems == null || applFormItems.isEmpty()) {
// when there are no application form items
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + ApplicationMessages.INSTANCE.noFormDefined());
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
contents.setWidget(ft);
} else if (PerunEntity.VIRTUAL_ORGANIZATION.equals(entity) && "EXTENSION".equalsIgnoreCase(type) && Location.getParameter("targetexisting") != null) {
// FIXME - this is probably not good, since it prevents vo extension when targetexisting is specified.
if (Location.getParameter("targetexisting") != null) {
Location.replace(Location.getParameter("targetexisting"));
}
// when there are no application form items
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + ApplicationMessages.INSTANCE.alreadyVoMember());
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
contents.setWidget(ft);
} else {
// create application form
prepareApplicationForm();
}
session.getUiElements().setLogText("Loading " + type + " application form items in selected VO finished:" + applFormItems.size());
events.onFinished(jso);
loaderImage.loadingFinished();
} | DEFECT | true | contents.setWidget(ft);
} else if (PerunEntity.VIRTUAL_ORGANIZATION.equals(entity) && "EXTENSION".equalsIgnoreCase(type) && Location.getParameter("targetexisting") != null) {
// FIXME - this is probably not good, since it prevents vo extension when targetexisting is specified.
if (Location.getParameter("targetexisting") != null) {
Location.replace(Location.getParameter("targetexisting")); | applFormGenerators.clear();
if (applFormItems == null || applFormItems.isEmpty()) {
// when there are no application form items
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + ApplicationMessages.INSTANCE.noFormDefined());
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
contents.setWidget(ft);
} else if (PerunEntity.VIRTUAL_ORGANIZATION.equals(entity) && "EXTENSION".equalsIgnoreCase(type) && Location.getParameter("targetexisting") != null) {
// FIXME - this is probably not good, since it prevents vo extension when targetexisting is specified.
if (Location.getParameter("targetexisting") != null) {
Location.replace(Location.getParameter("targetexisting"));
}
// when there are no application form items
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + ApplicationMessages.INSTANCE.alreadyVoMember());
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
contents.setWidget(ft); | public void onFinished(JavaScriptObject jso) {
applFormItems.clear();
applFormItems.addAll(JsonUtils.<ApplicationFormItemWithPrefilledValue>jsoAsList(jso));
applFormGenerators.clear();
if (applFormItems == null || applFormItems.isEmpty()) {
// when there are no application form items
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + ApplicationMessages.INSTANCE.noFormDefined());
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
contents.setWidget(ft);
} else if (PerunEntity.VIRTUAL_ORGANIZATION.equals(entity) && "EXTENSION".equalsIgnoreCase(type) && Location.getParameter("targetexisting") != null) {
// FIXME - this is probably not good, since it prevents vo extension when targetexisting is specified.
if (Location.getParameter("targetexisting") != null) {
Location.replace(Location.getParameter("targetexisting"));
}
// when there are no application form items
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + ApplicationMessages.INSTANCE.alreadyVoMember());
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
contents.setWidget(ft);
} else {
// create application form
prepareApplicationForm();
}
session.getUiElements().setLogText("Loading " + type + " application form items in selected VO finished:" + applFormItems.size());
events.onFinished(jso);
loaderImage.loadingFinished();
} |
17,679 | 3 | // when there are no application form items | public void onFinished(JavaScriptObject jso) {
applFormItems.clear();
applFormItems.addAll(JsonUtils.<ApplicationFormItemWithPrefilledValue>jsoAsList(jso));
applFormGenerators.clear();
if (applFormItems == null || applFormItems.isEmpty()) {
// when there are no application form items
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + ApplicationMessages.INSTANCE.noFormDefined());
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
contents.setWidget(ft);
} else if (PerunEntity.VIRTUAL_ORGANIZATION.equals(entity) && "EXTENSION".equalsIgnoreCase(type) && Location.getParameter("targetexisting") != null) {
// FIXME - this is probably not good, since it prevents vo extension when targetexisting is specified.
if (Location.getParameter("targetexisting") != null) {
Location.replace(Location.getParameter("targetexisting"));
}
// when there are no application form items
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + ApplicationMessages.INSTANCE.alreadyVoMember());
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
contents.setWidget(ft);
} else {
// create application form
prepareApplicationForm();
}
session.getUiElements().setLogText("Loading " + type + " application form items in selected VO finished:" + applFormItems.size());
events.onFinished(jso);
loaderImage.loadingFinished();
} | NONSATD | true | applFormGenerators.clear();
if (applFormItems == null || applFormItems.isEmpty()) {
// when there are no application form items
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px"); | public void onFinished(JavaScriptObject jso) {
applFormItems.clear();
applFormItems.addAll(JsonUtils.<ApplicationFormItemWithPrefilledValue>jsoAsList(jso));
applFormGenerators.clear();
if (applFormItems == null || applFormItems.isEmpty()) {
// when there are no application form items
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + ApplicationMessages.INSTANCE.noFormDefined());
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
contents.setWidget(ft);
} else if (PerunEntity.VIRTUAL_ORGANIZATION.equals(entity) && "EXTENSION".equalsIgnoreCase(type) && Location.getParameter("targetexisting") != null) {
// FIXME - this is probably not good, since it prevents vo extension when targetexisting is specified.
if (Location.getParameter("targetexisting") != null) {
Location.replace(Location.getParameter("targetexisting")); | public void onFinished(JavaScriptObject jso) {
applFormItems.clear();
applFormItems.addAll(JsonUtils.<ApplicationFormItemWithPrefilledValue>jsoAsList(jso));
applFormGenerators.clear();
if (applFormItems == null || applFormItems.isEmpty()) {
// when there are no application form items
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + ApplicationMessages.INSTANCE.noFormDefined());
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
contents.setWidget(ft);
} else if (PerunEntity.VIRTUAL_ORGANIZATION.equals(entity) && "EXTENSION".equalsIgnoreCase(type) && Location.getParameter("targetexisting") != null) {
// FIXME - this is probably not good, since it prevents vo extension when targetexisting is specified.
if (Location.getParameter("targetexisting") != null) {
Location.replace(Location.getParameter("targetexisting"));
}
// when there are no application form items
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + ApplicationMessages.INSTANCE.alreadyVoMember());
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
contents.setWidget(ft);
} else {
// create application form |
17,679 | 4 | // create application form | public void onFinished(JavaScriptObject jso) {
applFormItems.clear();
applFormItems.addAll(JsonUtils.<ApplicationFormItemWithPrefilledValue>jsoAsList(jso));
applFormGenerators.clear();
if (applFormItems == null || applFormItems.isEmpty()) {
// when there are no application form items
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + ApplicationMessages.INSTANCE.noFormDefined());
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
contents.setWidget(ft);
} else if (PerunEntity.VIRTUAL_ORGANIZATION.equals(entity) && "EXTENSION".equalsIgnoreCase(type) && Location.getParameter("targetexisting") != null) {
// FIXME - this is probably not good, since it prevents vo extension when targetexisting is specified.
if (Location.getParameter("targetexisting") != null) {
Location.replace(Location.getParameter("targetexisting"));
}
// when there are no application form items
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + ApplicationMessages.INSTANCE.alreadyVoMember());
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
contents.setWidget(ft);
} else {
// create application form
prepareApplicationForm();
}
session.getUiElements().setLogText("Loading " + type + " application form items in selected VO finished:" + applFormItems.size());
events.onFinished(jso);
loaderImage.loadingFinished();
} | NONSATD | true | contents.setWidget(ft);
} else {
// create application form
prepareApplicationForm();
} | Location.replace(Location.getParameter("targetexisting"));
}
// when there are no application form items
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + ApplicationMessages.INSTANCE.alreadyVoMember());
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
contents.setWidget(ft);
} else {
// create application form
prepareApplicationForm();
}
session.getUiElements().setLogText("Loading " + type + " application form items in selected VO finished:" + applFormItems.size());
events.onFinished(jso);
loaderImage.loadingFinished();
} | // when there are no application form items
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + ApplicationMessages.INSTANCE.noFormDefined());
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
contents.setWidget(ft);
} else if (PerunEntity.VIRTUAL_ORGANIZATION.equals(entity) && "EXTENSION".equalsIgnoreCase(type) && Location.getParameter("targetexisting") != null) {
// FIXME - this is probably not good, since it prevents vo extension when targetexisting is specified.
if (Location.getParameter("targetexisting") != null) {
Location.replace(Location.getParameter("targetexisting"));
}
// when there are no application form items
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + ApplicationMessages.INSTANCE.alreadyVoMember());
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
contents.setWidget(ft);
} else {
// create application form
prepareApplicationForm();
}
session.getUiElements().setLogText("Loading " + type + " application form items in selected VO finished:" + applFormItems.size());
events.onFinished(jso);
loaderImage.loadingFinished();
} |
9,490 | 0 | // This method takes a reference to the head of a linked list.
// It returns the reference to the head of the linked list in the reversed order. | public LNode reverseListRec(LNode head)
{
// TODO: implement this method
/*This method takes a reference to the head of a linked list and returns
the reference to the head of the linked list in the reversed order. */
if(head == null) { return head; }
if(head.getLink() == null) { return head; }
head.getLink().setLink(head);
head.setLink(null);
return reverseListRec(head);
// replace this statement with your own return
} | NONSATD | true | public LNode reverseListRec(LNode head)
{
// TODO: implement this method
/*This method takes a reference to the head of a linked list and returns
the reference to the head of the linked list in the reversed order. */
if(head == null) { return head; }
if(head.getLink() == null) { return head; }
head.getLink().setLink(head);
head.setLink(null);
return reverseListRec(head);
// replace this statement with your own return
} | public LNode reverseListRec(LNode head)
{
// TODO: implement this method
/*This method takes a reference to the head of a linked list and returns
the reference to the head of the linked list in the reversed order. */
if(head == null) { return head; }
if(head.getLink() == null) { return head; }
head.getLink().setLink(head);
head.setLink(null);
return reverseListRec(head);
// replace this statement with your own return
} | public LNode reverseListRec(LNode head)
{
// TODO: implement this method
/*This method takes a reference to the head of a linked list and returns
the reference to the head of the linked list in the reversed order. */
if(head == null) { return head; }
if(head.getLink() == null) { return head; }
head.getLink().setLink(head);
head.setLink(null);
return reverseListRec(head);
// replace this statement with your own return
} |
9,490 | 1 | // TODO: implement this method
/*This method takes a reference to the head of a linked list and returns
the reference to the head of the linked list in the reversed order. */ | public LNode reverseListRec(LNode head)
{
// TODO: implement this method
/*This method takes a reference to the head of a linked list and returns
the reference to the head of the linked list in the reversed order. */
if(head == null) { return head; }
if(head.getLink() == null) { return head; }
head.getLink().setLink(head);
head.setLink(null);
return reverseListRec(head);
// replace this statement with your own return
} | IMPLEMENTATION | true | public LNode reverseListRec(LNode head)
{
// TODO: implement this method
/*This method takes a reference to the head of a linked list and returns
the reference to the head of the linked list in the reversed order. */
if(head == null) { return head; }
if(head.getLink() == null) { return head; } | public LNode reverseListRec(LNode head)
{
// TODO: implement this method
/*This method takes a reference to the head of a linked list and returns
the reference to the head of the linked list in the reversed order. */
if(head == null) { return head; }
if(head.getLink() == null) { return head; }
head.getLink().setLink(head);
head.setLink(null);
return reverseListRec(head);
// replace this statement with your own return
} | public LNode reverseListRec(LNode head)
{
// TODO: implement this method
/*This method takes a reference to the head of a linked list and returns
the reference to the head of the linked list in the reversed order. */
if(head == null) { return head; }
if(head.getLink() == null) { return head; }
head.getLink().setLink(head);
head.setLink(null);
return reverseListRec(head);
// replace this statement with your own return
} |
9,490 | 2 | // replace this statement with your own return | public LNode reverseListRec(LNode head)
{
// TODO: implement this method
/*This method takes a reference to the head of a linked list and returns
the reference to the head of the linked list in the reversed order. */
if(head == null) { return head; }
if(head.getLink() == null) { return head; }
head.getLink().setLink(head);
head.setLink(null);
return reverseListRec(head);
// replace this statement with your own return
} | IMPLEMENTATION | true | head.setLink(null);
return reverseListRec(head);
// replace this statement with your own return
} | public LNode reverseListRec(LNode head)
{
// TODO: implement this method
/*This method takes a reference to the head of a linked list and returns
the reference to the head of the linked list in the reversed order. */
if(head == null) { return head; }
if(head.getLink() == null) { return head; }
head.getLink().setLink(head);
head.setLink(null);
return reverseListRec(head);
// replace this statement with your own return
} | public LNode reverseListRec(LNode head)
{
// TODO: implement this method
/*This method takes a reference to the head of a linked list and returns
the reference to the head of the linked list in the reversed order. */
if(head == null) { return head; }
if(head.getLink() == null) { return head; }
head.getLink().setLink(head);
head.setLink(null);
return reverseListRec(head);
// replace this statement with your own return
} |
17,706 | 0 | /**
* Method to drive the robot using joystick info.
*
* @param xSpeed Speed of the robot in the x direction (forward).
* @param ySpeed Speed of the robot in the y direction (sideways).
* @param rot Angular rate of the robot.
* @param fieldRelative Whether the provided x and y speeds are relative to the
* field.
*/ | @SuppressWarnings("ParameterName")
public void drive(double xSpeed, double ySpeed, double rot, boolean fieldRelative) {
// ask the kinematics to determine our swerve command
ChassisSpeeds speeds;
if (fieldRelative == true) {
speeds = ChassisSpeeds.fromFieldRelativeSpeeds(xSpeed, ySpeed, rot, getHeading());
} else {
speeds = new ChassisSpeeds(xSpeed, ySpeed, rot);
}
SwerveModuleState[] swerveModuleStates = kinematics.toSwerveModuleStates(speeds);
// sometime the Kinematics spits out too fast of speeds, so this will fix this
SwerveDriveKinematics.desaturateWheelSpeeds(swerveModuleStates, kMaxSpeed);
// command each swerve module
for (int i = 0; i < modules.length; i++) {
modules[i].setDesiredState(swerveModuleStates[i]);
}
// report our commands to the dashboard
SmartDashboard.putNumber("SwerveDrive/xSpeed", xSpeed);
SmartDashboard.putNumber("SwerveDrive/ySpeed", ySpeed);
SmartDashboard.putNumber("SwerveDrive/rot", rot);
SmartDashboard.putBoolean("SwerveDrive/fieldRelative", fieldRelative);
} | NONSATD | true | @SuppressWarnings("ParameterName")
public void drive(double xSpeed, double ySpeed, double rot, boolean fieldRelative) {
// ask the kinematics to determine our swerve command
ChassisSpeeds speeds;
if (fieldRelative == true) {
speeds = ChassisSpeeds.fromFieldRelativeSpeeds(xSpeed, ySpeed, rot, getHeading());
} else {
speeds = new ChassisSpeeds(xSpeed, ySpeed, rot);
}
SwerveModuleState[] swerveModuleStates = kinematics.toSwerveModuleStates(speeds);
// sometime the Kinematics spits out too fast of speeds, so this will fix this
SwerveDriveKinematics.desaturateWheelSpeeds(swerveModuleStates, kMaxSpeed);
// command each swerve module
for (int i = 0; i < modules.length; i++) {
modules[i].setDesiredState(swerveModuleStates[i]);
}
// report our commands to the dashboard
SmartDashboard.putNumber("SwerveDrive/xSpeed", xSpeed);
SmartDashboard.putNumber("SwerveDrive/ySpeed", ySpeed);
SmartDashboard.putNumber("SwerveDrive/rot", rot);
SmartDashboard.putBoolean("SwerveDrive/fieldRelative", fieldRelative);
} | @SuppressWarnings("ParameterName")
public void drive(double xSpeed, double ySpeed, double rot, boolean fieldRelative) {
// ask the kinematics to determine our swerve command
ChassisSpeeds speeds;
if (fieldRelative == true) {
speeds = ChassisSpeeds.fromFieldRelativeSpeeds(xSpeed, ySpeed, rot, getHeading());
} else {
speeds = new ChassisSpeeds(xSpeed, ySpeed, rot);
}
SwerveModuleState[] swerveModuleStates = kinematics.toSwerveModuleStates(speeds);
// sometime the Kinematics spits out too fast of speeds, so this will fix this
SwerveDriveKinematics.desaturateWheelSpeeds(swerveModuleStates, kMaxSpeed);
// command each swerve module
for (int i = 0; i < modules.length; i++) {
modules[i].setDesiredState(swerveModuleStates[i]);
}
// report our commands to the dashboard
SmartDashboard.putNumber("SwerveDrive/xSpeed", xSpeed);
SmartDashboard.putNumber("SwerveDrive/ySpeed", ySpeed);
SmartDashboard.putNumber("SwerveDrive/rot", rot);
SmartDashboard.putBoolean("SwerveDrive/fieldRelative", fieldRelative);
} | @SuppressWarnings("ParameterName")
public void drive(double xSpeed, double ySpeed, double rot, boolean fieldRelative) {
// ask the kinematics to determine our swerve command
ChassisSpeeds speeds;
if (fieldRelative == true) {
speeds = ChassisSpeeds.fromFieldRelativeSpeeds(xSpeed, ySpeed, rot, getHeading());
} else {
speeds = new ChassisSpeeds(xSpeed, ySpeed, rot);
}
SwerveModuleState[] swerveModuleStates = kinematics.toSwerveModuleStates(speeds);
// sometime the Kinematics spits out too fast of speeds, so this will fix this
SwerveDriveKinematics.desaturateWheelSpeeds(swerveModuleStates, kMaxSpeed);
// command each swerve module
for (int i = 0; i < modules.length; i++) {
modules[i].setDesiredState(swerveModuleStates[i]);
}
// report our commands to the dashboard
SmartDashboard.putNumber("SwerveDrive/xSpeed", xSpeed);
SmartDashboard.putNumber("SwerveDrive/ySpeed", ySpeed);
SmartDashboard.putNumber("SwerveDrive/rot", rot);
SmartDashboard.putBoolean("SwerveDrive/fieldRelative", fieldRelative);
} |
17,706 | 1 | // ask the kinematics to determine our swerve command | @SuppressWarnings("ParameterName")
public void drive(double xSpeed, double ySpeed, double rot, boolean fieldRelative) {
// ask the kinematics to determine our swerve command
ChassisSpeeds speeds;
if (fieldRelative == true) {
speeds = ChassisSpeeds.fromFieldRelativeSpeeds(xSpeed, ySpeed, rot, getHeading());
} else {
speeds = new ChassisSpeeds(xSpeed, ySpeed, rot);
}
SwerveModuleState[] swerveModuleStates = kinematics.toSwerveModuleStates(speeds);
// sometime the Kinematics spits out too fast of speeds, so this will fix this
SwerveDriveKinematics.desaturateWheelSpeeds(swerveModuleStates, kMaxSpeed);
// command each swerve module
for (int i = 0; i < modules.length; i++) {
modules[i].setDesiredState(swerveModuleStates[i]);
}
// report our commands to the dashboard
SmartDashboard.putNumber("SwerveDrive/xSpeed", xSpeed);
SmartDashboard.putNumber("SwerveDrive/ySpeed", ySpeed);
SmartDashboard.putNumber("SwerveDrive/rot", rot);
SmartDashboard.putBoolean("SwerveDrive/fieldRelative", fieldRelative);
} | NONSATD | true | @SuppressWarnings("ParameterName")
public void drive(double xSpeed, double ySpeed, double rot, boolean fieldRelative) {
// ask the kinematics to determine our swerve command
ChassisSpeeds speeds;
if (fieldRelative == true) { | @SuppressWarnings("ParameterName")
public void drive(double xSpeed, double ySpeed, double rot, boolean fieldRelative) {
// ask the kinematics to determine our swerve command
ChassisSpeeds speeds;
if (fieldRelative == true) {
speeds = ChassisSpeeds.fromFieldRelativeSpeeds(xSpeed, ySpeed, rot, getHeading());
} else {
speeds = new ChassisSpeeds(xSpeed, ySpeed, rot);
}
SwerveModuleState[] swerveModuleStates = kinematics.toSwerveModuleStates(speeds);
// sometime the Kinematics spits out too fast of speeds, so this will fix this
SwerveDriveKinematics.desaturateWheelSpeeds(swerveModuleStates, kMaxSpeed);
// command each swerve module | @SuppressWarnings("ParameterName")
public void drive(double xSpeed, double ySpeed, double rot, boolean fieldRelative) {
// ask the kinematics to determine our swerve command
ChassisSpeeds speeds;
if (fieldRelative == true) {
speeds = ChassisSpeeds.fromFieldRelativeSpeeds(xSpeed, ySpeed, rot, getHeading());
} else {
speeds = new ChassisSpeeds(xSpeed, ySpeed, rot);
}
SwerveModuleState[] swerveModuleStates = kinematics.toSwerveModuleStates(speeds);
// sometime the Kinematics spits out too fast of speeds, so this will fix this
SwerveDriveKinematics.desaturateWheelSpeeds(swerveModuleStates, kMaxSpeed);
// command each swerve module
for (int i = 0; i < modules.length; i++) {
modules[i].setDesiredState(swerveModuleStates[i]);
}
// report our commands to the dashboard
SmartDashboard.putNumber("SwerveDrive/xSpeed", xSpeed);
SmartDashboard.putNumber("SwerveDrive/ySpeed", ySpeed);
SmartDashboard.putNumber("SwerveDrive/rot", rot);
SmartDashboard.putBoolean("SwerveDrive/fieldRelative", fieldRelative);
} |
17,706 | 2 | // sometime the Kinematics spits out too fast of speeds, so this will fix this | @SuppressWarnings("ParameterName")
public void drive(double xSpeed, double ySpeed, double rot, boolean fieldRelative) {
// ask the kinematics to determine our swerve command
ChassisSpeeds speeds;
if (fieldRelative == true) {
speeds = ChassisSpeeds.fromFieldRelativeSpeeds(xSpeed, ySpeed, rot, getHeading());
} else {
speeds = new ChassisSpeeds(xSpeed, ySpeed, rot);
}
SwerveModuleState[] swerveModuleStates = kinematics.toSwerveModuleStates(speeds);
// sometime the Kinematics spits out too fast of speeds, so this will fix this
SwerveDriveKinematics.desaturateWheelSpeeds(swerveModuleStates, kMaxSpeed);
// command each swerve module
for (int i = 0; i < modules.length; i++) {
modules[i].setDesiredState(swerveModuleStates[i]);
}
// report our commands to the dashboard
SmartDashboard.putNumber("SwerveDrive/xSpeed", xSpeed);
SmartDashboard.putNumber("SwerveDrive/ySpeed", ySpeed);
SmartDashboard.putNumber("SwerveDrive/rot", rot);
SmartDashboard.putBoolean("SwerveDrive/fieldRelative", fieldRelative);
} | NONSATD | true | }
SwerveModuleState[] swerveModuleStates = kinematics.toSwerveModuleStates(speeds);
// sometime the Kinematics spits out too fast of speeds, so this will fix this
SwerveDriveKinematics.desaturateWheelSpeeds(swerveModuleStates, kMaxSpeed);
// command each swerve module | @SuppressWarnings("ParameterName")
public void drive(double xSpeed, double ySpeed, double rot, boolean fieldRelative) {
// ask the kinematics to determine our swerve command
ChassisSpeeds speeds;
if (fieldRelative == true) {
speeds = ChassisSpeeds.fromFieldRelativeSpeeds(xSpeed, ySpeed, rot, getHeading());
} else {
speeds = new ChassisSpeeds(xSpeed, ySpeed, rot);
}
SwerveModuleState[] swerveModuleStates = kinematics.toSwerveModuleStates(speeds);
// sometime the Kinematics spits out too fast of speeds, so this will fix this
SwerveDriveKinematics.desaturateWheelSpeeds(swerveModuleStates, kMaxSpeed);
// command each swerve module
for (int i = 0; i < modules.length; i++) {
modules[i].setDesiredState(swerveModuleStates[i]);
}
// report our commands to the dashboard
SmartDashboard.putNumber("SwerveDrive/xSpeed", xSpeed);
SmartDashboard.putNumber("SwerveDrive/ySpeed", ySpeed);
SmartDashboard.putNumber("SwerveDrive/rot", rot);
SmartDashboard.putBoolean("SwerveDrive/fieldRelative", fieldRelative); | @SuppressWarnings("ParameterName")
public void drive(double xSpeed, double ySpeed, double rot, boolean fieldRelative) {
// ask the kinematics to determine our swerve command
ChassisSpeeds speeds;
if (fieldRelative == true) {
speeds = ChassisSpeeds.fromFieldRelativeSpeeds(xSpeed, ySpeed, rot, getHeading());
} else {
speeds = new ChassisSpeeds(xSpeed, ySpeed, rot);
}
SwerveModuleState[] swerveModuleStates = kinematics.toSwerveModuleStates(speeds);
// sometime the Kinematics spits out too fast of speeds, so this will fix this
SwerveDriveKinematics.desaturateWheelSpeeds(swerveModuleStates, kMaxSpeed);
// command each swerve module
for (int i = 0; i < modules.length; i++) {
modules[i].setDesiredState(swerveModuleStates[i]);
}
// report our commands to the dashboard
SmartDashboard.putNumber("SwerveDrive/xSpeed", xSpeed);
SmartDashboard.putNumber("SwerveDrive/ySpeed", ySpeed);
SmartDashboard.putNumber("SwerveDrive/rot", rot);
SmartDashboard.putBoolean("SwerveDrive/fieldRelative", fieldRelative);
} |
17,706 | 3 | // command each swerve module | @SuppressWarnings("ParameterName")
public void drive(double xSpeed, double ySpeed, double rot, boolean fieldRelative) {
// ask the kinematics to determine our swerve command
ChassisSpeeds speeds;
if (fieldRelative == true) {
speeds = ChassisSpeeds.fromFieldRelativeSpeeds(xSpeed, ySpeed, rot, getHeading());
} else {
speeds = new ChassisSpeeds(xSpeed, ySpeed, rot);
}
SwerveModuleState[] swerveModuleStates = kinematics.toSwerveModuleStates(speeds);
// sometime the Kinematics spits out too fast of speeds, so this will fix this
SwerveDriveKinematics.desaturateWheelSpeeds(swerveModuleStates, kMaxSpeed);
// command each swerve module
for (int i = 0; i < modules.length; i++) {
modules[i].setDesiredState(swerveModuleStates[i]);
}
// report our commands to the dashboard
SmartDashboard.putNumber("SwerveDrive/xSpeed", xSpeed);
SmartDashboard.putNumber("SwerveDrive/ySpeed", ySpeed);
SmartDashboard.putNumber("SwerveDrive/rot", rot);
SmartDashboard.putBoolean("SwerveDrive/fieldRelative", fieldRelative);
} | NONSATD | true | // sometime the Kinematics spits out too fast of speeds, so this will fix this
SwerveDriveKinematics.desaturateWheelSpeeds(swerveModuleStates, kMaxSpeed);
// command each swerve module
for (int i = 0; i < modules.length; i++) {
modules[i].setDesiredState(swerveModuleStates[i]); | // ask the kinematics to determine our swerve command
ChassisSpeeds speeds;
if (fieldRelative == true) {
speeds = ChassisSpeeds.fromFieldRelativeSpeeds(xSpeed, ySpeed, rot, getHeading());
} else {
speeds = new ChassisSpeeds(xSpeed, ySpeed, rot);
}
SwerveModuleState[] swerveModuleStates = kinematics.toSwerveModuleStates(speeds);
// sometime the Kinematics spits out too fast of speeds, so this will fix this
SwerveDriveKinematics.desaturateWheelSpeeds(swerveModuleStates, kMaxSpeed);
// command each swerve module
for (int i = 0; i < modules.length; i++) {
modules[i].setDesiredState(swerveModuleStates[i]);
}
// report our commands to the dashboard
SmartDashboard.putNumber("SwerveDrive/xSpeed", xSpeed);
SmartDashboard.putNumber("SwerveDrive/ySpeed", ySpeed);
SmartDashboard.putNumber("SwerveDrive/rot", rot);
SmartDashboard.putBoolean("SwerveDrive/fieldRelative", fieldRelative);
} | @SuppressWarnings("ParameterName")
public void drive(double xSpeed, double ySpeed, double rot, boolean fieldRelative) {
// ask the kinematics to determine our swerve command
ChassisSpeeds speeds;
if (fieldRelative == true) {
speeds = ChassisSpeeds.fromFieldRelativeSpeeds(xSpeed, ySpeed, rot, getHeading());
} else {
speeds = new ChassisSpeeds(xSpeed, ySpeed, rot);
}
SwerveModuleState[] swerveModuleStates = kinematics.toSwerveModuleStates(speeds);
// sometime the Kinematics spits out too fast of speeds, so this will fix this
SwerveDriveKinematics.desaturateWheelSpeeds(swerveModuleStates, kMaxSpeed);
// command each swerve module
for (int i = 0; i < modules.length; i++) {
modules[i].setDesiredState(swerveModuleStates[i]);
}
// report our commands to the dashboard
SmartDashboard.putNumber("SwerveDrive/xSpeed", xSpeed);
SmartDashboard.putNumber("SwerveDrive/ySpeed", ySpeed);
SmartDashboard.putNumber("SwerveDrive/rot", rot);
SmartDashboard.putBoolean("SwerveDrive/fieldRelative", fieldRelative);
} |
17,706 | 4 | // report our commands to the dashboard | @SuppressWarnings("ParameterName")
public void drive(double xSpeed, double ySpeed, double rot, boolean fieldRelative) {
// ask the kinematics to determine our swerve command
ChassisSpeeds speeds;
if (fieldRelative == true) {
speeds = ChassisSpeeds.fromFieldRelativeSpeeds(xSpeed, ySpeed, rot, getHeading());
} else {
speeds = new ChassisSpeeds(xSpeed, ySpeed, rot);
}
SwerveModuleState[] swerveModuleStates = kinematics.toSwerveModuleStates(speeds);
// sometime the Kinematics spits out too fast of speeds, so this will fix this
SwerveDriveKinematics.desaturateWheelSpeeds(swerveModuleStates, kMaxSpeed);
// command each swerve module
for (int i = 0; i < modules.length; i++) {
modules[i].setDesiredState(swerveModuleStates[i]);
}
// report our commands to the dashboard
SmartDashboard.putNumber("SwerveDrive/xSpeed", xSpeed);
SmartDashboard.putNumber("SwerveDrive/ySpeed", ySpeed);
SmartDashboard.putNumber("SwerveDrive/rot", rot);
SmartDashboard.putBoolean("SwerveDrive/fieldRelative", fieldRelative);
} | NONSATD | true | modules[i].setDesiredState(swerveModuleStates[i]);
}
// report our commands to the dashboard
SmartDashboard.putNumber("SwerveDrive/xSpeed", xSpeed);
SmartDashboard.putNumber("SwerveDrive/ySpeed", ySpeed); | } else {
speeds = new ChassisSpeeds(xSpeed, ySpeed, rot);
}
SwerveModuleState[] swerveModuleStates = kinematics.toSwerveModuleStates(speeds);
// sometime the Kinematics spits out too fast of speeds, so this will fix this
SwerveDriveKinematics.desaturateWheelSpeeds(swerveModuleStates, kMaxSpeed);
// command each swerve module
for (int i = 0; i < modules.length; i++) {
modules[i].setDesiredState(swerveModuleStates[i]);
}
// report our commands to the dashboard
SmartDashboard.putNumber("SwerveDrive/xSpeed", xSpeed);
SmartDashboard.putNumber("SwerveDrive/ySpeed", ySpeed);
SmartDashboard.putNumber("SwerveDrive/rot", rot);
SmartDashboard.putBoolean("SwerveDrive/fieldRelative", fieldRelative);
} | @SuppressWarnings("ParameterName")
public void drive(double xSpeed, double ySpeed, double rot, boolean fieldRelative) {
// ask the kinematics to determine our swerve command
ChassisSpeeds speeds;
if (fieldRelative == true) {
speeds = ChassisSpeeds.fromFieldRelativeSpeeds(xSpeed, ySpeed, rot, getHeading());
} else {
speeds = new ChassisSpeeds(xSpeed, ySpeed, rot);
}
SwerveModuleState[] swerveModuleStates = kinematics.toSwerveModuleStates(speeds);
// sometime the Kinematics spits out too fast of speeds, so this will fix this
SwerveDriveKinematics.desaturateWheelSpeeds(swerveModuleStates, kMaxSpeed);
// command each swerve module
for (int i = 0; i < modules.length; i++) {
modules[i].setDesiredState(swerveModuleStates[i]);
}
// report our commands to the dashboard
SmartDashboard.putNumber("SwerveDrive/xSpeed", xSpeed);
SmartDashboard.putNumber("SwerveDrive/ySpeed", ySpeed);
SmartDashboard.putNumber("SwerveDrive/rot", rot);
SmartDashboard.putBoolean("SwerveDrive/fieldRelative", fieldRelative);
} |
25,901 | 0 | /**
* Test of getVotesForInstance method, of class FeS2.
*/ | @Test
public void testGetVotesForInstance() {
System.out.println("getVotesForInstance");
FeS2 classifier = new FeS2();
Instance x = trainingSet.instance(0);
classifier.subspaceStrategyOption.setChosenIndex(0);
classifier.distanceStrategyOption.setChosenIndex(2);
classifier.initialClusterWeightOption.setValue(0.1);
classifier.learningRateAlphaOption.setValue(0.95);
classifier.minimumClusterSizeOption.setValue(3);
classifier.outlierDefinitionStrategyOption.setChosenIndex(0);
// classifier.pruneThresholdOption.setValue(0.00001);
classifier.updateStrategyOption.setChosenIndex(1);
classifier.trainOnInstance(trainingSet.instance(0));
double[] result = classifier.getVotesForInstance(x);
int h = (int) result[weka.core.Utils.maxIndex(result)];
int y = 1;
assertEquals(y,h);
// TODO - add fuller set
} | NONSATD | true | @Test
public void testGetVotesForInstance() {
System.out.println("getVotesForInstance");
FeS2 classifier = new FeS2();
Instance x = trainingSet.instance(0);
classifier.subspaceStrategyOption.setChosenIndex(0);
classifier.distanceStrategyOption.setChosenIndex(2);
classifier.initialClusterWeightOption.setValue(0.1);
classifier.learningRateAlphaOption.setValue(0.95);
classifier.minimumClusterSizeOption.setValue(3);
classifier.outlierDefinitionStrategyOption.setChosenIndex(0);
// classifier.pruneThresholdOption.setValue(0.00001);
classifier.updateStrategyOption.setChosenIndex(1);
classifier.trainOnInstance(trainingSet.instance(0));
double[] result = classifier.getVotesForInstance(x);
int h = (int) result[weka.core.Utils.maxIndex(result)];
int y = 1;
assertEquals(y,h);
// TODO - add fuller set
} | @Test
public void testGetVotesForInstance() {
System.out.println("getVotesForInstance");
FeS2 classifier = new FeS2();
Instance x = trainingSet.instance(0);
classifier.subspaceStrategyOption.setChosenIndex(0);
classifier.distanceStrategyOption.setChosenIndex(2);
classifier.initialClusterWeightOption.setValue(0.1);
classifier.learningRateAlphaOption.setValue(0.95);
classifier.minimumClusterSizeOption.setValue(3);
classifier.outlierDefinitionStrategyOption.setChosenIndex(0);
// classifier.pruneThresholdOption.setValue(0.00001);
classifier.updateStrategyOption.setChosenIndex(1);
classifier.trainOnInstance(trainingSet.instance(0));
double[] result = classifier.getVotesForInstance(x);
int h = (int) result[weka.core.Utils.maxIndex(result)];
int y = 1;
assertEquals(y,h);
// TODO - add fuller set
} | @Test
public void testGetVotesForInstance() {
System.out.println("getVotesForInstance");
FeS2 classifier = new FeS2();
Instance x = trainingSet.instance(0);
classifier.subspaceStrategyOption.setChosenIndex(0);
classifier.distanceStrategyOption.setChosenIndex(2);
classifier.initialClusterWeightOption.setValue(0.1);
classifier.learningRateAlphaOption.setValue(0.95);
classifier.minimumClusterSizeOption.setValue(3);
classifier.outlierDefinitionStrategyOption.setChosenIndex(0);
// classifier.pruneThresholdOption.setValue(0.00001);
classifier.updateStrategyOption.setChosenIndex(1);
classifier.trainOnInstance(trainingSet.instance(0));
double[] result = classifier.getVotesForInstance(x);
int h = (int) result[weka.core.Utils.maxIndex(result)];
int y = 1;
assertEquals(y,h);
// TODO - add fuller set
} |
25,901 | 1 | // classifier.pruneThresholdOption.setValue(0.00001); | @Test
public void testGetVotesForInstance() {
System.out.println("getVotesForInstance");
FeS2 classifier = new FeS2();
Instance x = trainingSet.instance(0);
classifier.subspaceStrategyOption.setChosenIndex(0);
classifier.distanceStrategyOption.setChosenIndex(2);
classifier.initialClusterWeightOption.setValue(0.1);
classifier.learningRateAlphaOption.setValue(0.95);
classifier.minimumClusterSizeOption.setValue(3);
classifier.outlierDefinitionStrategyOption.setChosenIndex(0);
// classifier.pruneThresholdOption.setValue(0.00001);
classifier.updateStrategyOption.setChosenIndex(1);
classifier.trainOnInstance(trainingSet.instance(0));
double[] result = classifier.getVotesForInstance(x);
int h = (int) result[weka.core.Utils.maxIndex(result)];
int y = 1;
assertEquals(y,h);
// TODO - add fuller set
} | NONSATD | true | classifier.minimumClusterSizeOption.setValue(3);
classifier.outlierDefinitionStrategyOption.setChosenIndex(0);
// classifier.pruneThresholdOption.setValue(0.00001);
classifier.updateStrategyOption.setChosenIndex(1);
classifier.trainOnInstance(trainingSet.instance(0)); | public void testGetVotesForInstance() {
System.out.println("getVotesForInstance");
FeS2 classifier = new FeS2();
Instance x = trainingSet.instance(0);
classifier.subspaceStrategyOption.setChosenIndex(0);
classifier.distanceStrategyOption.setChosenIndex(2);
classifier.initialClusterWeightOption.setValue(0.1);
classifier.learningRateAlphaOption.setValue(0.95);
classifier.minimumClusterSizeOption.setValue(3);
classifier.outlierDefinitionStrategyOption.setChosenIndex(0);
// classifier.pruneThresholdOption.setValue(0.00001);
classifier.updateStrategyOption.setChosenIndex(1);
classifier.trainOnInstance(trainingSet.instance(0));
double[] result = classifier.getVotesForInstance(x);
int h = (int) result[weka.core.Utils.maxIndex(result)];
int y = 1;
assertEquals(y,h);
// TODO - add fuller set
} | @Test
public void testGetVotesForInstance() {
System.out.println("getVotesForInstance");
FeS2 classifier = new FeS2();
Instance x = trainingSet.instance(0);
classifier.subspaceStrategyOption.setChosenIndex(0);
classifier.distanceStrategyOption.setChosenIndex(2);
classifier.initialClusterWeightOption.setValue(0.1);
classifier.learningRateAlphaOption.setValue(0.95);
classifier.minimumClusterSizeOption.setValue(3);
classifier.outlierDefinitionStrategyOption.setChosenIndex(0);
// classifier.pruneThresholdOption.setValue(0.00001);
classifier.updateStrategyOption.setChosenIndex(1);
classifier.trainOnInstance(trainingSet.instance(0));
double[] result = classifier.getVotesForInstance(x);
int h = (int) result[weka.core.Utils.maxIndex(result)];
int y = 1;
assertEquals(y,h);
// TODO - add fuller set
} |
25,901 | 2 | // TODO - add fuller set | @Test
public void testGetVotesForInstance() {
System.out.println("getVotesForInstance");
FeS2 classifier = new FeS2();
Instance x = trainingSet.instance(0);
classifier.subspaceStrategyOption.setChosenIndex(0);
classifier.distanceStrategyOption.setChosenIndex(2);
classifier.initialClusterWeightOption.setValue(0.1);
classifier.learningRateAlphaOption.setValue(0.95);
classifier.minimumClusterSizeOption.setValue(3);
classifier.outlierDefinitionStrategyOption.setChosenIndex(0);
// classifier.pruneThresholdOption.setValue(0.00001);
classifier.updateStrategyOption.setChosenIndex(1);
classifier.trainOnInstance(trainingSet.instance(0));
double[] result = classifier.getVotesForInstance(x);
int h = (int) result[weka.core.Utils.maxIndex(result)];
int y = 1;
assertEquals(y,h);
// TODO - add fuller set
} | IMPLEMENTATION | true | int y = 1;
assertEquals(y,h);
// TODO - add fuller set
} | classifier.learningRateAlphaOption.setValue(0.95);
classifier.minimumClusterSizeOption.setValue(3);
classifier.outlierDefinitionStrategyOption.setChosenIndex(0);
// classifier.pruneThresholdOption.setValue(0.00001);
classifier.updateStrategyOption.setChosenIndex(1);
classifier.trainOnInstance(trainingSet.instance(0));
double[] result = classifier.getVotesForInstance(x);
int h = (int) result[weka.core.Utils.maxIndex(result)];
int y = 1;
assertEquals(y,h);
// TODO - add fuller set
} | @Test
public void testGetVotesForInstance() {
System.out.println("getVotesForInstance");
FeS2 classifier = new FeS2();
Instance x = trainingSet.instance(0);
classifier.subspaceStrategyOption.setChosenIndex(0);
classifier.distanceStrategyOption.setChosenIndex(2);
classifier.initialClusterWeightOption.setValue(0.1);
classifier.learningRateAlphaOption.setValue(0.95);
classifier.minimumClusterSizeOption.setValue(3);
classifier.outlierDefinitionStrategyOption.setChosenIndex(0);
// classifier.pruneThresholdOption.setValue(0.00001);
classifier.updateStrategyOption.setChosenIndex(1);
classifier.trainOnInstance(trainingSet.instance(0));
double[] result = classifier.getVotesForInstance(x);
int h = (int) result[weka.core.Utils.maxIndex(result)];
int y = 1;
assertEquals(y,h);
// TODO - add fuller set
} |
9,519 | 0 | /**
* Score a frame with the given model.
*/ | protected static Response scoreOne(Frame frame, Model score_model) {
water.ModelMetrics metrics = water.ModelMetrics.getFromDKV(score_model, frame);
if (null == metrics) {
// have to compute
water.util.Log.debug("Cache miss: computing ModelMetrics. . .");
long before = System.currentTimeMillis();
Frame predictions = score_model.score(frame, true); // TODO: for now we're always calling adapt inside score
long after = System.currentTimeMillis();
ConfusionMatrix cm = new ConfusionMatrix(); // for regression this computes the MSE
AUC auc = null;
HitRatio hr = null;
if (score_model.isClassifier()) {
auc = new AUC();
// hr = new HitRatio();
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, auc, hr);
} else {
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, null, null);
}
// Now call AUC and ConfusionMatrix and maybe HitRatio
metrics = new water.ModelMetrics(score_model.getUniqueId(),
score_model.getModelCategory(),
frame.getUniqueId(),
after - before,
after,
auc,
cm);
// Put the metrics into the KV store
metrics.putInDKV();
} else {
// it's already cached in the DKV
water.util.Log.debug("using ModelMetrics from the cache. . .");
}
JsonObject metricsJson = metrics.toJSON();
JsonArray metricsArray = new JsonArray();
metricsArray.add(metricsJson);
JsonObject result = new JsonObject();
result.add("metrics", metricsArray);
return Response.done(result);
} | NONSATD | true | protected static Response scoreOne(Frame frame, Model score_model) {
water.ModelMetrics metrics = water.ModelMetrics.getFromDKV(score_model, frame);
if (null == metrics) {
// have to compute
water.util.Log.debug("Cache miss: computing ModelMetrics. . .");
long before = System.currentTimeMillis();
Frame predictions = score_model.score(frame, true); // TODO: for now we're always calling adapt inside score
long after = System.currentTimeMillis();
ConfusionMatrix cm = new ConfusionMatrix(); // for regression this computes the MSE
AUC auc = null;
HitRatio hr = null;
if (score_model.isClassifier()) {
auc = new AUC();
// hr = new HitRatio();
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, auc, hr);
} else {
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, null, null);
}
// Now call AUC and ConfusionMatrix and maybe HitRatio
metrics = new water.ModelMetrics(score_model.getUniqueId(),
score_model.getModelCategory(),
frame.getUniqueId(),
after - before,
after,
auc,
cm);
// Put the metrics into the KV store
metrics.putInDKV();
} else {
// it's already cached in the DKV
water.util.Log.debug("using ModelMetrics from the cache. . .");
}
JsonObject metricsJson = metrics.toJSON();
JsonArray metricsArray = new JsonArray();
metricsArray.add(metricsJson);
JsonObject result = new JsonObject();
result.add("metrics", metricsArray);
return Response.done(result);
} | protected static Response scoreOne(Frame frame, Model score_model) {
water.ModelMetrics metrics = water.ModelMetrics.getFromDKV(score_model, frame);
if (null == metrics) {
// have to compute
water.util.Log.debug("Cache miss: computing ModelMetrics. . .");
long before = System.currentTimeMillis();
Frame predictions = score_model.score(frame, true); // TODO: for now we're always calling adapt inside score
long after = System.currentTimeMillis();
ConfusionMatrix cm = new ConfusionMatrix(); // for regression this computes the MSE
AUC auc = null;
HitRatio hr = null;
if (score_model.isClassifier()) {
auc = new AUC();
// hr = new HitRatio();
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, auc, hr);
} else {
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, null, null);
}
// Now call AUC and ConfusionMatrix and maybe HitRatio
metrics = new water.ModelMetrics(score_model.getUniqueId(),
score_model.getModelCategory(),
frame.getUniqueId(),
after - before,
after,
auc,
cm);
// Put the metrics into the KV store
metrics.putInDKV();
} else {
// it's already cached in the DKV
water.util.Log.debug("using ModelMetrics from the cache. . .");
}
JsonObject metricsJson = metrics.toJSON();
JsonArray metricsArray = new JsonArray();
metricsArray.add(metricsJson);
JsonObject result = new JsonObject();
result.add("metrics", metricsArray);
return Response.done(result);
} | protected static Response scoreOne(Frame frame, Model score_model) {
water.ModelMetrics metrics = water.ModelMetrics.getFromDKV(score_model, frame);
if (null == metrics) {
// have to compute
water.util.Log.debug("Cache miss: computing ModelMetrics. . .");
long before = System.currentTimeMillis();
Frame predictions = score_model.score(frame, true); // TODO: for now we're always calling adapt inside score
long after = System.currentTimeMillis();
ConfusionMatrix cm = new ConfusionMatrix(); // for regression this computes the MSE
AUC auc = null;
HitRatio hr = null;
if (score_model.isClassifier()) {
auc = new AUC();
// hr = new HitRatio();
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, auc, hr);
} else {
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, null, null);
}
// Now call AUC and ConfusionMatrix and maybe HitRatio
metrics = new water.ModelMetrics(score_model.getUniqueId(),
score_model.getModelCategory(),
frame.getUniqueId(),
after - before,
after,
auc,
cm);
// Put the metrics into the KV store
metrics.putInDKV();
} else {
// it's already cached in the DKV
water.util.Log.debug("using ModelMetrics from the cache. . .");
}
JsonObject metricsJson = metrics.toJSON();
JsonArray metricsArray = new JsonArray();
metricsArray.add(metricsJson);
JsonObject result = new JsonObject();
result.add("metrics", metricsArray);
return Response.done(result);
} |
9,519 | 1 | // have to compute | protected static Response scoreOne(Frame frame, Model score_model) {
water.ModelMetrics metrics = water.ModelMetrics.getFromDKV(score_model, frame);
if (null == metrics) {
// have to compute
water.util.Log.debug("Cache miss: computing ModelMetrics. . .");
long before = System.currentTimeMillis();
Frame predictions = score_model.score(frame, true); // TODO: for now we're always calling adapt inside score
long after = System.currentTimeMillis();
ConfusionMatrix cm = new ConfusionMatrix(); // for regression this computes the MSE
AUC auc = null;
HitRatio hr = null;
if (score_model.isClassifier()) {
auc = new AUC();
// hr = new HitRatio();
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, auc, hr);
} else {
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, null, null);
}
// Now call AUC and ConfusionMatrix and maybe HitRatio
metrics = new water.ModelMetrics(score_model.getUniqueId(),
score_model.getModelCategory(),
frame.getUniqueId(),
after - before,
after,
auc,
cm);
// Put the metrics into the KV store
metrics.putInDKV();
} else {
// it's already cached in the DKV
water.util.Log.debug("using ModelMetrics from the cache. . .");
}
JsonObject metricsJson = metrics.toJSON();
JsonArray metricsArray = new JsonArray();
metricsArray.add(metricsJson);
JsonObject result = new JsonObject();
result.add("metrics", metricsArray);
return Response.done(result);
} | NONSATD | true | water.ModelMetrics metrics = water.ModelMetrics.getFromDKV(score_model, frame);
if (null == metrics) {
// have to compute
water.util.Log.debug("Cache miss: computing ModelMetrics. . .");
long before = System.currentTimeMillis(); | protected static Response scoreOne(Frame frame, Model score_model) {
water.ModelMetrics metrics = water.ModelMetrics.getFromDKV(score_model, frame);
if (null == metrics) {
// have to compute
water.util.Log.debug("Cache miss: computing ModelMetrics. . .");
long before = System.currentTimeMillis();
Frame predictions = score_model.score(frame, true); // TODO: for now we're always calling adapt inside score
long after = System.currentTimeMillis();
ConfusionMatrix cm = new ConfusionMatrix(); // for regression this computes the MSE
AUC auc = null;
HitRatio hr = null;
if (score_model.isClassifier()) {
auc = new AUC();
// hr = new HitRatio(); | protected static Response scoreOne(Frame frame, Model score_model) {
water.ModelMetrics metrics = water.ModelMetrics.getFromDKV(score_model, frame);
if (null == metrics) {
// have to compute
water.util.Log.debug("Cache miss: computing ModelMetrics. . .");
long before = System.currentTimeMillis();
Frame predictions = score_model.score(frame, true); // TODO: for now we're always calling adapt inside score
long after = System.currentTimeMillis();
ConfusionMatrix cm = new ConfusionMatrix(); // for regression this computes the MSE
AUC auc = null;
HitRatio hr = null;
if (score_model.isClassifier()) {
auc = new AUC();
// hr = new HitRatio();
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, auc, hr);
} else {
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, null, null);
}
// Now call AUC and ConfusionMatrix and maybe HitRatio
metrics = new water.ModelMetrics(score_model.getUniqueId(),
score_model.getModelCategory(),
frame.getUniqueId(), |
9,519 | 2 | // TODO: for now we're always calling adapt inside score | protected static Response scoreOne(Frame frame, Model score_model) {
water.ModelMetrics metrics = water.ModelMetrics.getFromDKV(score_model, frame);
if (null == metrics) {
// have to compute
water.util.Log.debug("Cache miss: computing ModelMetrics. . .");
long before = System.currentTimeMillis();
Frame predictions = score_model.score(frame, true); // TODO: for now we're always calling adapt inside score
long after = System.currentTimeMillis();
ConfusionMatrix cm = new ConfusionMatrix(); // for regression this computes the MSE
AUC auc = null;
HitRatio hr = null;
if (score_model.isClassifier()) {
auc = new AUC();
// hr = new HitRatio();
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, auc, hr);
} else {
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, null, null);
}
// Now call AUC and ConfusionMatrix and maybe HitRatio
metrics = new water.ModelMetrics(score_model.getUniqueId(),
score_model.getModelCategory(),
frame.getUniqueId(),
after - before,
after,
auc,
cm);
// Put the metrics into the KV store
metrics.putInDKV();
} else {
// it's already cached in the DKV
water.util.Log.debug("using ModelMetrics from the cache. . .");
}
JsonObject metricsJson = metrics.toJSON();
JsonArray metricsArray = new JsonArray();
metricsArray.add(metricsJson);
JsonObject result = new JsonObject();
result.add("metrics", metricsArray);
return Response.done(result);
} | DESIGN | true | water.util.Log.debug("Cache miss: computing ModelMetrics. . .");
long before = System.currentTimeMillis();
Frame predictions = score_model.score(frame, true); // TODO: for now we're always calling adapt inside score
long after = System.currentTimeMillis();
ConfusionMatrix cm = new ConfusionMatrix(); // for regression this computes the MSE | protected static Response scoreOne(Frame frame, Model score_model) {
water.ModelMetrics metrics = water.ModelMetrics.getFromDKV(score_model, frame);
if (null == metrics) {
// have to compute
water.util.Log.debug("Cache miss: computing ModelMetrics. . .");
long before = System.currentTimeMillis();
Frame predictions = score_model.score(frame, true); // TODO: for now we're always calling adapt inside score
long after = System.currentTimeMillis();
ConfusionMatrix cm = new ConfusionMatrix(); // for regression this computes the MSE
AUC auc = null;
HitRatio hr = null;
if (score_model.isClassifier()) {
auc = new AUC();
// hr = new HitRatio();
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, auc, hr);
} else { | protected static Response scoreOne(Frame frame, Model score_model) {
water.ModelMetrics metrics = water.ModelMetrics.getFromDKV(score_model, frame);
if (null == metrics) {
// have to compute
water.util.Log.debug("Cache miss: computing ModelMetrics. . .");
long before = System.currentTimeMillis();
Frame predictions = score_model.score(frame, true); // TODO: for now we're always calling adapt inside score
long after = System.currentTimeMillis();
ConfusionMatrix cm = new ConfusionMatrix(); // for regression this computes the MSE
AUC auc = null;
HitRatio hr = null;
if (score_model.isClassifier()) {
auc = new AUC();
// hr = new HitRatio();
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, auc, hr);
} else {
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, null, null);
}
// Now call AUC and ConfusionMatrix and maybe HitRatio
metrics = new water.ModelMetrics(score_model.getUniqueId(),
score_model.getModelCategory(),
frame.getUniqueId(),
after - before,
after,
auc, |
9,519 | 3 | // for regression this computes the MSE | protected static Response scoreOne(Frame frame, Model score_model) {
water.ModelMetrics metrics = water.ModelMetrics.getFromDKV(score_model, frame);
if (null == metrics) {
// have to compute
water.util.Log.debug("Cache miss: computing ModelMetrics. . .");
long before = System.currentTimeMillis();
Frame predictions = score_model.score(frame, true); // TODO: for now we're always calling adapt inside score
long after = System.currentTimeMillis();
ConfusionMatrix cm = new ConfusionMatrix(); // for regression this computes the MSE
AUC auc = null;
HitRatio hr = null;
if (score_model.isClassifier()) {
auc = new AUC();
// hr = new HitRatio();
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, auc, hr);
} else {
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, null, null);
}
// Now call AUC and ConfusionMatrix and maybe HitRatio
metrics = new water.ModelMetrics(score_model.getUniqueId(),
score_model.getModelCategory(),
frame.getUniqueId(),
after - before,
after,
auc,
cm);
// Put the metrics into the KV store
metrics.putInDKV();
} else {
// it's already cached in the DKV
water.util.Log.debug("using ModelMetrics from the cache. . .");
}
JsonObject metricsJson = metrics.toJSON();
JsonArray metricsArray = new JsonArray();
metricsArray.add(metricsJson);
JsonObject result = new JsonObject();
result.add("metrics", metricsArray);
return Response.done(result);
} | NONSATD | true | Frame predictions = score_model.score(frame, true); // TODO: for now we're always calling adapt inside score
long after = System.currentTimeMillis();
ConfusionMatrix cm = new ConfusionMatrix(); // for regression this computes the MSE
AUC auc = null;
HitRatio hr = null; | protected static Response scoreOne(Frame frame, Model score_model) {
water.ModelMetrics metrics = water.ModelMetrics.getFromDKV(score_model, frame);
if (null == metrics) {
// have to compute
water.util.Log.debug("Cache miss: computing ModelMetrics. . .");
long before = System.currentTimeMillis();
Frame predictions = score_model.score(frame, true); // TODO: for now we're always calling adapt inside score
long after = System.currentTimeMillis();
ConfusionMatrix cm = new ConfusionMatrix(); // for regression this computes the MSE
AUC auc = null;
HitRatio hr = null;
if (score_model.isClassifier()) {
auc = new AUC();
// hr = new HitRatio();
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, auc, hr);
} else {
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, null, null); | protected static Response scoreOne(Frame frame, Model score_model) {
water.ModelMetrics metrics = water.ModelMetrics.getFromDKV(score_model, frame);
if (null == metrics) {
// have to compute
water.util.Log.debug("Cache miss: computing ModelMetrics. . .");
long before = System.currentTimeMillis();
Frame predictions = score_model.score(frame, true); // TODO: for now we're always calling adapt inside score
long after = System.currentTimeMillis();
ConfusionMatrix cm = new ConfusionMatrix(); // for regression this computes the MSE
AUC auc = null;
HitRatio hr = null;
if (score_model.isClassifier()) {
auc = new AUC();
// hr = new HitRatio();
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, auc, hr);
} else {
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, null, null);
}
// Now call AUC and ConfusionMatrix and maybe HitRatio
metrics = new water.ModelMetrics(score_model.getUniqueId(),
score_model.getModelCategory(),
frame.getUniqueId(),
after - before,
after,
auc,
cm);
// Put the metrics into the KV store |
9,519 | 4 | // hr = new HitRatio(); | protected static Response scoreOne(Frame frame, Model score_model) {
water.ModelMetrics metrics = water.ModelMetrics.getFromDKV(score_model, frame);
if (null == metrics) {
// have to compute
water.util.Log.debug("Cache miss: computing ModelMetrics. . .");
long before = System.currentTimeMillis();
Frame predictions = score_model.score(frame, true); // TODO: for now we're always calling adapt inside score
long after = System.currentTimeMillis();
ConfusionMatrix cm = new ConfusionMatrix(); // for regression this computes the MSE
AUC auc = null;
HitRatio hr = null;
if (score_model.isClassifier()) {
auc = new AUC();
// hr = new HitRatio();
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, auc, hr);
} else {
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, null, null);
}
// Now call AUC and ConfusionMatrix and maybe HitRatio
metrics = new water.ModelMetrics(score_model.getUniqueId(),
score_model.getModelCategory(),
frame.getUniqueId(),
after - before,
after,
auc,
cm);
// Put the metrics into the KV store
metrics.putInDKV();
} else {
// it's already cached in the DKV
water.util.Log.debug("using ModelMetrics from the cache. . .");
}
JsonObject metricsJson = metrics.toJSON();
JsonArray metricsArray = new JsonArray();
metricsArray.add(metricsJson);
JsonObject result = new JsonObject();
result.add("metrics", metricsArray);
return Response.done(result);
} | NONSATD | true | if (score_model.isClassifier()) {
auc = new AUC();
// hr = new HitRatio();
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, auc, hr); | // have to compute
water.util.Log.debug("Cache miss: computing ModelMetrics. . .");
long before = System.currentTimeMillis();
Frame predictions = score_model.score(frame, true); // TODO: for now we're always calling adapt inside score
long after = System.currentTimeMillis();
ConfusionMatrix cm = new ConfusionMatrix(); // for regression this computes the MSE
AUC auc = null;
HitRatio hr = null;
if (score_model.isClassifier()) {
auc = new AUC();
// hr = new HitRatio();
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, auc, hr);
} else {
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, null, null);
}
// Now call AUC and ConfusionMatrix and maybe HitRatio
metrics = new water.ModelMetrics(score_model.getUniqueId(),
score_model.getModelCategory(),
frame.getUniqueId(), | protected static Response scoreOne(Frame frame, Model score_model) {
water.ModelMetrics metrics = water.ModelMetrics.getFromDKV(score_model, frame);
if (null == metrics) {
// have to compute
water.util.Log.debug("Cache miss: computing ModelMetrics. . .");
long before = System.currentTimeMillis();
Frame predictions = score_model.score(frame, true); // TODO: for now we're always calling adapt inside score
long after = System.currentTimeMillis();
ConfusionMatrix cm = new ConfusionMatrix(); // for regression this computes the MSE
AUC auc = null;
HitRatio hr = null;
if (score_model.isClassifier()) {
auc = new AUC();
// hr = new HitRatio();
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, auc, hr);
} else {
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, null, null);
}
// Now call AUC and ConfusionMatrix and maybe HitRatio
metrics = new water.ModelMetrics(score_model.getUniqueId(),
score_model.getModelCategory(),
frame.getUniqueId(),
after - before,
after,
auc,
cm);
// Put the metrics into the KV store
metrics.putInDKV();
} else {
// it's already cached in the DKV
water.util.Log.debug("using ModelMetrics from the cache. . .");
} |
9,519 | 5 | // Now call AUC and ConfusionMatrix and maybe HitRatio | protected static Response scoreOne(Frame frame, Model score_model) {
water.ModelMetrics metrics = water.ModelMetrics.getFromDKV(score_model, frame);
if (null == metrics) {
// have to compute
water.util.Log.debug("Cache miss: computing ModelMetrics. . .");
long before = System.currentTimeMillis();
Frame predictions = score_model.score(frame, true); // TODO: for now we're always calling adapt inside score
long after = System.currentTimeMillis();
ConfusionMatrix cm = new ConfusionMatrix(); // for regression this computes the MSE
AUC auc = null;
HitRatio hr = null;
if (score_model.isClassifier()) {
auc = new AUC();
// hr = new HitRatio();
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, auc, hr);
} else {
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, null, null);
}
// Now call AUC and ConfusionMatrix and maybe HitRatio
metrics = new water.ModelMetrics(score_model.getUniqueId(),
score_model.getModelCategory(),
frame.getUniqueId(),
after - before,
after,
auc,
cm);
// Put the metrics into the KV store
metrics.putInDKV();
} else {
// it's already cached in the DKV
water.util.Log.debug("using ModelMetrics from the cache. . .");
}
JsonObject metricsJson = metrics.toJSON();
JsonArray metricsArray = new JsonArray();
metricsArray.add(metricsJson);
JsonObject result = new JsonObject();
result.add("metrics", metricsArray);
return Response.done(result);
} | NONSATD | true | true, 20, cm, null, null);
}
// Now call AUC and ConfusionMatrix and maybe HitRatio
metrics = new water.ModelMetrics(score_model.getUniqueId(),
score_model.getModelCategory(), | HitRatio hr = null;
if (score_model.isClassifier()) {
auc = new AUC();
// hr = new HitRatio();
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, auc, hr);
} else {
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, null, null);
}
// Now call AUC and ConfusionMatrix and maybe HitRatio
metrics = new water.ModelMetrics(score_model.getUniqueId(),
score_model.getModelCategory(),
frame.getUniqueId(),
after - before,
after,
auc,
cm);
// Put the metrics into the KV store
metrics.putInDKV();
} else { | protected static Response scoreOne(Frame frame, Model score_model) {
water.ModelMetrics metrics = water.ModelMetrics.getFromDKV(score_model, frame);
if (null == metrics) {
// have to compute
water.util.Log.debug("Cache miss: computing ModelMetrics. . .");
long before = System.currentTimeMillis();
Frame predictions = score_model.score(frame, true); // TODO: for now we're always calling adapt inside score
long after = System.currentTimeMillis();
ConfusionMatrix cm = new ConfusionMatrix(); // for regression this computes the MSE
AUC auc = null;
HitRatio hr = null;
if (score_model.isClassifier()) {
auc = new AUC();
// hr = new HitRatio();
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, auc, hr);
} else {
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, null, null);
}
// Now call AUC and ConfusionMatrix and maybe HitRatio
metrics = new water.ModelMetrics(score_model.getUniqueId(),
score_model.getModelCategory(),
frame.getUniqueId(),
after - before,
after,
auc,
cm);
// Put the metrics into the KV store
metrics.putInDKV();
} else {
// it's already cached in the DKV
water.util.Log.debug("using ModelMetrics from the cache. . .");
}
JsonObject metricsJson = metrics.toJSON();
JsonArray metricsArray = new JsonArray();
metricsArray.add(metricsJson);
JsonObject result = new JsonObject();
result.add("metrics", metricsArray);
return Response.done(result);
} |
9,519 | 6 | // Put the metrics into the KV store | protected static Response scoreOne(Frame frame, Model score_model) {
water.ModelMetrics metrics = water.ModelMetrics.getFromDKV(score_model, frame);
if (null == metrics) {
// have to compute
water.util.Log.debug("Cache miss: computing ModelMetrics. . .");
long before = System.currentTimeMillis();
Frame predictions = score_model.score(frame, true); // TODO: for now we're always calling adapt inside score
long after = System.currentTimeMillis();
ConfusionMatrix cm = new ConfusionMatrix(); // for regression this computes the MSE
AUC auc = null;
HitRatio hr = null;
if (score_model.isClassifier()) {
auc = new AUC();
// hr = new HitRatio();
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, auc, hr);
} else {
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, null, null);
}
// Now call AUC and ConfusionMatrix and maybe HitRatio
metrics = new water.ModelMetrics(score_model.getUniqueId(),
score_model.getModelCategory(),
frame.getUniqueId(),
after - before,
after,
auc,
cm);
// Put the metrics into the KV store
metrics.putInDKV();
} else {
// it's already cached in the DKV
water.util.Log.debug("using ModelMetrics from the cache. . .");
}
JsonObject metricsJson = metrics.toJSON();
JsonArray metricsArray = new JsonArray();
metricsArray.add(metricsJson);
JsonObject result = new JsonObject();
result.add("metrics", metricsArray);
return Response.done(result);
} | NONSATD | true | auc,
cm);
// Put the metrics into the KV store
metrics.putInDKV();
} else { | true, 20, cm, null, null);
}
// Now call AUC and ConfusionMatrix and maybe HitRatio
metrics = new water.ModelMetrics(score_model.getUniqueId(),
score_model.getModelCategory(),
frame.getUniqueId(),
after - before,
after,
auc,
cm);
// Put the metrics into the KV store
metrics.putInDKV();
} else {
// it's already cached in the DKV
water.util.Log.debug("using ModelMetrics from the cache. . .");
}
JsonObject metricsJson = metrics.toJSON();
JsonArray metricsArray = new JsonArray();
metricsArray.add(metricsJson);
JsonObject result = new JsonObject();
result.add("metrics", metricsArray); | ConfusionMatrix cm = new ConfusionMatrix(); // for regression this computes the MSE
AUC auc = null;
HitRatio hr = null;
if (score_model.isClassifier()) {
auc = new AUC();
// hr = new HitRatio();
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, auc, hr);
} else {
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, null, null);
}
// Now call AUC and ConfusionMatrix and maybe HitRatio
metrics = new water.ModelMetrics(score_model.getUniqueId(),
score_model.getModelCategory(),
frame.getUniqueId(),
after - before,
after,
auc,
cm);
// Put the metrics into the KV store
metrics.putInDKV();
} else {
// it's already cached in the DKV
water.util.Log.debug("using ModelMetrics from the cache. . .");
}
JsonObject metricsJson = metrics.toJSON();
JsonArray metricsArray = new JsonArray();
metricsArray.add(metricsJson);
JsonObject result = new JsonObject();
result.add("metrics", metricsArray);
return Response.done(result);
} |
9,519 | 7 | // it's already cached in the DKV | protected static Response scoreOne(Frame frame, Model score_model) {
water.ModelMetrics metrics = water.ModelMetrics.getFromDKV(score_model, frame);
if (null == metrics) {
// have to compute
water.util.Log.debug("Cache miss: computing ModelMetrics. . .");
long before = System.currentTimeMillis();
Frame predictions = score_model.score(frame, true); // TODO: for now we're always calling adapt inside score
long after = System.currentTimeMillis();
ConfusionMatrix cm = new ConfusionMatrix(); // for regression this computes the MSE
AUC auc = null;
HitRatio hr = null;
if (score_model.isClassifier()) {
auc = new AUC();
// hr = new HitRatio();
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, auc, hr);
} else {
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, null, null);
}
// Now call AUC and ConfusionMatrix and maybe HitRatio
metrics = new water.ModelMetrics(score_model.getUniqueId(),
score_model.getModelCategory(),
frame.getUniqueId(),
after - before,
after,
auc,
cm);
// Put the metrics into the KV store
metrics.putInDKV();
} else {
// it's already cached in the DKV
water.util.Log.debug("using ModelMetrics from the cache. . .");
}
JsonObject metricsJson = metrics.toJSON();
JsonArray metricsArray = new JsonArray();
metricsArray.add(metricsJson);
JsonObject result = new JsonObject();
result.add("metrics", metricsArray);
return Response.done(result);
} | NONSATD | true | metrics.putInDKV();
} else {
// it's already cached in the DKV
water.util.Log.debug("using ModelMetrics from the cache. . .");
} | metrics = new water.ModelMetrics(score_model.getUniqueId(),
score_model.getModelCategory(),
frame.getUniqueId(),
after - before,
after,
auc,
cm);
// Put the metrics into the KV store
metrics.putInDKV();
} else {
// it's already cached in the DKV
water.util.Log.debug("using ModelMetrics from the cache. . .");
}
JsonObject metricsJson = metrics.toJSON();
JsonArray metricsArray = new JsonArray();
metricsArray.add(metricsJson);
JsonObject result = new JsonObject();
result.add("metrics", metricsArray);
return Response.done(result);
} | if (score_model.isClassifier()) {
auc = new AUC();
// hr = new HitRatio();
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, auc, hr);
} else {
score_model.calcError(frame, frame.vec(score_model.responseName()), predictions, predictions, "Prediction error:",
true, 20, cm, null, null);
}
// Now call AUC and ConfusionMatrix and maybe HitRatio
metrics = new water.ModelMetrics(score_model.getUniqueId(),
score_model.getModelCategory(),
frame.getUniqueId(),
after - before,
after,
auc,
cm);
// Put the metrics into the KV store
metrics.putInDKV();
} else {
// it's already cached in the DKV
water.util.Log.debug("using ModelMetrics from the cache. . .");
}
JsonObject metricsJson = metrics.toJSON();
JsonArray metricsArray = new JsonArray();
metricsArray.add(metricsJson);
JsonObject result = new JsonObject();
result.add("metrics", metricsArray);
return Response.done(result);
} |
17,712 | 0 | // TODO: naive linear search of the token map | public Range<Token> getRange(ByteBuffer key)
{
// TODO: naive linear search of the token map
Token<?> t = partitioner.getToken(key);
for (Range<Token> range : rangeMap.keySet())
if (range.contains(t))
return range;
throw new RuntimeException("Invalid token information returned by describe_ring: " + rangeMap);
} | IMPLEMENTATION | true | public Range<Token> getRange(ByteBuffer key)
{
// TODO: naive linear search of the token map
Token<?> t = partitioner.getToken(key);
for (Range<Token> range : rangeMap.keySet()) | public Range<Token> getRange(ByteBuffer key)
{
// TODO: naive linear search of the token map
Token<?> t = partitioner.getToken(key);
for (Range<Token> range : rangeMap.keySet())
if (range.contains(t))
return range;
throw new RuntimeException("Invalid token information returned by describe_ring: " + rangeMap);
} | public Range<Token> getRange(ByteBuffer key)
{
// TODO: naive linear search of the token map
Token<?> t = partitioner.getToken(key);
for (Range<Token> range : rangeMap.keySet())
if (range.contains(t))
return range;
throw new RuntimeException("Invalid token information returned by describe_ring: " + rangeMap);
} |
34,098 | 0 | // todo: write your code here | @Override
public void runOpMode() {
telemetry.addData("Status", "Initialized");
telemetry.update();
left_mtr = hardwareMap.dcMotor.get("left_mtr");
right_mtr = hardwareMap.dcMotor.get("right_mtr");
front_left_mtr = hardwareMap.dcMotor.get("front_left_mtr");
front_right_mtr = hardwareMap.dcMotor.get("front_right_mtr");
Shooter = hardwareMap.dcMotor.get("Shooter");
Conveyor = hardwareMap.dcMotor.get("Conveyor");
clow_moter = hardwareMap.dcMotor.get("clow moter");
Claw = hardwareMap.servo.get("Claw");
touchfront = hardwareMap.touchSensor.get("touchfront");
touch2 = hardwareMap.touchSensor.get("touch2");
// values is a reference to the hsvValues array.
float[] hsvValues = new float[3];
final float values[] = hsvValues;
// bPrevState and bCurrState keep track of the previous and current state of the button
boolean bPrevState = false;
boolean bCurrState = false;
String mode="";
Claw.setPosition(0);
right_mtr.setDirection(DcMotorSimple.Direction.REVERSE);
right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
clow_moter.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
initVuforia();
initTfod();
/**
* Activate TensorFlow Object Detection before we wait for the start command.
* Do it here so that the Camera Stream window will have the TensorFlow annotations visible.
**/
if (tfod != null) {
tfod.activate();
// The TensorFlow software will scale the input images from the camera to a lower resolution.
// This can result in lower detection accuracy at longer distances (> 55cm or 22").
// If your target is at distance greater than 50 cm (20") you can adjust the magnification value
// to artificially zoom in to the center of image. For best results, the "aspectRatio" argument
// should be set to the value of the images used to create the TensorFlow Object Detection model
// (typically 1.78 or 16/9).
// Uncomment the following line if you want to adjust the magnification and/or the aspect ratio of the input images.
//tfod.setZoom(2.5, 1.78);
}
/** Wait for the game to begin */
telemetry.addData(">", "Press Play to start op mode");
telemetry.update();
waitForStart();
if (opModeIsActive()) {
halt();
sleep(1000);
turnRight(0.5);
haltSequence(450);
goForward(.5);
haltSequence(150);
turnLeft(.5);
haltSequence(450);
goForward(0.4);
sleep(450);
halt();
sleep(1000);
telemetry.addData("Status", "Started");
telemetry.update();
if (tfod != null) {
// getUpdatedRecognitions() will return null if no new information is available since
// the last time that call was made.
List<Recognition> updatedRecognitions = tfod.getUpdatedRecognitions();
if (updatedRecognitions != null) {
telemetry.addData("# Object Detected", updatedRecognitions.size());
if (updatedRecognitions.size() == 0) {
mode = "A";
}
// step through the list of recognitions and display boundary info.
int i = 0;
for (Recognition recognition : updatedRecognitions) {
telemetry.addData(String.format("label (%d)", i), recognition.getLabel());
if (recognition.getLabel() =="Quad"){
mode = "C";
} else {
mode = "B";
}
telemetry.addData(String.format(" left,top (%d)", i), "%.03f , %.03f",
recognition.getLeft(), recognition.getTop());
telemetry.addData(String.format(" right,bottom (%d)", i), "%.03f , %.03f",
recognition.getRight(), recognition.getBottom());
}
//telemetry.addData(String.format("Mode (%s)", mode), "");
telemetry.update();
sleep(2000);
}
}
}
// go somewhere based on mode
if (mode == "A") {
doModeA();
} else if (mode == "B") {
doModeB();
} else if (mode == "C") {
doModeC();
} else {
// not sure what to do here
}
if (tfod != null) {
tfod.shutdown();
}
} | IMPLEMENTATION | true | @Override
public void runOpMode() {
telemetry.addData("Status", "Initialized");
telemetry.update();
left_mtr = hardwareMap.dcMotor.get("left_mtr");
right_mtr = hardwareMap.dcMotor.get("right_mtr");
front_left_mtr = hardwareMap.dcMotor.get("front_left_mtr");
front_right_mtr = hardwareMap.dcMotor.get("front_right_mtr");
Shooter = hardwareMap.dcMotor.get("Shooter");
Conveyor = hardwareMap.dcMotor.get("Conveyor");
clow_moter = hardwareMap.dcMotor.get("clow moter");
Claw = hardwareMap.servo.get("Claw");
touchfront = hardwareMap.touchSensor.get("touchfront");
touch2 = hardwareMap.touchSensor.get("touch2");
// values is a reference to the hsvValues array.
float[] hsvValues = new float[3];
final float values[] = hsvValues;
// bPrevState and bCurrState keep track of the previous and current state of the button
boolean bPrevState = false;
boolean bCurrState = false;
String mode="";
Claw.setPosition(0);
right_mtr.setDirection(DcMotorSimple.Direction.REVERSE);
right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
clow_moter.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
initVuforia();
initTfod();
/**
* Activate TensorFlow Object Detection before we wait for the start command.
* Do it here so that the Camera Stream window will have the TensorFlow annotations visible.
**/
if (tfod != null) {
tfod.activate();
// The TensorFlow software will scale the input images from the camera to a lower resolution.
// This can result in lower detection accuracy at longer distances (> 55cm or 22").
// If your target is at distance greater than 50 cm (20") you can adjust the magnification value
// to artificially zoom in to the center of image. For best results, the "aspectRatio" argument
// should be set to the value of the images used to create the TensorFlow Object Detection model
// (typically 1.78 or 16/9).
// Uncomment the following line if you want to adjust the magnification and/or the aspect ratio of the input images.
//tfod.setZoom(2.5, 1.78);
}
/** Wait for the game to begin */
telemetry.addData(">", "Press Play to start op mode");
telemetry.update();
waitForStart();
if (opModeIsActive()) {
halt();
sleep(1000);
turnRight(0.5);
haltSequence(450);
goForward(.5);
haltSequence(150);
turnLeft(.5);
haltSequence(450);
goForward(0.4);
sleep(450);
halt();
sleep(1000);
telemetry.addData("Status", "Started");
telemetry.update();
if (tfod != null) {
// getUpdatedRecognitions() will return null if no new information is available since
// the last time that call was made.
List<Recognition> updatedRecognitions = tfod.getUpdatedRecognitions();
if (updatedRecognitions != null) {
telemetry.addData("# Object Detected", updatedRecognitions.size());
if (updatedRecognitions.size() == 0) {
mode = "A";
}
// step through the list of recognitions and display boundary info.
int i = 0;
for (Recognition recognition : updatedRecognitions) {
telemetry.addData(String.format("label (%d)", i), recognition.getLabel());
if (recognition.getLabel() =="Quad"){
mode = "C";
} else {
mode = "B";
}
telemetry.addData(String.format(" left,top (%d)", i), "%.03f , %.03f",
recognition.getLeft(), recognition.getTop());
telemetry.addData(String.format(" right,bottom (%d)", i), "%.03f , %.03f",
recognition.getRight(), recognition.getBottom());
}
//telemetry.addData(String.format("Mode (%s)", mode), "");
telemetry.update();
sleep(2000);
}
}
}
// go somewhere based on mode
if (mode == "A") {
doModeA();
} else if (mode == "B") {
doModeB();
} else if (mode == "C") {
doModeC();
} else {
// not sure what to do here
}
if (tfod != null) {
tfod.shutdown();
}
} | @Override
public void runOpMode() {
telemetry.addData("Status", "Initialized");
telemetry.update();
left_mtr = hardwareMap.dcMotor.get("left_mtr");
right_mtr = hardwareMap.dcMotor.get("right_mtr");
front_left_mtr = hardwareMap.dcMotor.get("front_left_mtr");
front_right_mtr = hardwareMap.dcMotor.get("front_right_mtr");
Shooter = hardwareMap.dcMotor.get("Shooter");
Conveyor = hardwareMap.dcMotor.get("Conveyor");
clow_moter = hardwareMap.dcMotor.get("clow moter");
Claw = hardwareMap.servo.get("Claw");
touchfront = hardwareMap.touchSensor.get("touchfront");
touch2 = hardwareMap.touchSensor.get("touch2");
// values is a reference to the hsvValues array.
float[] hsvValues = new float[3];
final float values[] = hsvValues;
// bPrevState and bCurrState keep track of the previous and current state of the button
boolean bPrevState = false;
boolean bCurrState = false;
String mode="";
Claw.setPosition(0);
right_mtr.setDirection(DcMotorSimple.Direction.REVERSE);
right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
clow_moter.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
initVuforia();
initTfod();
/**
* Activate TensorFlow Object Detection before we wait for the start command.
* Do it here so that the Camera Stream window will have the TensorFlow annotations visible.
**/
if (tfod != null) {
tfod.activate();
// The TensorFlow software will scale the input images from the camera to a lower resolution.
// This can result in lower detection accuracy at longer distances (> 55cm or 22").
// If your target is at distance greater than 50 cm (20") you can adjust the magnification value
// to artificially zoom in to the center of image. For best results, the "aspectRatio" argument
// should be set to the value of the images used to create the TensorFlow Object Detection model
// (typically 1.78 or 16/9).
// Uncomment the following line if you want to adjust the magnification and/or the aspect ratio of the input images.
//tfod.setZoom(2.5, 1.78);
}
/** Wait for the game to begin */
telemetry.addData(">", "Press Play to start op mode");
telemetry.update();
waitForStart();
if (opModeIsActive()) {
halt();
sleep(1000);
turnRight(0.5);
haltSequence(450);
goForward(.5);
haltSequence(150);
turnLeft(.5);
haltSequence(450);
goForward(0.4);
sleep(450);
halt();
sleep(1000);
telemetry.addData("Status", "Started");
telemetry.update();
if (tfod != null) {
// getUpdatedRecognitions() will return null if no new information is available since
// the last time that call was made.
List<Recognition> updatedRecognitions = tfod.getUpdatedRecognitions();
if (updatedRecognitions != null) {
telemetry.addData("# Object Detected", updatedRecognitions.size());
if (updatedRecognitions.size() == 0) {
mode = "A";
}
// step through the list of recognitions and display boundary info.
int i = 0;
for (Recognition recognition : updatedRecognitions) {
telemetry.addData(String.format("label (%d)", i), recognition.getLabel());
if (recognition.getLabel() =="Quad"){
mode = "C";
} else {
mode = "B";
}
telemetry.addData(String.format(" left,top (%d)", i), "%.03f , %.03f",
recognition.getLeft(), recognition.getTop());
telemetry.addData(String.format(" right,bottom (%d)", i), "%.03f , %.03f",
recognition.getRight(), recognition.getBottom());
}
//telemetry.addData(String.format("Mode (%s)", mode), "");
telemetry.update();
sleep(2000);
}
}
}
// go somewhere based on mode
if (mode == "A") {
doModeA();
} else if (mode == "B") {
doModeB();
} else if (mode == "C") {
doModeC();
} else {
// not sure what to do here
}
if (tfod != null) {
tfod.shutdown();
}
} | @Override
public void runOpMode() {
telemetry.addData("Status", "Initialized");
telemetry.update();
left_mtr = hardwareMap.dcMotor.get("left_mtr");
right_mtr = hardwareMap.dcMotor.get("right_mtr");
front_left_mtr = hardwareMap.dcMotor.get("front_left_mtr");
front_right_mtr = hardwareMap.dcMotor.get("front_right_mtr");
Shooter = hardwareMap.dcMotor.get("Shooter");
Conveyor = hardwareMap.dcMotor.get("Conveyor");
clow_moter = hardwareMap.dcMotor.get("clow moter");
Claw = hardwareMap.servo.get("Claw");
touchfront = hardwareMap.touchSensor.get("touchfront");
touch2 = hardwareMap.touchSensor.get("touch2");
// values is a reference to the hsvValues array.
float[] hsvValues = new float[3];
final float values[] = hsvValues;
// bPrevState and bCurrState keep track of the previous and current state of the button
boolean bPrevState = false;
boolean bCurrState = false;
String mode="";
Claw.setPosition(0);
right_mtr.setDirection(DcMotorSimple.Direction.REVERSE);
right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
clow_moter.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
initVuforia();
initTfod();
/**
* Activate TensorFlow Object Detection before we wait for the start command.
* Do it here so that the Camera Stream window will have the TensorFlow annotations visible.
**/
if (tfod != null) {
tfod.activate();
// The TensorFlow software will scale the input images from the camera to a lower resolution.
// This can result in lower detection accuracy at longer distances (> 55cm or 22").
// If your target is at distance greater than 50 cm (20") you can adjust the magnification value
// to artificially zoom in to the center of image. For best results, the "aspectRatio" argument
// should be set to the value of the images used to create the TensorFlow Object Detection model
// (typically 1.78 or 16/9).
// Uncomment the following line if you want to adjust the magnification and/or the aspect ratio of the input images.
//tfod.setZoom(2.5, 1.78);
}
/** Wait for the game to begin */
telemetry.addData(">", "Press Play to start op mode");
telemetry.update();
waitForStart();
if (opModeIsActive()) {
halt();
sleep(1000);
turnRight(0.5);
haltSequence(450);
goForward(.5);
haltSequence(150);
turnLeft(.5);
haltSequence(450);
goForward(0.4);
sleep(450);
halt();
sleep(1000);
telemetry.addData("Status", "Started");
telemetry.update();
if (tfod != null) {
// getUpdatedRecognitions() will return null if no new information is available since
// the last time that call was made.
List<Recognition> updatedRecognitions = tfod.getUpdatedRecognitions();
if (updatedRecognitions != null) {
telemetry.addData("# Object Detected", updatedRecognitions.size());
if (updatedRecognitions.size() == 0) {
mode = "A";
}
// step through the list of recognitions and display boundary info.
int i = 0;
for (Recognition recognition : updatedRecognitions) {
telemetry.addData(String.format("label (%d)", i), recognition.getLabel());
if (recognition.getLabel() =="Quad"){
mode = "C";
} else {
mode = "B";
}
telemetry.addData(String.format(" left,top (%d)", i), "%.03f , %.03f",
recognition.getLeft(), recognition.getTop());
telemetry.addData(String.format(" right,bottom (%d)", i), "%.03f , %.03f",
recognition.getRight(), recognition.getBottom());
}
//telemetry.addData(String.format("Mode (%s)", mode), "");
telemetry.update();
sleep(2000);
}
}
}
// go somewhere based on mode
if (mode == "A") {
doModeA();
} else if (mode == "B") {
doModeB();
} else if (mode == "C") {
doModeC();
} else {
// not sure what to do here
}
if (tfod != null) {
tfod.shutdown();
}
} |
34,098 | 1 | // values is a reference to the hsvValues array. | @Override
public void runOpMode() {
telemetry.addData("Status", "Initialized");
telemetry.update();
left_mtr = hardwareMap.dcMotor.get("left_mtr");
right_mtr = hardwareMap.dcMotor.get("right_mtr");
front_left_mtr = hardwareMap.dcMotor.get("front_left_mtr");
front_right_mtr = hardwareMap.dcMotor.get("front_right_mtr");
Shooter = hardwareMap.dcMotor.get("Shooter");
Conveyor = hardwareMap.dcMotor.get("Conveyor");
clow_moter = hardwareMap.dcMotor.get("clow moter");
Claw = hardwareMap.servo.get("Claw");
touchfront = hardwareMap.touchSensor.get("touchfront");
touch2 = hardwareMap.touchSensor.get("touch2");
// values is a reference to the hsvValues array.
float[] hsvValues = new float[3];
final float values[] = hsvValues;
// bPrevState and bCurrState keep track of the previous and current state of the button
boolean bPrevState = false;
boolean bCurrState = false;
String mode="";
Claw.setPosition(0);
right_mtr.setDirection(DcMotorSimple.Direction.REVERSE);
right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
clow_moter.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
initVuforia();
initTfod();
/**
* Activate TensorFlow Object Detection before we wait for the start command.
* Do it here so that the Camera Stream window will have the TensorFlow annotations visible.
**/
if (tfod != null) {
tfod.activate();
// The TensorFlow software will scale the input images from the camera to a lower resolution.
// This can result in lower detection accuracy at longer distances (> 55cm or 22").
// If your target is at distance greater than 50 cm (20") you can adjust the magnification value
// to artificially zoom in to the center of image. For best results, the "aspectRatio" argument
// should be set to the value of the images used to create the TensorFlow Object Detection model
// (typically 1.78 or 16/9).
// Uncomment the following line if you want to adjust the magnification and/or the aspect ratio of the input images.
//tfod.setZoom(2.5, 1.78);
}
/** Wait for the game to begin */
telemetry.addData(">", "Press Play to start op mode");
telemetry.update();
waitForStart();
if (opModeIsActive()) {
halt();
sleep(1000);
turnRight(0.5);
haltSequence(450);
goForward(.5);
haltSequence(150);
turnLeft(.5);
haltSequence(450);
goForward(0.4);
sleep(450);
halt();
sleep(1000);
telemetry.addData("Status", "Started");
telemetry.update();
if (tfod != null) {
// getUpdatedRecognitions() will return null if no new information is available since
// the last time that call was made.
List<Recognition> updatedRecognitions = tfod.getUpdatedRecognitions();
if (updatedRecognitions != null) {
telemetry.addData("# Object Detected", updatedRecognitions.size());
if (updatedRecognitions.size() == 0) {
mode = "A";
}
// step through the list of recognitions and display boundary info.
int i = 0;
for (Recognition recognition : updatedRecognitions) {
telemetry.addData(String.format("label (%d)", i), recognition.getLabel());
if (recognition.getLabel() =="Quad"){
mode = "C";
} else {
mode = "B";
}
telemetry.addData(String.format(" left,top (%d)", i), "%.03f , %.03f",
recognition.getLeft(), recognition.getTop());
telemetry.addData(String.format(" right,bottom (%d)", i), "%.03f , %.03f",
recognition.getRight(), recognition.getBottom());
}
//telemetry.addData(String.format("Mode (%s)", mode), "");
telemetry.update();
sleep(2000);
}
}
}
// go somewhere based on mode
if (mode == "A") {
doModeA();
} else if (mode == "B") {
doModeB();
} else if (mode == "C") {
doModeC();
} else {
// not sure what to do here
}
if (tfod != null) {
tfod.shutdown();
}
} | NONSATD | true | touchfront = hardwareMap.touchSensor.get("touchfront");
touch2 = hardwareMap.touchSensor.get("touch2");
// values is a reference to the hsvValues array.
float[] hsvValues = new float[3];
final float values[] = hsvValues; | left_mtr = hardwareMap.dcMotor.get("left_mtr");
right_mtr = hardwareMap.dcMotor.get("right_mtr");
front_left_mtr = hardwareMap.dcMotor.get("front_left_mtr");
front_right_mtr = hardwareMap.dcMotor.get("front_right_mtr");
Shooter = hardwareMap.dcMotor.get("Shooter");
Conveyor = hardwareMap.dcMotor.get("Conveyor");
clow_moter = hardwareMap.dcMotor.get("clow moter");
Claw = hardwareMap.servo.get("Claw");
touchfront = hardwareMap.touchSensor.get("touchfront");
touch2 = hardwareMap.touchSensor.get("touch2");
// values is a reference to the hsvValues array.
float[] hsvValues = new float[3];
final float values[] = hsvValues;
// bPrevState and bCurrState keep track of the previous and current state of the button
boolean bPrevState = false;
boolean bCurrState = false;
String mode="";
Claw.setPosition(0);
right_mtr.setDirection(DcMotorSimple.Direction.REVERSE);
right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE); | @Override
public void runOpMode() {
telemetry.addData("Status", "Initialized");
telemetry.update();
left_mtr = hardwareMap.dcMotor.get("left_mtr");
right_mtr = hardwareMap.dcMotor.get("right_mtr");
front_left_mtr = hardwareMap.dcMotor.get("front_left_mtr");
front_right_mtr = hardwareMap.dcMotor.get("front_right_mtr");
Shooter = hardwareMap.dcMotor.get("Shooter");
Conveyor = hardwareMap.dcMotor.get("Conveyor");
clow_moter = hardwareMap.dcMotor.get("clow moter");
Claw = hardwareMap.servo.get("Claw");
touchfront = hardwareMap.touchSensor.get("touchfront");
touch2 = hardwareMap.touchSensor.get("touch2");
// values is a reference to the hsvValues array.
float[] hsvValues = new float[3];
final float values[] = hsvValues;
// bPrevState and bCurrState keep track of the previous and current state of the button
boolean bPrevState = false;
boolean bCurrState = false;
String mode="";
Claw.setPosition(0);
right_mtr.setDirection(DcMotorSimple.Direction.REVERSE);
right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
clow_moter.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
initVuforia();
initTfod();
/** |
34,098 | 2 | // bPrevState and bCurrState keep track of the previous and current state of the button | @Override
public void runOpMode() {
telemetry.addData("Status", "Initialized");
telemetry.update();
left_mtr = hardwareMap.dcMotor.get("left_mtr");
right_mtr = hardwareMap.dcMotor.get("right_mtr");
front_left_mtr = hardwareMap.dcMotor.get("front_left_mtr");
front_right_mtr = hardwareMap.dcMotor.get("front_right_mtr");
Shooter = hardwareMap.dcMotor.get("Shooter");
Conveyor = hardwareMap.dcMotor.get("Conveyor");
clow_moter = hardwareMap.dcMotor.get("clow moter");
Claw = hardwareMap.servo.get("Claw");
touchfront = hardwareMap.touchSensor.get("touchfront");
touch2 = hardwareMap.touchSensor.get("touch2");
// values is a reference to the hsvValues array.
float[] hsvValues = new float[3];
final float values[] = hsvValues;
// bPrevState and bCurrState keep track of the previous and current state of the button
boolean bPrevState = false;
boolean bCurrState = false;
String mode="";
Claw.setPosition(0);
right_mtr.setDirection(DcMotorSimple.Direction.REVERSE);
right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
clow_moter.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
initVuforia();
initTfod();
/**
* Activate TensorFlow Object Detection before we wait for the start command.
* Do it here so that the Camera Stream window will have the TensorFlow annotations visible.
**/
if (tfod != null) {
tfod.activate();
// The TensorFlow software will scale the input images from the camera to a lower resolution.
// This can result in lower detection accuracy at longer distances (> 55cm or 22").
// If your target is at distance greater than 50 cm (20") you can adjust the magnification value
// to artificially zoom in to the center of image. For best results, the "aspectRatio" argument
// should be set to the value of the images used to create the TensorFlow Object Detection model
// (typically 1.78 or 16/9).
// Uncomment the following line if you want to adjust the magnification and/or the aspect ratio of the input images.
//tfod.setZoom(2.5, 1.78);
}
/** Wait for the game to begin */
telemetry.addData(">", "Press Play to start op mode");
telemetry.update();
waitForStart();
if (opModeIsActive()) {
halt();
sleep(1000);
turnRight(0.5);
haltSequence(450);
goForward(.5);
haltSequence(150);
turnLeft(.5);
haltSequence(450);
goForward(0.4);
sleep(450);
halt();
sleep(1000);
telemetry.addData("Status", "Started");
telemetry.update();
if (tfod != null) {
// getUpdatedRecognitions() will return null if no new information is available since
// the last time that call was made.
List<Recognition> updatedRecognitions = tfod.getUpdatedRecognitions();
if (updatedRecognitions != null) {
telemetry.addData("# Object Detected", updatedRecognitions.size());
if (updatedRecognitions.size() == 0) {
mode = "A";
}
// step through the list of recognitions and display boundary info.
int i = 0;
for (Recognition recognition : updatedRecognitions) {
telemetry.addData(String.format("label (%d)", i), recognition.getLabel());
if (recognition.getLabel() =="Quad"){
mode = "C";
} else {
mode = "B";
}
telemetry.addData(String.format(" left,top (%d)", i), "%.03f , %.03f",
recognition.getLeft(), recognition.getTop());
telemetry.addData(String.format(" right,bottom (%d)", i), "%.03f , %.03f",
recognition.getRight(), recognition.getBottom());
}
//telemetry.addData(String.format("Mode (%s)", mode), "");
telemetry.update();
sleep(2000);
}
}
}
// go somewhere based on mode
if (mode == "A") {
doModeA();
} else if (mode == "B") {
doModeB();
} else if (mode == "C") {
doModeC();
} else {
// not sure what to do here
}
if (tfod != null) {
tfod.shutdown();
}
} | NONSATD | true | float[] hsvValues = new float[3];
final float values[] = hsvValues;
// bPrevState and bCurrState keep track of the previous and current state of the button
boolean bPrevState = false;
boolean bCurrState = false; | front_right_mtr = hardwareMap.dcMotor.get("front_right_mtr");
Shooter = hardwareMap.dcMotor.get("Shooter");
Conveyor = hardwareMap.dcMotor.get("Conveyor");
clow_moter = hardwareMap.dcMotor.get("clow moter");
Claw = hardwareMap.servo.get("Claw");
touchfront = hardwareMap.touchSensor.get("touchfront");
touch2 = hardwareMap.touchSensor.get("touch2");
// values is a reference to the hsvValues array.
float[] hsvValues = new float[3];
final float values[] = hsvValues;
// bPrevState and bCurrState keep track of the previous and current state of the button
boolean bPrevState = false;
boolean bCurrState = false;
String mode="";
Claw.setPosition(0);
right_mtr.setDirection(DcMotorSimple.Direction.REVERSE);
right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
clow_moter.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE); | @Override
public void runOpMode() {
telemetry.addData("Status", "Initialized");
telemetry.update();
left_mtr = hardwareMap.dcMotor.get("left_mtr");
right_mtr = hardwareMap.dcMotor.get("right_mtr");
front_left_mtr = hardwareMap.dcMotor.get("front_left_mtr");
front_right_mtr = hardwareMap.dcMotor.get("front_right_mtr");
Shooter = hardwareMap.dcMotor.get("Shooter");
Conveyor = hardwareMap.dcMotor.get("Conveyor");
clow_moter = hardwareMap.dcMotor.get("clow moter");
Claw = hardwareMap.servo.get("Claw");
touchfront = hardwareMap.touchSensor.get("touchfront");
touch2 = hardwareMap.touchSensor.get("touch2");
// values is a reference to the hsvValues array.
float[] hsvValues = new float[3];
final float values[] = hsvValues;
// bPrevState and bCurrState keep track of the previous and current state of the button
boolean bPrevState = false;
boolean bCurrState = false;
String mode="";
Claw.setPosition(0);
right_mtr.setDirection(DcMotorSimple.Direction.REVERSE);
right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
clow_moter.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
initVuforia();
initTfod();
/**
* Activate TensorFlow Object Detection before we wait for the start command.
* Do it here so that the Camera Stream window will have the TensorFlow annotations visible.
**/ |
34,098 | 3 | /**
* Activate TensorFlow Object Detection before we wait for the start command.
* Do it here so that the Camera Stream window will have the TensorFlow annotations visible.
**/ | @Override
public void runOpMode() {
telemetry.addData("Status", "Initialized");
telemetry.update();
left_mtr = hardwareMap.dcMotor.get("left_mtr");
right_mtr = hardwareMap.dcMotor.get("right_mtr");
front_left_mtr = hardwareMap.dcMotor.get("front_left_mtr");
front_right_mtr = hardwareMap.dcMotor.get("front_right_mtr");
Shooter = hardwareMap.dcMotor.get("Shooter");
Conveyor = hardwareMap.dcMotor.get("Conveyor");
clow_moter = hardwareMap.dcMotor.get("clow moter");
Claw = hardwareMap.servo.get("Claw");
touchfront = hardwareMap.touchSensor.get("touchfront");
touch2 = hardwareMap.touchSensor.get("touch2");
// values is a reference to the hsvValues array.
float[] hsvValues = new float[3];
final float values[] = hsvValues;
// bPrevState and bCurrState keep track of the previous and current state of the button
boolean bPrevState = false;
boolean bCurrState = false;
String mode="";
Claw.setPosition(0);
right_mtr.setDirection(DcMotorSimple.Direction.REVERSE);
right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
clow_moter.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
initVuforia();
initTfod();
/**
* Activate TensorFlow Object Detection before we wait for the start command.
* Do it here so that the Camera Stream window will have the TensorFlow annotations visible.
**/
if (tfod != null) {
tfod.activate();
// The TensorFlow software will scale the input images from the camera to a lower resolution.
// This can result in lower detection accuracy at longer distances (> 55cm or 22").
// If your target is at distance greater than 50 cm (20") you can adjust the magnification value
// to artificially zoom in to the center of image. For best results, the "aspectRatio" argument
// should be set to the value of the images used to create the TensorFlow Object Detection model
// (typically 1.78 or 16/9).
// Uncomment the following line if you want to adjust the magnification and/or the aspect ratio of the input images.
//tfod.setZoom(2.5, 1.78);
}
/** Wait for the game to begin */
telemetry.addData(">", "Press Play to start op mode");
telemetry.update();
waitForStart();
if (opModeIsActive()) {
halt();
sleep(1000);
turnRight(0.5);
haltSequence(450);
goForward(.5);
haltSequence(150);
turnLeft(.5);
haltSequence(450);
goForward(0.4);
sleep(450);
halt();
sleep(1000);
telemetry.addData("Status", "Started");
telemetry.update();
if (tfod != null) {
// getUpdatedRecognitions() will return null if no new information is available since
// the last time that call was made.
List<Recognition> updatedRecognitions = tfod.getUpdatedRecognitions();
if (updatedRecognitions != null) {
telemetry.addData("# Object Detected", updatedRecognitions.size());
if (updatedRecognitions.size() == 0) {
mode = "A";
}
// step through the list of recognitions and display boundary info.
int i = 0;
for (Recognition recognition : updatedRecognitions) {
telemetry.addData(String.format("label (%d)", i), recognition.getLabel());
if (recognition.getLabel() =="Quad"){
mode = "C";
} else {
mode = "B";
}
telemetry.addData(String.format(" left,top (%d)", i), "%.03f , %.03f",
recognition.getLeft(), recognition.getTop());
telemetry.addData(String.format(" right,bottom (%d)", i), "%.03f , %.03f",
recognition.getRight(), recognition.getBottom());
}
//telemetry.addData(String.format("Mode (%s)", mode), "");
telemetry.update();
sleep(2000);
}
}
}
// go somewhere based on mode
if (mode == "A") {
doModeA();
} else if (mode == "B") {
doModeB();
} else if (mode == "C") {
doModeC();
} else {
// not sure what to do here
}
if (tfod != null) {
tfod.shutdown();
}
} | NONSATD | true | initVuforia();
initTfod();
/**
* Activate TensorFlow Object Detection before we wait for the start command.
* Do it here so that the Camera Stream window will have the TensorFlow annotations visible.
**/
if (tfod != null) {
tfod.activate(); | left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
clow_moter.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
initVuforia();
initTfod();
/**
* Activate TensorFlow Object Detection before we wait for the start command.
* Do it here so that the Camera Stream window will have the TensorFlow annotations visible.
**/
if (tfod != null) {
tfod.activate();
// The TensorFlow software will scale the input images from the camera to a lower resolution.
// This can result in lower detection accuracy at longer distances (> 55cm or 22").
// If your target is at distance greater than 50 cm (20") you can adjust the magnification value
// to artificially zoom in to the center of image. For best results, the "aspectRatio" argument
// should be set to the value of the images used to create the TensorFlow Object Detection model
// (typically 1.78 or 16/9).
// Uncomment the following line if you want to adjust the magnification and/or the aspect ratio of the input images.
//tfod.setZoom(2.5, 1.78); | // values is a reference to the hsvValues array.
float[] hsvValues = new float[3];
final float values[] = hsvValues;
// bPrevState and bCurrState keep track of the previous and current state of the button
boolean bPrevState = false;
boolean bCurrState = false;
String mode="";
Claw.setPosition(0);
right_mtr.setDirection(DcMotorSimple.Direction.REVERSE);
right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
clow_moter.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
initVuforia();
initTfod();
/**
* Activate TensorFlow Object Detection before we wait for the start command.
* Do it here so that the Camera Stream window will have the TensorFlow annotations visible.
**/
if (tfod != null) {
tfod.activate();
// The TensorFlow software will scale the input images from the camera to a lower resolution.
// This can result in lower detection accuracy at longer distances (> 55cm or 22").
// If your target is at distance greater than 50 cm (20") you can adjust the magnification value
// to artificially zoom in to the center of image. For best results, the "aspectRatio" argument
// should be set to the value of the images used to create the TensorFlow Object Detection model
// (typically 1.78 or 16/9).
// Uncomment the following line if you want to adjust the magnification and/or the aspect ratio of the input images.
//tfod.setZoom(2.5, 1.78);
}
/** Wait for the game to begin */
telemetry.addData(">", "Press Play to start op mode");
telemetry.update();
waitForStart();
if (opModeIsActive()) {
halt();
sleep(1000);
turnRight(0.5);
haltSequence(450); |
34,098 | 4 | // The TensorFlow software will scale the input images from the camera to a lower resolution.
// This can result in lower detection accuracy at longer distances (> 55cm or 22").
// If your target is at distance greater than 50 cm (20") you can adjust the magnification value
// to artificially zoom in to the center of image. For best results, the "aspectRatio" argument
// should be set to the value of the images used to create the TensorFlow Object Detection model
// (typically 1.78 or 16/9).
// Uncomment the following line if you want to adjust the magnification and/or the aspect ratio of the input images.
//tfod.setZoom(2.5, 1.78); | @Override
public void runOpMode() {
telemetry.addData("Status", "Initialized");
telemetry.update();
left_mtr = hardwareMap.dcMotor.get("left_mtr");
right_mtr = hardwareMap.dcMotor.get("right_mtr");
front_left_mtr = hardwareMap.dcMotor.get("front_left_mtr");
front_right_mtr = hardwareMap.dcMotor.get("front_right_mtr");
Shooter = hardwareMap.dcMotor.get("Shooter");
Conveyor = hardwareMap.dcMotor.get("Conveyor");
clow_moter = hardwareMap.dcMotor.get("clow moter");
Claw = hardwareMap.servo.get("Claw");
touchfront = hardwareMap.touchSensor.get("touchfront");
touch2 = hardwareMap.touchSensor.get("touch2");
// values is a reference to the hsvValues array.
float[] hsvValues = new float[3];
final float values[] = hsvValues;
// bPrevState and bCurrState keep track of the previous and current state of the button
boolean bPrevState = false;
boolean bCurrState = false;
String mode="";
Claw.setPosition(0);
right_mtr.setDirection(DcMotorSimple.Direction.REVERSE);
right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
clow_moter.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
initVuforia();
initTfod();
/**
* Activate TensorFlow Object Detection before we wait for the start command.
* Do it here so that the Camera Stream window will have the TensorFlow annotations visible.
**/
if (tfod != null) {
tfod.activate();
// The TensorFlow software will scale the input images from the camera to a lower resolution.
// This can result in lower detection accuracy at longer distances (> 55cm or 22").
// If your target is at distance greater than 50 cm (20") you can adjust the magnification value
// to artificially zoom in to the center of image. For best results, the "aspectRatio" argument
// should be set to the value of the images used to create the TensorFlow Object Detection model
// (typically 1.78 or 16/9).
// Uncomment the following line if you want to adjust the magnification and/or the aspect ratio of the input images.
//tfod.setZoom(2.5, 1.78);
}
/** Wait for the game to begin */
telemetry.addData(">", "Press Play to start op mode");
telemetry.update();
waitForStart();
if (opModeIsActive()) {
halt();
sleep(1000);
turnRight(0.5);
haltSequence(450);
goForward(.5);
haltSequence(150);
turnLeft(.5);
haltSequence(450);
goForward(0.4);
sleep(450);
halt();
sleep(1000);
telemetry.addData("Status", "Started");
telemetry.update();
if (tfod != null) {
// getUpdatedRecognitions() will return null if no new information is available since
// the last time that call was made.
List<Recognition> updatedRecognitions = tfod.getUpdatedRecognitions();
if (updatedRecognitions != null) {
telemetry.addData("# Object Detected", updatedRecognitions.size());
if (updatedRecognitions.size() == 0) {
mode = "A";
}
// step through the list of recognitions and display boundary info.
int i = 0;
for (Recognition recognition : updatedRecognitions) {
telemetry.addData(String.format("label (%d)", i), recognition.getLabel());
if (recognition.getLabel() =="Quad"){
mode = "C";
} else {
mode = "B";
}
telemetry.addData(String.format(" left,top (%d)", i), "%.03f , %.03f",
recognition.getLeft(), recognition.getTop());
telemetry.addData(String.format(" right,bottom (%d)", i), "%.03f , %.03f",
recognition.getRight(), recognition.getBottom());
}
//telemetry.addData(String.format("Mode (%s)", mode), "");
telemetry.update();
sleep(2000);
}
}
}
// go somewhere based on mode
if (mode == "A") {
doModeA();
} else if (mode == "B") {
doModeB();
} else if (mode == "C") {
doModeC();
} else {
// not sure what to do here
}
if (tfod != null) {
tfod.shutdown();
}
} | NONSATD | true | if (tfod != null) {
tfod.activate();
// The TensorFlow software will scale the input images from the camera to a lower resolution.
// This can result in lower detection accuracy at longer distances (> 55cm or 22").
// If your target is at distance greater than 50 cm (20") you can adjust the magnification value
// to artificially zoom in to the center of image. For best results, the "aspectRatio" argument
// should be set to the value of the images used to create the TensorFlow Object Detection model
// (typically 1.78 or 16/9).
// Uncomment the following line if you want to adjust the magnification and/or the aspect ratio of the input images.
//tfod.setZoom(2.5, 1.78);
}
/** Wait for the game to begin */ | front_right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
initVuforia();
initTfod();
/**
* Activate TensorFlow Object Detection before we wait for the start command.
* Do it here so that the Camera Stream window will have the TensorFlow annotations visible.
**/
if (tfod != null) {
tfod.activate();
// The TensorFlow software will scale the input images from the camera to a lower resolution.
// This can result in lower detection accuracy at longer distances (> 55cm or 22").
// If your target is at distance greater than 50 cm (20") you can adjust the magnification value
// to artificially zoom in to the center of image. For best results, the "aspectRatio" argument
// should be set to the value of the images used to create the TensorFlow Object Detection model
// (typically 1.78 or 16/9).
// Uncomment the following line if you want to adjust the magnification and/or the aspect ratio of the input images.
//tfod.setZoom(2.5, 1.78);
}
/** Wait for the game to begin */
telemetry.addData(">", "Press Play to start op mode");
telemetry.update();
waitForStart();
if (opModeIsActive()) {
halt();
sleep(1000);
turnRight(0.5);
haltSequence(450); | String mode="";
Claw.setPosition(0);
right_mtr.setDirection(DcMotorSimple.Direction.REVERSE);
right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
clow_moter.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
initVuforia();
initTfod();
/**
* Activate TensorFlow Object Detection before we wait for the start command.
* Do it here so that the Camera Stream window will have the TensorFlow annotations visible.
**/
if (tfod != null) {
tfod.activate();
// The TensorFlow software will scale the input images from the camera to a lower resolution.
// This can result in lower detection accuracy at longer distances (> 55cm or 22").
// If your target is at distance greater than 50 cm (20") you can adjust the magnification value
// to artificially zoom in to the center of image. For best results, the "aspectRatio" argument
// should be set to the value of the images used to create the TensorFlow Object Detection model
// (typically 1.78 or 16/9).
// Uncomment the following line if you want to adjust the magnification and/or the aspect ratio of the input images.
//tfod.setZoom(2.5, 1.78);
}
/** Wait for the game to begin */
telemetry.addData(">", "Press Play to start op mode");
telemetry.update();
waitForStart();
if (opModeIsActive()) {
halt();
sleep(1000);
turnRight(0.5);
haltSequence(450);
goForward(.5);
haltSequence(150);
turnLeft(.5);
haltSequence(450);
goForward(0.4);
sleep(450);
halt();
sleep(1000);
telemetry.addData("Status", "Started");
telemetry.update(); |
34,098 | 5 | /** Wait for the game to begin */ | @Override
public void runOpMode() {
telemetry.addData("Status", "Initialized");
telemetry.update();
left_mtr = hardwareMap.dcMotor.get("left_mtr");
right_mtr = hardwareMap.dcMotor.get("right_mtr");
front_left_mtr = hardwareMap.dcMotor.get("front_left_mtr");
front_right_mtr = hardwareMap.dcMotor.get("front_right_mtr");
Shooter = hardwareMap.dcMotor.get("Shooter");
Conveyor = hardwareMap.dcMotor.get("Conveyor");
clow_moter = hardwareMap.dcMotor.get("clow moter");
Claw = hardwareMap.servo.get("Claw");
touchfront = hardwareMap.touchSensor.get("touchfront");
touch2 = hardwareMap.touchSensor.get("touch2");
// values is a reference to the hsvValues array.
float[] hsvValues = new float[3];
final float values[] = hsvValues;
// bPrevState and bCurrState keep track of the previous and current state of the button
boolean bPrevState = false;
boolean bCurrState = false;
String mode="";
Claw.setPosition(0);
right_mtr.setDirection(DcMotorSimple.Direction.REVERSE);
right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
clow_moter.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
initVuforia();
initTfod();
/**
* Activate TensorFlow Object Detection before we wait for the start command.
* Do it here so that the Camera Stream window will have the TensorFlow annotations visible.
**/
if (tfod != null) {
tfod.activate();
// The TensorFlow software will scale the input images from the camera to a lower resolution.
// This can result in lower detection accuracy at longer distances (> 55cm or 22").
// If your target is at distance greater than 50 cm (20") you can adjust the magnification value
// to artificially zoom in to the center of image. For best results, the "aspectRatio" argument
// should be set to the value of the images used to create the TensorFlow Object Detection model
// (typically 1.78 or 16/9).
// Uncomment the following line if you want to adjust the magnification and/or the aspect ratio of the input images.
//tfod.setZoom(2.5, 1.78);
}
/** Wait for the game to begin */
telemetry.addData(">", "Press Play to start op mode");
telemetry.update();
waitForStart();
if (opModeIsActive()) {
halt();
sleep(1000);
turnRight(0.5);
haltSequence(450);
goForward(.5);
haltSequence(150);
turnLeft(.5);
haltSequence(450);
goForward(0.4);
sleep(450);
halt();
sleep(1000);
telemetry.addData("Status", "Started");
telemetry.update();
if (tfod != null) {
// getUpdatedRecognitions() will return null if no new information is available since
// the last time that call was made.
List<Recognition> updatedRecognitions = tfod.getUpdatedRecognitions();
if (updatedRecognitions != null) {
telemetry.addData("# Object Detected", updatedRecognitions.size());
if (updatedRecognitions.size() == 0) {
mode = "A";
}
// step through the list of recognitions and display boundary info.
int i = 0;
for (Recognition recognition : updatedRecognitions) {
telemetry.addData(String.format("label (%d)", i), recognition.getLabel());
if (recognition.getLabel() =="Quad"){
mode = "C";
} else {
mode = "B";
}
telemetry.addData(String.format(" left,top (%d)", i), "%.03f , %.03f",
recognition.getLeft(), recognition.getTop());
telemetry.addData(String.format(" right,bottom (%d)", i), "%.03f , %.03f",
recognition.getRight(), recognition.getBottom());
}
//telemetry.addData(String.format("Mode (%s)", mode), "");
telemetry.update();
sleep(2000);
}
}
}
// go somewhere based on mode
if (mode == "A") {
doModeA();
} else if (mode == "B") {
doModeB();
} else if (mode == "C") {
doModeC();
} else {
// not sure what to do here
}
if (tfod != null) {
tfod.shutdown();
}
} | NONSATD | true | //tfod.setZoom(2.5, 1.78);
}
/** Wait for the game to begin */
telemetry.addData(">", "Press Play to start op mode");
telemetry.update(); | tfod.activate();
// The TensorFlow software will scale the input images from the camera to a lower resolution.
// This can result in lower detection accuracy at longer distances (> 55cm or 22").
// If your target is at distance greater than 50 cm (20") you can adjust the magnification value
// to artificially zoom in to the center of image. For best results, the "aspectRatio" argument
// should be set to the value of the images used to create the TensorFlow Object Detection model
// (typically 1.78 or 16/9).
// Uncomment the following line if you want to adjust the magnification and/or the aspect ratio of the input images.
//tfod.setZoom(2.5, 1.78);
}
/** Wait for the game to begin */
telemetry.addData(">", "Press Play to start op mode");
telemetry.update();
waitForStart();
if (opModeIsActive()) {
halt();
sleep(1000);
turnRight(0.5);
haltSequence(450);
goForward(.5);
haltSequence(150); | left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
initVuforia();
initTfod();
/**
* Activate TensorFlow Object Detection before we wait for the start command.
* Do it here so that the Camera Stream window will have the TensorFlow annotations visible.
**/
if (tfod != null) {
tfod.activate();
// The TensorFlow software will scale the input images from the camera to a lower resolution.
// This can result in lower detection accuracy at longer distances (> 55cm or 22").
// If your target is at distance greater than 50 cm (20") you can adjust the magnification value
// to artificially zoom in to the center of image. For best results, the "aspectRatio" argument
// should be set to the value of the images used to create the TensorFlow Object Detection model
// (typically 1.78 or 16/9).
// Uncomment the following line if you want to adjust the magnification and/or the aspect ratio of the input images.
//tfod.setZoom(2.5, 1.78);
}
/** Wait for the game to begin */
telemetry.addData(">", "Press Play to start op mode");
telemetry.update();
waitForStart();
if (opModeIsActive()) {
halt();
sleep(1000);
turnRight(0.5);
haltSequence(450);
goForward(.5);
haltSequence(150);
turnLeft(.5);
haltSequence(450);
goForward(0.4);
sleep(450);
halt();
sleep(1000);
telemetry.addData("Status", "Started");
telemetry.update();
if (tfod != null) {
// getUpdatedRecognitions() will return null if no new information is available since |
34,098 | 6 | // getUpdatedRecognitions() will return null if no new information is available since
// the last time that call was made. | @Override
public void runOpMode() {
telemetry.addData("Status", "Initialized");
telemetry.update();
left_mtr = hardwareMap.dcMotor.get("left_mtr");
right_mtr = hardwareMap.dcMotor.get("right_mtr");
front_left_mtr = hardwareMap.dcMotor.get("front_left_mtr");
front_right_mtr = hardwareMap.dcMotor.get("front_right_mtr");
Shooter = hardwareMap.dcMotor.get("Shooter");
Conveyor = hardwareMap.dcMotor.get("Conveyor");
clow_moter = hardwareMap.dcMotor.get("clow moter");
Claw = hardwareMap.servo.get("Claw");
touchfront = hardwareMap.touchSensor.get("touchfront");
touch2 = hardwareMap.touchSensor.get("touch2");
// values is a reference to the hsvValues array.
float[] hsvValues = new float[3];
final float values[] = hsvValues;
// bPrevState and bCurrState keep track of the previous and current state of the button
boolean bPrevState = false;
boolean bCurrState = false;
String mode="";
Claw.setPosition(0);
right_mtr.setDirection(DcMotorSimple.Direction.REVERSE);
right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
clow_moter.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
initVuforia();
initTfod();
/**
* Activate TensorFlow Object Detection before we wait for the start command.
* Do it here so that the Camera Stream window will have the TensorFlow annotations visible.
**/
if (tfod != null) {
tfod.activate();
// The TensorFlow software will scale the input images from the camera to a lower resolution.
// This can result in lower detection accuracy at longer distances (> 55cm or 22").
// If your target is at distance greater than 50 cm (20") you can adjust the magnification value
// to artificially zoom in to the center of image. For best results, the "aspectRatio" argument
// should be set to the value of the images used to create the TensorFlow Object Detection model
// (typically 1.78 or 16/9).
// Uncomment the following line if you want to adjust the magnification and/or the aspect ratio of the input images.
//tfod.setZoom(2.5, 1.78);
}
/** Wait for the game to begin */
telemetry.addData(">", "Press Play to start op mode");
telemetry.update();
waitForStart();
if (opModeIsActive()) {
halt();
sleep(1000);
turnRight(0.5);
haltSequence(450);
goForward(.5);
haltSequence(150);
turnLeft(.5);
haltSequence(450);
goForward(0.4);
sleep(450);
halt();
sleep(1000);
telemetry.addData("Status", "Started");
telemetry.update();
if (tfod != null) {
// getUpdatedRecognitions() will return null if no new information is available since
// the last time that call was made.
List<Recognition> updatedRecognitions = tfod.getUpdatedRecognitions();
if (updatedRecognitions != null) {
telemetry.addData("# Object Detected", updatedRecognitions.size());
if (updatedRecognitions.size() == 0) {
mode = "A";
}
// step through the list of recognitions and display boundary info.
int i = 0;
for (Recognition recognition : updatedRecognitions) {
telemetry.addData(String.format("label (%d)", i), recognition.getLabel());
if (recognition.getLabel() =="Quad"){
mode = "C";
} else {
mode = "B";
}
telemetry.addData(String.format(" left,top (%d)", i), "%.03f , %.03f",
recognition.getLeft(), recognition.getTop());
telemetry.addData(String.format(" right,bottom (%d)", i), "%.03f , %.03f",
recognition.getRight(), recognition.getBottom());
}
//telemetry.addData(String.format("Mode (%s)", mode), "");
telemetry.update();
sleep(2000);
}
}
}
// go somewhere based on mode
if (mode == "A") {
doModeA();
} else if (mode == "B") {
doModeB();
} else if (mode == "C") {
doModeC();
} else {
// not sure what to do here
}
if (tfod != null) {
tfod.shutdown();
}
} | NONSATD | true | telemetry.update();
if (tfod != null) {
// getUpdatedRecognitions() will return null if no new information is available since
// the last time that call was made.
List<Recognition> updatedRecognitions = tfod.getUpdatedRecognitions();
if (updatedRecognitions != null) { | haltSequence(150);
turnLeft(.5);
haltSequence(450);
goForward(0.4);
sleep(450);
halt();
sleep(1000);
telemetry.addData("Status", "Started");
telemetry.update();
if (tfod != null) {
// getUpdatedRecognitions() will return null if no new information is available since
// the last time that call was made.
List<Recognition> updatedRecognitions = tfod.getUpdatedRecognitions();
if (updatedRecognitions != null) {
telemetry.addData("# Object Detected", updatedRecognitions.size());
if (updatedRecognitions.size() == 0) {
mode = "A";
}
// step through the list of recognitions and display boundary info.
int i = 0;
for (Recognition recognition : updatedRecognitions) {
telemetry.addData(String.format("label (%d)", i), recognition.getLabel()); | /** Wait for the game to begin */
telemetry.addData(">", "Press Play to start op mode");
telemetry.update();
waitForStart();
if (opModeIsActive()) {
halt();
sleep(1000);
turnRight(0.5);
haltSequence(450);
goForward(.5);
haltSequence(150);
turnLeft(.5);
haltSequence(450);
goForward(0.4);
sleep(450);
halt();
sleep(1000);
telemetry.addData("Status", "Started");
telemetry.update();
if (tfod != null) {
// getUpdatedRecognitions() will return null if no new information is available since
// the last time that call was made.
List<Recognition> updatedRecognitions = tfod.getUpdatedRecognitions();
if (updatedRecognitions != null) {
telemetry.addData("# Object Detected", updatedRecognitions.size());
if (updatedRecognitions.size() == 0) {
mode = "A";
}
// step through the list of recognitions and display boundary info.
int i = 0;
for (Recognition recognition : updatedRecognitions) {
telemetry.addData(String.format("label (%d)", i), recognition.getLabel());
if (recognition.getLabel() =="Quad"){
mode = "C";
} else {
mode = "B";
}
telemetry.addData(String.format(" left,top (%d)", i), "%.03f , %.03f",
recognition.getLeft(), recognition.getTop());
telemetry.addData(String.format(" right,bottom (%d)", i), "%.03f , %.03f",
recognition.getRight(), recognition.getBottom());
} |
34,098 | 7 | // step through the list of recognitions and display boundary info. | @Override
public void runOpMode() {
telemetry.addData("Status", "Initialized");
telemetry.update();
left_mtr = hardwareMap.dcMotor.get("left_mtr");
right_mtr = hardwareMap.dcMotor.get("right_mtr");
front_left_mtr = hardwareMap.dcMotor.get("front_left_mtr");
front_right_mtr = hardwareMap.dcMotor.get("front_right_mtr");
Shooter = hardwareMap.dcMotor.get("Shooter");
Conveyor = hardwareMap.dcMotor.get("Conveyor");
clow_moter = hardwareMap.dcMotor.get("clow moter");
Claw = hardwareMap.servo.get("Claw");
touchfront = hardwareMap.touchSensor.get("touchfront");
touch2 = hardwareMap.touchSensor.get("touch2");
// values is a reference to the hsvValues array.
float[] hsvValues = new float[3];
final float values[] = hsvValues;
// bPrevState and bCurrState keep track of the previous and current state of the button
boolean bPrevState = false;
boolean bCurrState = false;
String mode="";
Claw.setPosition(0);
right_mtr.setDirection(DcMotorSimple.Direction.REVERSE);
right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
clow_moter.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
initVuforia();
initTfod();
/**
* Activate TensorFlow Object Detection before we wait for the start command.
* Do it here so that the Camera Stream window will have the TensorFlow annotations visible.
**/
if (tfod != null) {
tfod.activate();
// The TensorFlow software will scale the input images from the camera to a lower resolution.
// This can result in lower detection accuracy at longer distances (> 55cm or 22").
// If your target is at distance greater than 50 cm (20") you can adjust the magnification value
// to artificially zoom in to the center of image. For best results, the "aspectRatio" argument
// should be set to the value of the images used to create the TensorFlow Object Detection model
// (typically 1.78 or 16/9).
// Uncomment the following line if you want to adjust the magnification and/or the aspect ratio of the input images.
//tfod.setZoom(2.5, 1.78);
}
/** Wait for the game to begin */
telemetry.addData(">", "Press Play to start op mode");
telemetry.update();
waitForStart();
if (opModeIsActive()) {
halt();
sleep(1000);
turnRight(0.5);
haltSequence(450);
goForward(.5);
haltSequence(150);
turnLeft(.5);
haltSequence(450);
goForward(0.4);
sleep(450);
halt();
sleep(1000);
telemetry.addData("Status", "Started");
telemetry.update();
if (tfod != null) {
// getUpdatedRecognitions() will return null if no new information is available since
// the last time that call was made.
List<Recognition> updatedRecognitions = tfod.getUpdatedRecognitions();
if (updatedRecognitions != null) {
telemetry.addData("# Object Detected", updatedRecognitions.size());
if (updatedRecognitions.size() == 0) {
mode = "A";
}
// step through the list of recognitions and display boundary info.
int i = 0;
for (Recognition recognition : updatedRecognitions) {
telemetry.addData(String.format("label (%d)", i), recognition.getLabel());
if (recognition.getLabel() =="Quad"){
mode = "C";
} else {
mode = "B";
}
telemetry.addData(String.format(" left,top (%d)", i), "%.03f , %.03f",
recognition.getLeft(), recognition.getTop());
telemetry.addData(String.format(" right,bottom (%d)", i), "%.03f , %.03f",
recognition.getRight(), recognition.getBottom());
}
//telemetry.addData(String.format("Mode (%s)", mode), "");
telemetry.update();
sleep(2000);
}
}
}
// go somewhere based on mode
if (mode == "A") {
doModeA();
} else if (mode == "B") {
doModeB();
} else if (mode == "C") {
doModeC();
} else {
// not sure what to do here
}
if (tfod != null) {
tfod.shutdown();
}
} | NONSATD | true | mode = "A";
}
// step through the list of recognitions and display boundary info.
int i = 0;
for (Recognition recognition : updatedRecognitions) { | telemetry.update();
if (tfod != null) {
// getUpdatedRecognitions() will return null if no new information is available since
// the last time that call was made.
List<Recognition> updatedRecognitions = tfod.getUpdatedRecognitions();
if (updatedRecognitions != null) {
telemetry.addData("# Object Detected", updatedRecognitions.size());
if (updatedRecognitions.size() == 0) {
mode = "A";
}
// step through the list of recognitions and display boundary info.
int i = 0;
for (Recognition recognition : updatedRecognitions) {
telemetry.addData(String.format("label (%d)", i), recognition.getLabel());
if (recognition.getLabel() =="Quad"){
mode = "C";
} else {
mode = "B";
}
telemetry.addData(String.format(" left,top (%d)", i), "%.03f , %.03f",
recognition.getLeft(), recognition.getTop()); | haltSequence(450);
goForward(.5);
haltSequence(150);
turnLeft(.5);
haltSequence(450);
goForward(0.4);
sleep(450);
halt();
sleep(1000);
telemetry.addData("Status", "Started");
telemetry.update();
if (tfod != null) {
// getUpdatedRecognitions() will return null if no new information is available since
// the last time that call was made.
List<Recognition> updatedRecognitions = tfod.getUpdatedRecognitions();
if (updatedRecognitions != null) {
telemetry.addData("# Object Detected", updatedRecognitions.size());
if (updatedRecognitions.size() == 0) {
mode = "A";
}
// step through the list of recognitions and display boundary info.
int i = 0;
for (Recognition recognition : updatedRecognitions) {
telemetry.addData(String.format("label (%d)", i), recognition.getLabel());
if (recognition.getLabel() =="Quad"){
mode = "C";
} else {
mode = "B";
}
telemetry.addData(String.format(" left,top (%d)", i), "%.03f , %.03f",
recognition.getLeft(), recognition.getTop());
telemetry.addData(String.format(" right,bottom (%d)", i), "%.03f , %.03f",
recognition.getRight(), recognition.getBottom());
}
//telemetry.addData(String.format("Mode (%s)", mode), "");
telemetry.update();
sleep(2000);
}
}
}
// go somewhere based on mode |
34,098 | 8 | //telemetry.addData(String.format("Mode (%s)", mode), ""); | @Override
public void runOpMode() {
telemetry.addData("Status", "Initialized");
telemetry.update();
left_mtr = hardwareMap.dcMotor.get("left_mtr");
right_mtr = hardwareMap.dcMotor.get("right_mtr");
front_left_mtr = hardwareMap.dcMotor.get("front_left_mtr");
front_right_mtr = hardwareMap.dcMotor.get("front_right_mtr");
Shooter = hardwareMap.dcMotor.get("Shooter");
Conveyor = hardwareMap.dcMotor.get("Conveyor");
clow_moter = hardwareMap.dcMotor.get("clow moter");
Claw = hardwareMap.servo.get("Claw");
touchfront = hardwareMap.touchSensor.get("touchfront");
touch2 = hardwareMap.touchSensor.get("touch2");
// values is a reference to the hsvValues array.
float[] hsvValues = new float[3];
final float values[] = hsvValues;
// bPrevState and bCurrState keep track of the previous and current state of the button
boolean bPrevState = false;
boolean bCurrState = false;
String mode="";
Claw.setPosition(0);
right_mtr.setDirection(DcMotorSimple.Direction.REVERSE);
right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
clow_moter.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
initVuforia();
initTfod();
/**
* Activate TensorFlow Object Detection before we wait for the start command.
* Do it here so that the Camera Stream window will have the TensorFlow annotations visible.
**/
if (tfod != null) {
tfod.activate();
// The TensorFlow software will scale the input images from the camera to a lower resolution.
// This can result in lower detection accuracy at longer distances (> 55cm or 22").
// If your target is at distance greater than 50 cm (20") you can adjust the magnification value
// to artificially zoom in to the center of image. For best results, the "aspectRatio" argument
// should be set to the value of the images used to create the TensorFlow Object Detection model
// (typically 1.78 or 16/9).
// Uncomment the following line if you want to adjust the magnification and/or the aspect ratio of the input images.
//tfod.setZoom(2.5, 1.78);
}
/** Wait for the game to begin */
telemetry.addData(">", "Press Play to start op mode");
telemetry.update();
waitForStart();
if (opModeIsActive()) {
halt();
sleep(1000);
turnRight(0.5);
haltSequence(450);
goForward(.5);
haltSequence(150);
turnLeft(.5);
haltSequence(450);
goForward(0.4);
sleep(450);
halt();
sleep(1000);
telemetry.addData("Status", "Started");
telemetry.update();
if (tfod != null) {
// getUpdatedRecognitions() will return null if no new information is available since
// the last time that call was made.
List<Recognition> updatedRecognitions = tfod.getUpdatedRecognitions();
if (updatedRecognitions != null) {
telemetry.addData("# Object Detected", updatedRecognitions.size());
if (updatedRecognitions.size() == 0) {
mode = "A";
}
// step through the list of recognitions and display boundary info.
int i = 0;
for (Recognition recognition : updatedRecognitions) {
telemetry.addData(String.format("label (%d)", i), recognition.getLabel());
if (recognition.getLabel() =="Quad"){
mode = "C";
} else {
mode = "B";
}
telemetry.addData(String.format(" left,top (%d)", i), "%.03f , %.03f",
recognition.getLeft(), recognition.getTop());
telemetry.addData(String.format(" right,bottom (%d)", i), "%.03f , %.03f",
recognition.getRight(), recognition.getBottom());
}
//telemetry.addData(String.format("Mode (%s)", mode), "");
telemetry.update();
sleep(2000);
}
}
}
// go somewhere based on mode
if (mode == "A") {
doModeA();
} else if (mode == "B") {
doModeB();
} else if (mode == "C") {
doModeC();
} else {
// not sure what to do here
}
if (tfod != null) {
tfod.shutdown();
}
} | NONSATD | true | recognition.getRight(), recognition.getBottom());
}
//telemetry.addData(String.format("Mode (%s)", mode), "");
telemetry.update();
sleep(2000); | if (recognition.getLabel() =="Quad"){
mode = "C";
} else {
mode = "B";
}
telemetry.addData(String.format(" left,top (%d)", i), "%.03f , %.03f",
recognition.getLeft(), recognition.getTop());
telemetry.addData(String.format(" right,bottom (%d)", i), "%.03f , %.03f",
recognition.getRight(), recognition.getBottom());
}
//telemetry.addData(String.format("Mode (%s)", mode), "");
telemetry.update();
sleep(2000);
}
}
}
// go somewhere based on mode
if (mode == "A") {
doModeA();
} else if (mode == "B") {
doModeB(); | List<Recognition> updatedRecognitions = tfod.getUpdatedRecognitions();
if (updatedRecognitions != null) {
telemetry.addData("# Object Detected", updatedRecognitions.size());
if (updatedRecognitions.size() == 0) {
mode = "A";
}
// step through the list of recognitions and display boundary info.
int i = 0;
for (Recognition recognition : updatedRecognitions) {
telemetry.addData(String.format("label (%d)", i), recognition.getLabel());
if (recognition.getLabel() =="Quad"){
mode = "C";
} else {
mode = "B";
}
telemetry.addData(String.format(" left,top (%d)", i), "%.03f , %.03f",
recognition.getLeft(), recognition.getTop());
telemetry.addData(String.format(" right,bottom (%d)", i), "%.03f , %.03f",
recognition.getRight(), recognition.getBottom());
}
//telemetry.addData(String.format("Mode (%s)", mode), "");
telemetry.update();
sleep(2000);
}
}
}
// go somewhere based on mode
if (mode == "A") {
doModeA();
} else if (mode == "B") {
doModeB();
} else if (mode == "C") {
doModeC();
} else {
// not sure what to do here
}
if (tfod != null) {
tfod.shutdown();
}
} |
34,098 | 9 | // go somewhere based on mode | @Override
public void runOpMode() {
telemetry.addData("Status", "Initialized");
telemetry.update();
left_mtr = hardwareMap.dcMotor.get("left_mtr");
right_mtr = hardwareMap.dcMotor.get("right_mtr");
front_left_mtr = hardwareMap.dcMotor.get("front_left_mtr");
front_right_mtr = hardwareMap.dcMotor.get("front_right_mtr");
Shooter = hardwareMap.dcMotor.get("Shooter");
Conveyor = hardwareMap.dcMotor.get("Conveyor");
clow_moter = hardwareMap.dcMotor.get("clow moter");
Claw = hardwareMap.servo.get("Claw");
touchfront = hardwareMap.touchSensor.get("touchfront");
touch2 = hardwareMap.touchSensor.get("touch2");
// values is a reference to the hsvValues array.
float[] hsvValues = new float[3];
final float values[] = hsvValues;
// bPrevState and bCurrState keep track of the previous and current state of the button
boolean bPrevState = false;
boolean bCurrState = false;
String mode="";
Claw.setPosition(0);
right_mtr.setDirection(DcMotorSimple.Direction.REVERSE);
right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
clow_moter.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
initVuforia();
initTfod();
/**
* Activate TensorFlow Object Detection before we wait for the start command.
* Do it here so that the Camera Stream window will have the TensorFlow annotations visible.
**/
if (tfod != null) {
tfod.activate();
// The TensorFlow software will scale the input images from the camera to a lower resolution.
// This can result in lower detection accuracy at longer distances (> 55cm or 22").
// If your target is at distance greater than 50 cm (20") you can adjust the magnification value
// to artificially zoom in to the center of image. For best results, the "aspectRatio" argument
// should be set to the value of the images used to create the TensorFlow Object Detection model
// (typically 1.78 or 16/9).
// Uncomment the following line if you want to adjust the magnification and/or the aspect ratio of the input images.
//tfod.setZoom(2.5, 1.78);
}
/** Wait for the game to begin */
telemetry.addData(">", "Press Play to start op mode");
telemetry.update();
waitForStart();
if (opModeIsActive()) {
halt();
sleep(1000);
turnRight(0.5);
haltSequence(450);
goForward(.5);
haltSequence(150);
turnLeft(.5);
haltSequence(450);
goForward(0.4);
sleep(450);
halt();
sleep(1000);
telemetry.addData("Status", "Started");
telemetry.update();
if (tfod != null) {
// getUpdatedRecognitions() will return null if no new information is available since
// the last time that call was made.
List<Recognition> updatedRecognitions = tfod.getUpdatedRecognitions();
if (updatedRecognitions != null) {
telemetry.addData("# Object Detected", updatedRecognitions.size());
if (updatedRecognitions.size() == 0) {
mode = "A";
}
// step through the list of recognitions and display boundary info.
int i = 0;
for (Recognition recognition : updatedRecognitions) {
telemetry.addData(String.format("label (%d)", i), recognition.getLabel());
if (recognition.getLabel() =="Quad"){
mode = "C";
} else {
mode = "B";
}
telemetry.addData(String.format(" left,top (%d)", i), "%.03f , %.03f",
recognition.getLeft(), recognition.getTop());
telemetry.addData(String.format(" right,bottom (%d)", i), "%.03f , %.03f",
recognition.getRight(), recognition.getBottom());
}
//telemetry.addData(String.format("Mode (%s)", mode), "");
telemetry.update();
sleep(2000);
}
}
}
// go somewhere based on mode
if (mode == "A") {
doModeA();
} else if (mode == "B") {
doModeB();
} else if (mode == "C") {
doModeC();
} else {
// not sure what to do here
}
if (tfod != null) {
tfod.shutdown();
}
} | NONSATD | true | }
}
// go somewhere based on mode
if (mode == "A") {
doModeA(); | recognition.getLeft(), recognition.getTop());
telemetry.addData(String.format(" right,bottom (%d)", i), "%.03f , %.03f",
recognition.getRight(), recognition.getBottom());
}
//telemetry.addData(String.format("Mode (%s)", mode), "");
telemetry.update();
sleep(2000);
}
}
}
// go somewhere based on mode
if (mode == "A") {
doModeA();
} else if (mode == "B") {
doModeB();
} else if (mode == "C") {
doModeC();
} else {
// not sure what to do here
}
if (tfod != null) { | // step through the list of recognitions and display boundary info.
int i = 0;
for (Recognition recognition : updatedRecognitions) {
telemetry.addData(String.format("label (%d)", i), recognition.getLabel());
if (recognition.getLabel() =="Quad"){
mode = "C";
} else {
mode = "B";
}
telemetry.addData(String.format(" left,top (%d)", i), "%.03f , %.03f",
recognition.getLeft(), recognition.getTop());
telemetry.addData(String.format(" right,bottom (%d)", i), "%.03f , %.03f",
recognition.getRight(), recognition.getBottom());
}
//telemetry.addData(String.format("Mode (%s)", mode), "");
telemetry.update();
sleep(2000);
}
}
}
// go somewhere based on mode
if (mode == "A") {
doModeA();
} else if (mode == "B") {
doModeB();
} else if (mode == "C") {
doModeC();
} else {
// not sure what to do here
}
if (tfod != null) {
tfod.shutdown();
}
} |
34,098 | 10 | // not sure what to do here | @Override
public void runOpMode() {
telemetry.addData("Status", "Initialized");
telemetry.update();
left_mtr = hardwareMap.dcMotor.get("left_mtr");
right_mtr = hardwareMap.dcMotor.get("right_mtr");
front_left_mtr = hardwareMap.dcMotor.get("front_left_mtr");
front_right_mtr = hardwareMap.dcMotor.get("front_right_mtr");
Shooter = hardwareMap.dcMotor.get("Shooter");
Conveyor = hardwareMap.dcMotor.get("Conveyor");
clow_moter = hardwareMap.dcMotor.get("clow moter");
Claw = hardwareMap.servo.get("Claw");
touchfront = hardwareMap.touchSensor.get("touchfront");
touch2 = hardwareMap.touchSensor.get("touch2");
// values is a reference to the hsvValues array.
float[] hsvValues = new float[3];
final float values[] = hsvValues;
// bPrevState and bCurrState keep track of the previous and current state of the button
boolean bPrevState = false;
boolean bCurrState = false;
String mode="";
Claw.setPosition(0);
right_mtr.setDirection(DcMotorSimple.Direction.REVERSE);
right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_right_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
front_left_mtr.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
clow_moter.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_right_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
front_left_mtr.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
initVuforia();
initTfod();
/**
* Activate TensorFlow Object Detection before we wait for the start command.
* Do it here so that the Camera Stream window will have the TensorFlow annotations visible.
**/
if (tfod != null) {
tfod.activate();
// The TensorFlow software will scale the input images from the camera to a lower resolution.
// This can result in lower detection accuracy at longer distances (> 55cm or 22").
// If your target is at distance greater than 50 cm (20") you can adjust the magnification value
// to artificially zoom in to the center of image. For best results, the "aspectRatio" argument
// should be set to the value of the images used to create the TensorFlow Object Detection model
// (typically 1.78 or 16/9).
// Uncomment the following line if you want to adjust the magnification and/or the aspect ratio of the input images.
//tfod.setZoom(2.5, 1.78);
}
/** Wait for the game to begin */
telemetry.addData(">", "Press Play to start op mode");
telemetry.update();
waitForStart();
if (opModeIsActive()) {
halt();
sleep(1000);
turnRight(0.5);
haltSequence(450);
goForward(.5);
haltSequence(150);
turnLeft(.5);
haltSequence(450);
goForward(0.4);
sleep(450);
halt();
sleep(1000);
telemetry.addData("Status", "Started");
telemetry.update();
if (tfod != null) {
// getUpdatedRecognitions() will return null if no new information is available since
// the last time that call was made.
List<Recognition> updatedRecognitions = tfod.getUpdatedRecognitions();
if (updatedRecognitions != null) {
telemetry.addData("# Object Detected", updatedRecognitions.size());
if (updatedRecognitions.size() == 0) {
mode = "A";
}
// step through the list of recognitions and display boundary info.
int i = 0;
for (Recognition recognition : updatedRecognitions) {
telemetry.addData(String.format("label (%d)", i), recognition.getLabel());
if (recognition.getLabel() =="Quad"){
mode = "C";
} else {
mode = "B";
}
telemetry.addData(String.format(" left,top (%d)", i), "%.03f , %.03f",
recognition.getLeft(), recognition.getTop());
telemetry.addData(String.format(" right,bottom (%d)", i), "%.03f , %.03f",
recognition.getRight(), recognition.getBottom());
}
//telemetry.addData(String.format("Mode (%s)", mode), "");
telemetry.update();
sleep(2000);
}
}
}
// go somewhere based on mode
if (mode == "A") {
doModeA();
} else if (mode == "B") {
doModeB();
} else if (mode == "C") {
doModeC();
} else {
// not sure what to do here
}
if (tfod != null) {
tfod.shutdown();
}
} | DESIGN | true | doModeC();
} else {
// not sure what to do here
}
if (tfod != null) { | }
}
// go somewhere based on mode
if (mode == "A") {
doModeA();
} else if (mode == "B") {
doModeB();
} else if (mode == "C") {
doModeC();
} else {
// not sure what to do here
}
if (tfod != null) {
tfod.shutdown();
}
} | }
telemetry.addData(String.format(" left,top (%d)", i), "%.03f , %.03f",
recognition.getLeft(), recognition.getTop());
telemetry.addData(String.format(" right,bottom (%d)", i), "%.03f , %.03f",
recognition.getRight(), recognition.getBottom());
}
//telemetry.addData(String.format("Mode (%s)", mode), "");
telemetry.update();
sleep(2000);
}
}
}
// go somewhere based on mode
if (mode == "A") {
doModeA();
} else if (mode == "B") {
doModeB();
} else if (mode == "C") {
doModeC();
} else {
// not sure what to do here
}
if (tfod != null) {
tfod.shutdown();
}
} |
17,714 | 0 | // TODO: optimize | public void writeBytes(int stream, byte[] b, int offset, int len) {
// TODO: optimize
final int end = offset + len;
for(int i=offset;i<end;i++)
writeByte(stream, b[i]);
} | DESIGN | true | public void writeBytes(int stream, byte[] b, int offset, int len) {
// TODO: optimize
final int end = offset + len;
for(int i=offset;i<end;i++) | public void writeBytes(int stream, byte[] b, int offset, int len) {
// TODO: optimize
final int end = offset + len;
for(int i=offset;i<end;i++)
writeByte(stream, b[i]);
} | public void writeBytes(int stream, byte[] b, int offset, int len) {
// TODO: optimize
final int end = offset + len;
for(int i=offset;i<end;i++)
writeByte(stream, b[i]);
} |
17,718 | 0 | // TODO: add exception handling (at least some logger) | private void populateSignatureNames() {
if (acroForm == null) {
return;
}
List<Object[]> sorter = new ArrayList<>();
for (Map.Entry<String, PdfFormField> entry : acroForm.getFormFields().entrySet()) {
PdfFormField field = entry.getValue();
PdfDictionary merged = field.getPdfObject();
if (!PdfName.Sig.equals(merged.get(PdfName.FT)))
continue;
PdfDictionary v = merged.getAsDictionary(PdfName.V);
if (v == null)
continue;
PdfString contents = v.getAsString(PdfName.Contents);
if (contents == null) {
continue;
} else {
contents.markAsUnencryptedObject();
}
PdfArray ro = v.getAsArray(PdfName.ByteRange);
if (ro == null)
continue;
int rangeSize = ro.size();
if (rangeSize < 2)
continue;
int length = ro.getAsNumber(rangeSize - 1).intValue() + ro.getAsNumber(rangeSize - 2).intValue();
sorter.add(new Object[]{entry.getKey(), new int[]{length, 0}});
}
Collections.sort(sorter, new SorterComparator());
if (sorter.size() > 0) {
try {
if (((int[]) sorter.get(sorter.size() - 1)[1])[0] == document.getReader().getFileLength())
totalRevisions = sorter.size();
else
totalRevisions = sorter.size() + 1;
} catch (IOException e) {
// TODO: add exception handling (at least some logger)
}
for (int k = 0; k < sorter.size(); ++k) {
Object[] objs = sorter.get(k);
String name = (String) objs[0];
int[] p = (int[]) objs[1];
p[1] = k + 1;
sigNames.put(name, p);
orderedSignatureNames.add(name);
}
}
} | IMPLEMENTATION | true | totalRevisions = sorter.size() + 1;
} catch (IOException e) {
// TODO: add exception handling (at least some logger)
}
for (int k = 0; k < sorter.size(); ++k) { | sorter.add(new Object[]{entry.getKey(), new int[]{length, 0}});
}
Collections.sort(sorter, new SorterComparator());
if (sorter.size() > 0) {
try {
if (((int[]) sorter.get(sorter.size() - 1)[1])[0] == document.getReader().getFileLength())
totalRevisions = sorter.size();
else
totalRevisions = sorter.size() + 1;
} catch (IOException e) {
// TODO: add exception handling (at least some logger)
}
for (int k = 0; k < sorter.size(); ++k) {
Object[] objs = sorter.get(k);
String name = (String) objs[0];
int[] p = (int[]) objs[1];
p[1] = k + 1;
sigNames.put(name, p);
orderedSignatureNames.add(name);
}
} | } else {
contents.markAsUnencryptedObject();
}
PdfArray ro = v.getAsArray(PdfName.ByteRange);
if (ro == null)
continue;
int rangeSize = ro.size();
if (rangeSize < 2)
continue;
int length = ro.getAsNumber(rangeSize - 1).intValue() + ro.getAsNumber(rangeSize - 2).intValue();
sorter.add(new Object[]{entry.getKey(), new int[]{length, 0}});
}
Collections.sort(sorter, new SorterComparator());
if (sorter.size() > 0) {
try {
if (((int[]) sorter.get(sorter.size() - 1)[1])[0] == document.getReader().getFileLength())
totalRevisions = sorter.size();
else
totalRevisions = sorter.size() + 1;
} catch (IOException e) {
// TODO: add exception handling (at least some logger)
}
for (int k = 0; k < sorter.size(); ++k) {
Object[] objs = sorter.get(k);
String name = (String) objs[0];
int[] p = (int[]) objs[1];
p[1] = k + 1;
sigNames.put(name, p);
orderedSignatureNames.add(name);
}
}
} |
9,527 | 0 | /**
* TODO: option - create via IDEA or via java.io. In latter case no need in Project parameter.
* Creates directory inside a write action and returns the resulting reference to it.
* If the directory already exists, does nothing.
* @param parent Parent directory.
* @param name Name of the directory.
* @return reference to the created or already existing directory.
*/ | public static VirtualFile createDir(Project project, final VirtualFile parent, final String name) {
final Ref<VirtualFile> result = new Ref<VirtualFile>();
new WriteCommandAction.Simple(project) {
@Override
protected void run() throws Throwable {
try {
VirtualFile dir = parent.findChild(name);
if (dir == null) {
dir = parent.createChildDirectory(this, name);
}
result.set(dir);
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
}.execute();
return result.get();
} | IMPLEMENTATION | true | public static VirtualFile createDir(Project project, final VirtualFile parent, final String name) {
final Ref<VirtualFile> result = new Ref<VirtualFile>();
new WriteCommandAction.Simple(project) {
@Override
protected void run() throws Throwable {
try {
VirtualFile dir = parent.findChild(name);
if (dir == null) {
dir = parent.createChildDirectory(this, name);
}
result.set(dir);
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
}.execute();
return result.get();
} | public static VirtualFile createDir(Project project, final VirtualFile parent, final String name) {
final Ref<VirtualFile> result = new Ref<VirtualFile>();
new WriteCommandAction.Simple(project) {
@Override
protected void run() throws Throwable {
try {
VirtualFile dir = parent.findChild(name);
if (dir == null) {
dir = parent.createChildDirectory(this, name);
}
result.set(dir);
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
}.execute();
return result.get();
} | public static VirtualFile createDir(Project project, final VirtualFile parent, final String name) {
final Ref<VirtualFile> result = new Ref<VirtualFile>();
new WriteCommandAction.Simple(project) {
@Override
protected void run() throws Throwable {
try {
VirtualFile dir = parent.findChild(name);
if (dir == null) {
dir = parent.createChildDirectory(this, name);
}
result.set(dir);
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
}.execute();
return result.get();
} |
9,528 | 0 | // Ignored. TODO: Do I have to handle this? | @CEntryPoint(name = "execute")
public static int execute(IsolateThread thread, int statement) {
try {
boolean hasResult = statements.get(statement).execute();
if (hasResult) {
throw new SQLException("unexpected results on statement execute");
}
return statements.get(statement).getUpdateCount();
} catch (Throwable e) {
setError(e);
return -1;
} finally {
try {
statements.get(statement).close();
} catch(Throwable t) {
// Ignored. TODO: Do I have to handle this?
}
}
} | DESIGN | true | statements.get(statement).close();
} catch(Throwable t) {
// Ignored. TODO: Do I have to handle this?
}
} | throw new SQLException("unexpected results on statement execute");
}
return statements.get(statement).getUpdateCount();
} catch (Throwable e) {
setError(e);
return -1;
} finally {
try {
statements.get(statement).close();
} catch(Throwable t) {
// Ignored. TODO: Do I have to handle this?
}
}
} | @CEntryPoint(name = "execute")
public static int execute(IsolateThread thread, int statement) {
try {
boolean hasResult = statements.get(statement).execute();
if (hasResult) {
throw new SQLException("unexpected results on statement execute");
}
return statements.get(statement).getUpdateCount();
} catch (Throwable e) {
setError(e);
return -1;
} finally {
try {
statements.get(statement).close();
} catch(Throwable t) {
// Ignored. TODO: Do I have to handle this?
}
}
} |
9,531 | 0 | /**
* Adds correction terms of the following form for variables v.
*
* <ul>
* <li> If primed context has no v, conjoins v_1 = v_max (v doesn't change in this block)
* <li> If primed context has index i < max, conjoins v_i = v_max
* <li> If unprimed context has has index i > 1, conjoins v_1 = v_i
* </ul>
*
* Adds formulas for program counter before and after block transition.
*
* @return A path formula with the above mentioned adjustments to the block transition formula.
* The ssa map contains the indices for all primed variables including those not in the
* original block formula and the pc. The pointer target set is the same as before.
*/ | private PathFormula withCorrectionTermsAndPC(
Block pBlock,
FormulaManagerView pFmgr,
BooleanFormulaManagerView pBfmgr,
BitvectorFormulaManagerView pBvfmgr,
PathFormulaManager pPfmgr,
CFA pCFA) {
BooleanFormula extendedBlockFormula = pBlock.getFormula();
PathFormula unprimedBlockContext = pBlock.getUnprimedContext();
PathFormula primedBlockContext = pBlock.getPrimedContext();
SSAMap unprimedSSAMap = unprimedBlockContext.getSsa();
SSAMap primedSSAMap = primedBlockContext.getSsa();
for (String varName : programVariableNames) {
// Add general correction v_1 = v_max if v is not in block formula (= not in primed context),
if (!primedSSAMap.containsVariable(varName)) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(pPfmgr, pFmgr, this.unprimedContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(pPfmgr, pFmgr, this.primedContext, varName, highestSSA));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
} else {
// Add low correction v_1 = v_? if unprimed context for v has higher index (? > 1).
if (unprimedSSAMap.containsVariable(varName)
&& unprimedSSAMap.getIndex(varName) > STANDARD_UNPRIMED_SSA) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(pPfmgr, pFmgr, unprimedBlockContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(
pPfmgr,
pFmgr,
unprimedBlockContext,
varName,
unprimedSSAMap.getIndex(varName)));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
}
// Add high correction v_? = v_max if primed context for v has lower index (? < max)
if (primedSSAMap.getIndex(varName) < highestSSA) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(
pPfmgr, pFmgr, primedBlockContext, varName, primedSSAMap.getIndex(varName)),
makeVar(pPfmgr, pFmgr, primedBlockContext, varName, highestSSA));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
}
}
}
// Add program counter
int predID = getID(pBlock.getPredecessorLocation());
int succID = getID(pBlock.getSuccessorLocation());
BooleanFormula pcBefore =
pFmgr.instantiate(
makeProgramcounterFormula(predID, pBvfmgr, pCFA),
SSAMap.emptySSAMap().withDefault(STANDARD_UNPRIMED_SSA));
BooleanFormula pcAfter =
pFmgr.instantiate(
makeProgramcounterFormula(succID, pBvfmgr, pCFA),
SSAMap.emptySSAMap().withDefault(PC_PRIMED_SSA));
extendedBlockFormula = pBfmgr.and(pcBefore, extendedBlockFormula, pcAfter);
@SuppressWarnings("deprecation")
// TODO: seems buggy because it implicitly combines extendedBlockFormula and
// primedContext.getSsa() with PointerTargetSet of primedBlockContext, is this correct?
PathFormula pathFormula =
pPfmgr.makeNewPathFormula(
primedBlockContext.updateFormula(extendedBlockFormula), this.primedContext.getSsa());
return pathFormula;
} | NONSATD | true | private PathFormula withCorrectionTermsAndPC(
Block pBlock,
FormulaManagerView pFmgr,
BooleanFormulaManagerView pBfmgr,
BitvectorFormulaManagerView pBvfmgr,
PathFormulaManager pPfmgr,
CFA pCFA) {
BooleanFormula extendedBlockFormula = pBlock.getFormula();
PathFormula unprimedBlockContext = pBlock.getUnprimedContext();
PathFormula primedBlockContext = pBlock.getPrimedContext();
SSAMap unprimedSSAMap = unprimedBlockContext.getSsa();
SSAMap primedSSAMap = primedBlockContext.getSsa();
for (String varName : programVariableNames) {
// Add general correction v_1 = v_max if v is not in block formula (= not in primed context),
if (!primedSSAMap.containsVariable(varName)) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(pPfmgr, pFmgr, this.unprimedContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(pPfmgr, pFmgr, this.primedContext, varName, highestSSA));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
} else {
// Add low correction v_1 = v_? if unprimed context for v has higher index (? > 1).
if (unprimedSSAMap.containsVariable(varName)
&& unprimedSSAMap.getIndex(varName) > STANDARD_UNPRIMED_SSA) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(pPfmgr, pFmgr, unprimedBlockContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(
pPfmgr,
pFmgr,
unprimedBlockContext,
varName,
unprimedSSAMap.getIndex(varName)));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
}
// Add high correction v_? = v_max if primed context for v has lower index (? < max)
if (primedSSAMap.getIndex(varName) < highestSSA) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(
pPfmgr, pFmgr, primedBlockContext, varName, primedSSAMap.getIndex(varName)),
makeVar(pPfmgr, pFmgr, primedBlockContext, varName, highestSSA));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
}
}
}
// Add program counter
int predID = getID(pBlock.getPredecessorLocation());
int succID = getID(pBlock.getSuccessorLocation());
BooleanFormula pcBefore =
pFmgr.instantiate(
makeProgramcounterFormula(predID, pBvfmgr, pCFA),
SSAMap.emptySSAMap().withDefault(STANDARD_UNPRIMED_SSA));
BooleanFormula pcAfter =
pFmgr.instantiate(
makeProgramcounterFormula(succID, pBvfmgr, pCFA),
SSAMap.emptySSAMap().withDefault(PC_PRIMED_SSA));
extendedBlockFormula = pBfmgr.and(pcBefore, extendedBlockFormula, pcAfter);
@SuppressWarnings("deprecation")
// TODO: seems buggy because it implicitly combines extendedBlockFormula and
// primedContext.getSsa() with PointerTargetSet of primedBlockContext, is this correct?
PathFormula pathFormula =
pPfmgr.makeNewPathFormula(
primedBlockContext.updateFormula(extendedBlockFormula), this.primedContext.getSsa());
return pathFormula;
} | private PathFormula withCorrectionTermsAndPC(
Block pBlock,
FormulaManagerView pFmgr,
BooleanFormulaManagerView pBfmgr,
BitvectorFormulaManagerView pBvfmgr,
PathFormulaManager pPfmgr,
CFA pCFA) {
BooleanFormula extendedBlockFormula = pBlock.getFormula();
PathFormula unprimedBlockContext = pBlock.getUnprimedContext();
PathFormula primedBlockContext = pBlock.getPrimedContext();
SSAMap unprimedSSAMap = unprimedBlockContext.getSsa();
SSAMap primedSSAMap = primedBlockContext.getSsa();
for (String varName : programVariableNames) {
// Add general correction v_1 = v_max if v is not in block formula (= not in primed context),
if (!primedSSAMap.containsVariable(varName)) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(pPfmgr, pFmgr, this.unprimedContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(pPfmgr, pFmgr, this.primedContext, varName, highestSSA));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
} else {
// Add low correction v_1 = v_? if unprimed context for v has higher index (? > 1).
if (unprimedSSAMap.containsVariable(varName)
&& unprimedSSAMap.getIndex(varName) > STANDARD_UNPRIMED_SSA) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(pPfmgr, pFmgr, unprimedBlockContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(
pPfmgr,
pFmgr,
unprimedBlockContext,
varName,
unprimedSSAMap.getIndex(varName)));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
}
// Add high correction v_? = v_max if primed context for v has lower index (? < max)
if (primedSSAMap.getIndex(varName) < highestSSA) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(
pPfmgr, pFmgr, primedBlockContext, varName, primedSSAMap.getIndex(varName)),
makeVar(pPfmgr, pFmgr, primedBlockContext, varName, highestSSA));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
}
}
}
// Add program counter
int predID = getID(pBlock.getPredecessorLocation());
int succID = getID(pBlock.getSuccessorLocation());
BooleanFormula pcBefore =
pFmgr.instantiate(
makeProgramcounterFormula(predID, pBvfmgr, pCFA),
SSAMap.emptySSAMap().withDefault(STANDARD_UNPRIMED_SSA));
BooleanFormula pcAfter =
pFmgr.instantiate(
makeProgramcounterFormula(succID, pBvfmgr, pCFA),
SSAMap.emptySSAMap().withDefault(PC_PRIMED_SSA));
extendedBlockFormula = pBfmgr.and(pcBefore, extendedBlockFormula, pcAfter);
@SuppressWarnings("deprecation")
// TODO: seems buggy because it implicitly combines extendedBlockFormula and
// primedContext.getSsa() with PointerTargetSet of primedBlockContext, is this correct?
PathFormula pathFormula =
pPfmgr.makeNewPathFormula(
primedBlockContext.updateFormula(extendedBlockFormula), this.primedContext.getSsa());
return pathFormula;
} | private PathFormula withCorrectionTermsAndPC(
Block pBlock,
FormulaManagerView pFmgr,
BooleanFormulaManagerView pBfmgr,
BitvectorFormulaManagerView pBvfmgr,
PathFormulaManager pPfmgr,
CFA pCFA) {
BooleanFormula extendedBlockFormula = pBlock.getFormula();
PathFormula unprimedBlockContext = pBlock.getUnprimedContext();
PathFormula primedBlockContext = pBlock.getPrimedContext();
SSAMap unprimedSSAMap = unprimedBlockContext.getSsa();
SSAMap primedSSAMap = primedBlockContext.getSsa();
for (String varName : programVariableNames) {
// Add general correction v_1 = v_max if v is not in block formula (= not in primed context),
if (!primedSSAMap.containsVariable(varName)) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(pPfmgr, pFmgr, this.unprimedContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(pPfmgr, pFmgr, this.primedContext, varName, highestSSA));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
} else {
// Add low correction v_1 = v_? if unprimed context for v has higher index (? > 1).
if (unprimedSSAMap.containsVariable(varName)
&& unprimedSSAMap.getIndex(varName) > STANDARD_UNPRIMED_SSA) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(pPfmgr, pFmgr, unprimedBlockContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(
pPfmgr,
pFmgr,
unprimedBlockContext,
varName,
unprimedSSAMap.getIndex(varName)));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
}
// Add high correction v_? = v_max if primed context for v has lower index (? < max)
if (primedSSAMap.getIndex(varName) < highestSSA) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(
pPfmgr, pFmgr, primedBlockContext, varName, primedSSAMap.getIndex(varName)),
makeVar(pPfmgr, pFmgr, primedBlockContext, varName, highestSSA));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
}
}
}
// Add program counter
int predID = getID(pBlock.getPredecessorLocation());
int succID = getID(pBlock.getSuccessorLocation());
BooleanFormula pcBefore =
pFmgr.instantiate(
makeProgramcounterFormula(predID, pBvfmgr, pCFA),
SSAMap.emptySSAMap().withDefault(STANDARD_UNPRIMED_SSA));
BooleanFormula pcAfter =
pFmgr.instantiate(
makeProgramcounterFormula(succID, pBvfmgr, pCFA),
SSAMap.emptySSAMap().withDefault(PC_PRIMED_SSA));
extendedBlockFormula = pBfmgr.and(pcBefore, extendedBlockFormula, pcAfter);
@SuppressWarnings("deprecation")
// TODO: seems buggy because it implicitly combines extendedBlockFormula and
// primedContext.getSsa() with PointerTargetSet of primedBlockContext, is this correct?
PathFormula pathFormula =
pPfmgr.makeNewPathFormula(
primedBlockContext.updateFormula(extendedBlockFormula), this.primedContext.getSsa());
return pathFormula;
} |
9,531 | 1 | // Add general correction v_1 = v_max if v is not in block formula (= not in primed context), | private PathFormula withCorrectionTermsAndPC(
Block pBlock,
FormulaManagerView pFmgr,
BooleanFormulaManagerView pBfmgr,
BitvectorFormulaManagerView pBvfmgr,
PathFormulaManager pPfmgr,
CFA pCFA) {
BooleanFormula extendedBlockFormula = pBlock.getFormula();
PathFormula unprimedBlockContext = pBlock.getUnprimedContext();
PathFormula primedBlockContext = pBlock.getPrimedContext();
SSAMap unprimedSSAMap = unprimedBlockContext.getSsa();
SSAMap primedSSAMap = primedBlockContext.getSsa();
for (String varName : programVariableNames) {
// Add general correction v_1 = v_max if v is not in block formula (= not in primed context),
if (!primedSSAMap.containsVariable(varName)) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(pPfmgr, pFmgr, this.unprimedContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(pPfmgr, pFmgr, this.primedContext, varName, highestSSA));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
} else {
// Add low correction v_1 = v_? if unprimed context for v has higher index (? > 1).
if (unprimedSSAMap.containsVariable(varName)
&& unprimedSSAMap.getIndex(varName) > STANDARD_UNPRIMED_SSA) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(pPfmgr, pFmgr, unprimedBlockContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(
pPfmgr,
pFmgr,
unprimedBlockContext,
varName,
unprimedSSAMap.getIndex(varName)));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
}
// Add high correction v_? = v_max if primed context for v has lower index (? < max)
if (primedSSAMap.getIndex(varName) < highestSSA) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(
pPfmgr, pFmgr, primedBlockContext, varName, primedSSAMap.getIndex(varName)),
makeVar(pPfmgr, pFmgr, primedBlockContext, varName, highestSSA));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
}
}
}
// Add program counter
int predID = getID(pBlock.getPredecessorLocation());
int succID = getID(pBlock.getSuccessorLocation());
BooleanFormula pcBefore =
pFmgr.instantiate(
makeProgramcounterFormula(predID, pBvfmgr, pCFA),
SSAMap.emptySSAMap().withDefault(STANDARD_UNPRIMED_SSA));
BooleanFormula pcAfter =
pFmgr.instantiate(
makeProgramcounterFormula(succID, pBvfmgr, pCFA),
SSAMap.emptySSAMap().withDefault(PC_PRIMED_SSA));
extendedBlockFormula = pBfmgr.and(pcBefore, extendedBlockFormula, pcAfter);
@SuppressWarnings("deprecation")
// TODO: seems buggy because it implicitly combines extendedBlockFormula and
// primedContext.getSsa() with PointerTargetSet of primedBlockContext, is this correct?
PathFormula pathFormula =
pPfmgr.makeNewPathFormula(
primedBlockContext.updateFormula(extendedBlockFormula), this.primedContext.getSsa());
return pathFormula;
} | NONSATD | true | SSAMap primedSSAMap = primedBlockContext.getSsa();
for (String varName : programVariableNames) {
// Add general correction v_1 = v_max if v is not in block formula (= not in primed context),
if (!primedSSAMap.containsVariable(varName)) {
BooleanFormula correctionterm = | BooleanFormulaManagerView pBfmgr,
BitvectorFormulaManagerView pBvfmgr,
PathFormulaManager pPfmgr,
CFA pCFA) {
BooleanFormula extendedBlockFormula = pBlock.getFormula();
PathFormula unprimedBlockContext = pBlock.getUnprimedContext();
PathFormula primedBlockContext = pBlock.getPrimedContext();
SSAMap unprimedSSAMap = unprimedBlockContext.getSsa();
SSAMap primedSSAMap = primedBlockContext.getSsa();
for (String varName : programVariableNames) {
// Add general correction v_1 = v_max if v is not in block formula (= not in primed context),
if (!primedSSAMap.containsVariable(varName)) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(pPfmgr, pFmgr, this.unprimedContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(pPfmgr, pFmgr, this.primedContext, varName, highestSSA));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
} else {
// Add low correction v_1 = v_? if unprimed context for v has higher index (? > 1).
if (unprimedSSAMap.containsVariable(varName)
&& unprimedSSAMap.getIndex(varName) > STANDARD_UNPRIMED_SSA) { | private PathFormula withCorrectionTermsAndPC(
Block pBlock,
FormulaManagerView pFmgr,
BooleanFormulaManagerView pBfmgr,
BitvectorFormulaManagerView pBvfmgr,
PathFormulaManager pPfmgr,
CFA pCFA) {
BooleanFormula extendedBlockFormula = pBlock.getFormula();
PathFormula unprimedBlockContext = pBlock.getUnprimedContext();
PathFormula primedBlockContext = pBlock.getPrimedContext();
SSAMap unprimedSSAMap = unprimedBlockContext.getSsa();
SSAMap primedSSAMap = primedBlockContext.getSsa();
for (String varName : programVariableNames) {
// Add general correction v_1 = v_max if v is not in block formula (= not in primed context),
if (!primedSSAMap.containsVariable(varName)) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(pPfmgr, pFmgr, this.unprimedContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(pPfmgr, pFmgr, this.primedContext, varName, highestSSA));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
} else {
// Add low correction v_1 = v_? if unprimed context for v has higher index (? > 1).
if (unprimedSSAMap.containsVariable(varName)
&& unprimedSSAMap.getIndex(varName) > STANDARD_UNPRIMED_SSA) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(pPfmgr, pFmgr, unprimedBlockContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(
pPfmgr,
pFmgr,
unprimedBlockContext,
varName,
unprimedSSAMap.getIndex(varName)));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm); |
9,531 | 2 | // Add low correction v_1 = v_? if unprimed context for v has higher index (? > 1). | private PathFormula withCorrectionTermsAndPC(
Block pBlock,
FormulaManagerView pFmgr,
BooleanFormulaManagerView pBfmgr,
BitvectorFormulaManagerView pBvfmgr,
PathFormulaManager pPfmgr,
CFA pCFA) {
BooleanFormula extendedBlockFormula = pBlock.getFormula();
PathFormula unprimedBlockContext = pBlock.getUnprimedContext();
PathFormula primedBlockContext = pBlock.getPrimedContext();
SSAMap unprimedSSAMap = unprimedBlockContext.getSsa();
SSAMap primedSSAMap = primedBlockContext.getSsa();
for (String varName : programVariableNames) {
// Add general correction v_1 = v_max if v is not in block formula (= not in primed context),
if (!primedSSAMap.containsVariable(varName)) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(pPfmgr, pFmgr, this.unprimedContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(pPfmgr, pFmgr, this.primedContext, varName, highestSSA));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
} else {
// Add low correction v_1 = v_? if unprimed context for v has higher index (? > 1).
if (unprimedSSAMap.containsVariable(varName)
&& unprimedSSAMap.getIndex(varName) > STANDARD_UNPRIMED_SSA) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(pPfmgr, pFmgr, unprimedBlockContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(
pPfmgr,
pFmgr,
unprimedBlockContext,
varName,
unprimedSSAMap.getIndex(varName)));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
}
// Add high correction v_? = v_max if primed context for v has lower index (? < max)
if (primedSSAMap.getIndex(varName) < highestSSA) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(
pPfmgr, pFmgr, primedBlockContext, varName, primedSSAMap.getIndex(varName)),
makeVar(pPfmgr, pFmgr, primedBlockContext, varName, highestSSA));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
}
}
}
// Add program counter
int predID = getID(pBlock.getPredecessorLocation());
int succID = getID(pBlock.getSuccessorLocation());
BooleanFormula pcBefore =
pFmgr.instantiate(
makeProgramcounterFormula(predID, pBvfmgr, pCFA),
SSAMap.emptySSAMap().withDefault(STANDARD_UNPRIMED_SSA));
BooleanFormula pcAfter =
pFmgr.instantiate(
makeProgramcounterFormula(succID, pBvfmgr, pCFA),
SSAMap.emptySSAMap().withDefault(PC_PRIMED_SSA));
extendedBlockFormula = pBfmgr.and(pcBefore, extendedBlockFormula, pcAfter);
@SuppressWarnings("deprecation")
// TODO: seems buggy because it implicitly combines extendedBlockFormula and
// primedContext.getSsa() with PointerTargetSet of primedBlockContext, is this correct?
PathFormula pathFormula =
pPfmgr.makeNewPathFormula(
primedBlockContext.updateFormula(extendedBlockFormula), this.primedContext.getSsa());
return pathFormula;
} | NONSATD | true | extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
} else {
// Add low correction v_1 = v_? if unprimed context for v has higher index (? > 1).
if (unprimedSSAMap.containsVariable(varName)
&& unprimedSSAMap.getIndex(varName) > STANDARD_UNPRIMED_SSA) { | SSAMap primedSSAMap = primedBlockContext.getSsa();
for (String varName : programVariableNames) {
// Add general correction v_1 = v_max if v is not in block formula (= not in primed context),
if (!primedSSAMap.containsVariable(varName)) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(pPfmgr, pFmgr, this.unprimedContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(pPfmgr, pFmgr, this.primedContext, varName, highestSSA));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
} else {
// Add low correction v_1 = v_? if unprimed context for v has higher index (? > 1).
if (unprimedSSAMap.containsVariable(varName)
&& unprimedSSAMap.getIndex(varName) > STANDARD_UNPRIMED_SSA) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(pPfmgr, pFmgr, unprimedBlockContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(
pPfmgr,
pFmgr,
unprimedBlockContext,
varName, | Block pBlock,
FormulaManagerView pFmgr,
BooleanFormulaManagerView pBfmgr,
BitvectorFormulaManagerView pBvfmgr,
PathFormulaManager pPfmgr,
CFA pCFA) {
BooleanFormula extendedBlockFormula = pBlock.getFormula();
PathFormula unprimedBlockContext = pBlock.getUnprimedContext();
PathFormula primedBlockContext = pBlock.getPrimedContext();
SSAMap unprimedSSAMap = unprimedBlockContext.getSsa();
SSAMap primedSSAMap = primedBlockContext.getSsa();
for (String varName : programVariableNames) {
// Add general correction v_1 = v_max if v is not in block formula (= not in primed context),
if (!primedSSAMap.containsVariable(varName)) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(pPfmgr, pFmgr, this.unprimedContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(pPfmgr, pFmgr, this.primedContext, varName, highestSSA));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
} else {
// Add low correction v_1 = v_? if unprimed context for v has higher index (? > 1).
if (unprimedSSAMap.containsVariable(varName)
&& unprimedSSAMap.getIndex(varName) > STANDARD_UNPRIMED_SSA) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(pPfmgr, pFmgr, unprimedBlockContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(
pPfmgr,
pFmgr,
unprimedBlockContext,
varName,
unprimedSSAMap.getIndex(varName)));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
}
// Add high correction v_? = v_max if primed context for v has lower index (? < max)
if (primedSSAMap.getIndex(varName) < highestSSA) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(
pPfmgr, pFmgr, primedBlockContext, varName, primedSSAMap.getIndex(varName)),
makeVar(pPfmgr, pFmgr, primedBlockContext, varName, highestSSA)); |
9,531 | 3 | // Add high correction v_? = v_max if primed context for v has lower index (? < max) | private PathFormula withCorrectionTermsAndPC(
Block pBlock,
FormulaManagerView pFmgr,
BooleanFormulaManagerView pBfmgr,
BitvectorFormulaManagerView pBvfmgr,
PathFormulaManager pPfmgr,
CFA pCFA) {
BooleanFormula extendedBlockFormula = pBlock.getFormula();
PathFormula unprimedBlockContext = pBlock.getUnprimedContext();
PathFormula primedBlockContext = pBlock.getPrimedContext();
SSAMap unprimedSSAMap = unprimedBlockContext.getSsa();
SSAMap primedSSAMap = primedBlockContext.getSsa();
for (String varName : programVariableNames) {
// Add general correction v_1 = v_max if v is not in block formula (= not in primed context),
if (!primedSSAMap.containsVariable(varName)) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(pPfmgr, pFmgr, this.unprimedContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(pPfmgr, pFmgr, this.primedContext, varName, highestSSA));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
} else {
// Add low correction v_1 = v_? if unprimed context for v has higher index (? > 1).
if (unprimedSSAMap.containsVariable(varName)
&& unprimedSSAMap.getIndex(varName) > STANDARD_UNPRIMED_SSA) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(pPfmgr, pFmgr, unprimedBlockContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(
pPfmgr,
pFmgr,
unprimedBlockContext,
varName,
unprimedSSAMap.getIndex(varName)));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
}
// Add high correction v_? = v_max if primed context for v has lower index (? < max)
if (primedSSAMap.getIndex(varName) < highestSSA) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(
pPfmgr, pFmgr, primedBlockContext, varName, primedSSAMap.getIndex(varName)),
makeVar(pPfmgr, pFmgr, primedBlockContext, varName, highestSSA));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
}
}
}
// Add program counter
int predID = getID(pBlock.getPredecessorLocation());
int succID = getID(pBlock.getSuccessorLocation());
BooleanFormula pcBefore =
pFmgr.instantiate(
makeProgramcounterFormula(predID, pBvfmgr, pCFA),
SSAMap.emptySSAMap().withDefault(STANDARD_UNPRIMED_SSA));
BooleanFormula pcAfter =
pFmgr.instantiate(
makeProgramcounterFormula(succID, pBvfmgr, pCFA),
SSAMap.emptySSAMap().withDefault(PC_PRIMED_SSA));
extendedBlockFormula = pBfmgr.and(pcBefore, extendedBlockFormula, pcAfter);
@SuppressWarnings("deprecation")
// TODO: seems buggy because it implicitly combines extendedBlockFormula and
// primedContext.getSsa() with PointerTargetSet of primedBlockContext, is this correct?
PathFormula pathFormula =
pPfmgr.makeNewPathFormula(
primedBlockContext.updateFormula(extendedBlockFormula), this.primedContext.getSsa());
return pathFormula;
} | NONSATD | true | extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
}
// Add high correction v_? = v_max if primed context for v has lower index (? < max)
if (primedSSAMap.getIndex(varName) < highestSSA) {
BooleanFormula correctionterm = | pBvfmgr.equal(
makeVar(pPfmgr, pFmgr, unprimedBlockContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(
pPfmgr,
pFmgr,
unprimedBlockContext,
varName,
unprimedSSAMap.getIndex(varName)));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
}
// Add high correction v_? = v_max if primed context for v has lower index (? < max)
if (primedSSAMap.getIndex(varName) < highestSSA) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(
pPfmgr, pFmgr, primedBlockContext, varName, primedSSAMap.getIndex(varName)),
makeVar(pPfmgr, pFmgr, primedBlockContext, varName, highestSSA));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
}
}
} | BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(pPfmgr, pFmgr, this.unprimedContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(pPfmgr, pFmgr, this.primedContext, varName, highestSSA));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
} else {
// Add low correction v_1 = v_? if unprimed context for v has higher index (? > 1).
if (unprimedSSAMap.containsVariable(varName)
&& unprimedSSAMap.getIndex(varName) > STANDARD_UNPRIMED_SSA) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(pPfmgr, pFmgr, unprimedBlockContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(
pPfmgr,
pFmgr,
unprimedBlockContext,
varName,
unprimedSSAMap.getIndex(varName)));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
}
// Add high correction v_? = v_max if primed context for v has lower index (? < max)
if (primedSSAMap.getIndex(varName) < highestSSA) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(
pPfmgr, pFmgr, primedBlockContext, varName, primedSSAMap.getIndex(varName)),
makeVar(pPfmgr, pFmgr, primedBlockContext, varName, highestSSA));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
}
}
}
// Add program counter
int predID = getID(pBlock.getPredecessorLocation());
int succID = getID(pBlock.getSuccessorLocation());
BooleanFormula pcBefore =
pFmgr.instantiate(
makeProgramcounterFormula(predID, pBvfmgr, pCFA),
SSAMap.emptySSAMap().withDefault(STANDARD_UNPRIMED_SSA));
BooleanFormula pcAfter =
pFmgr.instantiate(
makeProgramcounterFormula(succID, pBvfmgr, pCFA), |
9,531 | 4 | // Add program counter | private PathFormula withCorrectionTermsAndPC(
Block pBlock,
FormulaManagerView pFmgr,
BooleanFormulaManagerView pBfmgr,
BitvectorFormulaManagerView pBvfmgr,
PathFormulaManager pPfmgr,
CFA pCFA) {
BooleanFormula extendedBlockFormula = pBlock.getFormula();
PathFormula unprimedBlockContext = pBlock.getUnprimedContext();
PathFormula primedBlockContext = pBlock.getPrimedContext();
SSAMap unprimedSSAMap = unprimedBlockContext.getSsa();
SSAMap primedSSAMap = primedBlockContext.getSsa();
for (String varName : programVariableNames) {
// Add general correction v_1 = v_max if v is not in block formula (= not in primed context),
if (!primedSSAMap.containsVariable(varName)) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(pPfmgr, pFmgr, this.unprimedContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(pPfmgr, pFmgr, this.primedContext, varName, highestSSA));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
} else {
// Add low correction v_1 = v_? if unprimed context for v has higher index (? > 1).
if (unprimedSSAMap.containsVariable(varName)
&& unprimedSSAMap.getIndex(varName) > STANDARD_UNPRIMED_SSA) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(pPfmgr, pFmgr, unprimedBlockContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(
pPfmgr,
pFmgr,
unprimedBlockContext,
varName,
unprimedSSAMap.getIndex(varName)));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
}
// Add high correction v_? = v_max if primed context for v has lower index (? < max)
if (primedSSAMap.getIndex(varName) < highestSSA) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(
pPfmgr, pFmgr, primedBlockContext, varName, primedSSAMap.getIndex(varName)),
makeVar(pPfmgr, pFmgr, primedBlockContext, varName, highestSSA));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
}
}
}
// Add program counter
int predID = getID(pBlock.getPredecessorLocation());
int succID = getID(pBlock.getSuccessorLocation());
BooleanFormula pcBefore =
pFmgr.instantiate(
makeProgramcounterFormula(predID, pBvfmgr, pCFA),
SSAMap.emptySSAMap().withDefault(STANDARD_UNPRIMED_SSA));
BooleanFormula pcAfter =
pFmgr.instantiate(
makeProgramcounterFormula(succID, pBvfmgr, pCFA),
SSAMap.emptySSAMap().withDefault(PC_PRIMED_SSA));
extendedBlockFormula = pBfmgr.and(pcBefore, extendedBlockFormula, pcAfter);
@SuppressWarnings("deprecation")
// TODO: seems buggy because it implicitly combines extendedBlockFormula and
// primedContext.getSsa() with PointerTargetSet of primedBlockContext, is this correct?
PathFormula pathFormula =
pPfmgr.makeNewPathFormula(
primedBlockContext.updateFormula(extendedBlockFormula), this.primedContext.getSsa());
return pathFormula;
} | NONSATD | true | }
}
// Add program counter
int predID = getID(pBlock.getPredecessorLocation());
int succID = getID(pBlock.getSuccessorLocation()); | if (primedSSAMap.getIndex(varName) < highestSSA) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(
pPfmgr, pFmgr, primedBlockContext, varName, primedSSAMap.getIndex(varName)),
makeVar(pPfmgr, pFmgr, primedBlockContext, varName, highestSSA));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
}
}
}
// Add program counter
int predID = getID(pBlock.getPredecessorLocation());
int succID = getID(pBlock.getSuccessorLocation());
BooleanFormula pcBefore =
pFmgr.instantiate(
makeProgramcounterFormula(predID, pBvfmgr, pCFA),
SSAMap.emptySSAMap().withDefault(STANDARD_UNPRIMED_SSA));
BooleanFormula pcAfter =
pFmgr.instantiate(
makeProgramcounterFormula(succID, pBvfmgr, pCFA),
SSAMap.emptySSAMap().withDefault(PC_PRIMED_SSA)); | makeVar(pPfmgr, pFmgr, unprimedBlockContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(
pPfmgr,
pFmgr,
unprimedBlockContext,
varName,
unprimedSSAMap.getIndex(varName)));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
}
// Add high correction v_? = v_max if primed context for v has lower index (? < max)
if (primedSSAMap.getIndex(varName) < highestSSA) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(
pPfmgr, pFmgr, primedBlockContext, varName, primedSSAMap.getIndex(varName)),
makeVar(pPfmgr, pFmgr, primedBlockContext, varName, highestSSA));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
}
}
}
// Add program counter
int predID = getID(pBlock.getPredecessorLocation());
int succID = getID(pBlock.getSuccessorLocation());
BooleanFormula pcBefore =
pFmgr.instantiate(
makeProgramcounterFormula(predID, pBvfmgr, pCFA),
SSAMap.emptySSAMap().withDefault(STANDARD_UNPRIMED_SSA));
BooleanFormula pcAfter =
pFmgr.instantiate(
makeProgramcounterFormula(succID, pBvfmgr, pCFA),
SSAMap.emptySSAMap().withDefault(PC_PRIMED_SSA));
extendedBlockFormula = pBfmgr.and(pcBefore, extendedBlockFormula, pcAfter);
@SuppressWarnings("deprecation")
// TODO: seems buggy because it implicitly combines extendedBlockFormula and
// primedContext.getSsa() with PointerTargetSet of primedBlockContext, is this correct?
PathFormula pathFormula =
pPfmgr.makeNewPathFormula(
primedBlockContext.updateFormula(extendedBlockFormula), this.primedContext.getSsa());
return pathFormula;
} |
9,531 | 5 | // TODO: seems buggy because it implicitly combines extendedBlockFormula and
// primedContext.getSsa() with PointerTargetSet of primedBlockContext, is this correct? | private PathFormula withCorrectionTermsAndPC(
Block pBlock,
FormulaManagerView pFmgr,
BooleanFormulaManagerView pBfmgr,
BitvectorFormulaManagerView pBvfmgr,
PathFormulaManager pPfmgr,
CFA pCFA) {
BooleanFormula extendedBlockFormula = pBlock.getFormula();
PathFormula unprimedBlockContext = pBlock.getUnprimedContext();
PathFormula primedBlockContext = pBlock.getPrimedContext();
SSAMap unprimedSSAMap = unprimedBlockContext.getSsa();
SSAMap primedSSAMap = primedBlockContext.getSsa();
for (String varName : programVariableNames) {
// Add general correction v_1 = v_max if v is not in block formula (= not in primed context),
if (!primedSSAMap.containsVariable(varName)) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(pPfmgr, pFmgr, this.unprimedContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(pPfmgr, pFmgr, this.primedContext, varName, highestSSA));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
} else {
// Add low correction v_1 = v_? if unprimed context for v has higher index (? > 1).
if (unprimedSSAMap.containsVariable(varName)
&& unprimedSSAMap.getIndex(varName) > STANDARD_UNPRIMED_SSA) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(pPfmgr, pFmgr, unprimedBlockContext, varName, STANDARD_UNPRIMED_SSA),
makeVar(
pPfmgr,
pFmgr,
unprimedBlockContext,
varName,
unprimedSSAMap.getIndex(varName)));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
}
// Add high correction v_? = v_max if primed context for v has lower index (? < max)
if (primedSSAMap.getIndex(varName) < highestSSA) {
BooleanFormula correctionterm =
pBvfmgr.equal(
makeVar(
pPfmgr, pFmgr, primedBlockContext, varName, primedSSAMap.getIndex(varName)),
makeVar(pPfmgr, pFmgr, primedBlockContext, varName, highestSSA));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
}
}
}
// Add program counter
int predID = getID(pBlock.getPredecessorLocation());
int succID = getID(pBlock.getSuccessorLocation());
BooleanFormula pcBefore =
pFmgr.instantiate(
makeProgramcounterFormula(predID, pBvfmgr, pCFA),
SSAMap.emptySSAMap().withDefault(STANDARD_UNPRIMED_SSA));
BooleanFormula pcAfter =
pFmgr.instantiate(
makeProgramcounterFormula(succID, pBvfmgr, pCFA),
SSAMap.emptySSAMap().withDefault(PC_PRIMED_SSA));
extendedBlockFormula = pBfmgr.and(pcBefore, extendedBlockFormula, pcAfter);
@SuppressWarnings("deprecation")
// TODO: seems buggy because it implicitly combines extendedBlockFormula and
// primedContext.getSsa() with PointerTargetSet of primedBlockContext, is this correct?
PathFormula pathFormula =
pPfmgr.makeNewPathFormula(
primedBlockContext.updateFormula(extendedBlockFormula), this.primedContext.getSsa());
return pathFormula;
} | DEFECT | true | extendedBlockFormula = pBfmgr.and(pcBefore, extendedBlockFormula, pcAfter);
@SuppressWarnings("deprecation")
// TODO: seems buggy because it implicitly combines extendedBlockFormula and
// primedContext.getSsa() with PointerTargetSet of primedBlockContext, is this correct?
PathFormula pathFormula =
pPfmgr.makeNewPathFormula( | BooleanFormula pcBefore =
pFmgr.instantiate(
makeProgramcounterFormula(predID, pBvfmgr, pCFA),
SSAMap.emptySSAMap().withDefault(STANDARD_UNPRIMED_SSA));
BooleanFormula pcAfter =
pFmgr.instantiate(
makeProgramcounterFormula(succID, pBvfmgr, pCFA),
SSAMap.emptySSAMap().withDefault(PC_PRIMED_SSA));
extendedBlockFormula = pBfmgr.and(pcBefore, extendedBlockFormula, pcAfter);
@SuppressWarnings("deprecation")
// TODO: seems buggy because it implicitly combines extendedBlockFormula and
// primedContext.getSsa() with PointerTargetSet of primedBlockContext, is this correct?
PathFormula pathFormula =
pPfmgr.makeNewPathFormula(
primedBlockContext.updateFormula(extendedBlockFormula), this.primedContext.getSsa());
return pathFormula;
} | makeVar(
pPfmgr, pFmgr, primedBlockContext, varName, primedSSAMap.getIndex(varName)),
makeVar(pPfmgr, pFmgr, primedBlockContext, varName, highestSSA));
extendedBlockFormula = pBfmgr.and(extendedBlockFormula, correctionterm);
}
}
}
// Add program counter
int predID = getID(pBlock.getPredecessorLocation());
int succID = getID(pBlock.getSuccessorLocation());
BooleanFormula pcBefore =
pFmgr.instantiate(
makeProgramcounterFormula(predID, pBvfmgr, pCFA),
SSAMap.emptySSAMap().withDefault(STANDARD_UNPRIMED_SSA));
BooleanFormula pcAfter =
pFmgr.instantiate(
makeProgramcounterFormula(succID, pBvfmgr, pCFA),
SSAMap.emptySSAMap().withDefault(PC_PRIMED_SSA));
extendedBlockFormula = pBfmgr.and(pcBefore, extendedBlockFormula, pcAfter);
@SuppressWarnings("deprecation")
// TODO: seems buggy because it implicitly combines extendedBlockFormula and
// primedContext.getSsa() with PointerTargetSet of primedBlockContext, is this correct?
PathFormula pathFormula =
pPfmgr.makeNewPathFormula(
primedBlockContext.updateFormula(extendedBlockFormula), this.primedContext.getSsa());
return pathFormula;
} |
34,107 | 0 | /**
* Copy the keys and values from the source to this object. This will
* not copy the default values. This is meant to be used by going from
* a higher precedence object to a lower precedence object, so that if a
* key already exists, this method will not reset it.
*
* @param opsrc non-null reference to an OutputProperties.
*/ | public void copyFrom(OutputProperties opsrc)
throws TransformerException
{
// Bugzilla 6157: recover from xsl:output statements
// checkDuplicates(opsrc);
copyFrom(opsrc.getProperties());
} | NONSATD | true | public void copyFrom(OutputProperties opsrc)
throws TransformerException
{
// Bugzilla 6157: recover from xsl:output statements
// checkDuplicates(opsrc);
copyFrom(opsrc.getProperties());
} | public void copyFrom(OutputProperties opsrc)
throws TransformerException
{
// Bugzilla 6157: recover from xsl:output statements
// checkDuplicates(opsrc);
copyFrom(opsrc.getProperties());
} | public void copyFrom(OutputProperties opsrc)
throws TransformerException
{
// Bugzilla 6157: recover from xsl:output statements
// checkDuplicates(opsrc);
copyFrom(opsrc.getProperties());
} |
34,107 | 1 | // Bugzilla 6157: recover from xsl:output statements
// checkDuplicates(opsrc); | public void copyFrom(OutputProperties opsrc)
throws TransformerException
{
// Bugzilla 6157: recover from xsl:output statements
// checkDuplicates(opsrc);
copyFrom(opsrc.getProperties());
} | DEFECT | true | throws TransformerException
{
// Bugzilla 6157: recover from xsl:output statements
// checkDuplicates(opsrc);
copyFrom(opsrc.getProperties());
} | public void copyFrom(OutputProperties opsrc)
throws TransformerException
{
// Bugzilla 6157: recover from xsl:output statements
// checkDuplicates(opsrc);
copyFrom(opsrc.getProperties());
} | public void copyFrom(OutputProperties opsrc)
throws TransformerException
{
// Bugzilla 6157: recover from xsl:output statements
// checkDuplicates(opsrc);
copyFrom(opsrc.getProperties());
} |
34,109 | 0 | /**
*** Sets the report header group at the specified column
**/ | public ReportHeaderGroup getReportHeaderGroup(int col)
{
/* no report header groups? */
if (ListTools.isEmpty(this.rptHdrGrps)) {
return null;
}
/* search for column */
for (ReportHeaderGroup rhg : this.rptHdrGrps) {
int C = rhg.getColIndex();
if (col == C) {
return rhg;
}
// TODO: optimize
}
/* not found */
return null;
} | NONSATD | true | public ReportHeaderGroup getReportHeaderGroup(int col)
{
/* no report header groups? */
if (ListTools.isEmpty(this.rptHdrGrps)) {
return null;
}
/* search for column */
for (ReportHeaderGroup rhg : this.rptHdrGrps) {
int C = rhg.getColIndex();
if (col == C) {
return rhg;
}
// TODO: optimize
}
/* not found */
return null;
} | public ReportHeaderGroup getReportHeaderGroup(int col)
{
/* no report header groups? */
if (ListTools.isEmpty(this.rptHdrGrps)) {
return null;
}
/* search for column */
for (ReportHeaderGroup rhg : this.rptHdrGrps) {
int C = rhg.getColIndex();
if (col == C) {
return rhg;
}
// TODO: optimize
}
/* not found */
return null;
} | public ReportHeaderGroup getReportHeaderGroup(int col)
{
/* no report header groups? */
if (ListTools.isEmpty(this.rptHdrGrps)) {
return null;
}
/* search for column */
for (ReportHeaderGroup rhg : this.rptHdrGrps) {
int C = rhg.getColIndex();
if (col == C) {
return rhg;
}
// TODO: optimize
}
/* not found */
return null;
} |
34,109 | 1 | /* no report header groups? */ | public ReportHeaderGroup getReportHeaderGroup(int col)
{
/* no report header groups? */
if (ListTools.isEmpty(this.rptHdrGrps)) {
return null;
}
/* search for column */
for (ReportHeaderGroup rhg : this.rptHdrGrps) {
int C = rhg.getColIndex();
if (col == C) {
return rhg;
}
// TODO: optimize
}
/* not found */
return null;
} | NONSATD | true | public ReportHeaderGroup getReportHeaderGroup(int col)
{
/* no report header groups? */
if (ListTools.isEmpty(this.rptHdrGrps)) {
return null; | public ReportHeaderGroup getReportHeaderGroup(int col)
{
/* no report header groups? */
if (ListTools.isEmpty(this.rptHdrGrps)) {
return null;
}
/* search for column */
for (ReportHeaderGroup rhg : this.rptHdrGrps) {
int C = rhg.getColIndex();
if (col == C) {
return rhg;
}
// TODO: optimize | public ReportHeaderGroup getReportHeaderGroup(int col)
{
/* no report header groups? */
if (ListTools.isEmpty(this.rptHdrGrps)) {
return null;
}
/* search for column */
for (ReportHeaderGroup rhg : this.rptHdrGrps) {
int C = rhg.getColIndex();
if (col == C) {
return rhg;
}
// TODO: optimize
}
/* not found */
return null;
} |
34,109 | 2 | /* search for column */ | public ReportHeaderGroup getReportHeaderGroup(int col)
{
/* no report header groups? */
if (ListTools.isEmpty(this.rptHdrGrps)) {
return null;
}
/* search for column */
for (ReportHeaderGroup rhg : this.rptHdrGrps) {
int C = rhg.getColIndex();
if (col == C) {
return rhg;
}
// TODO: optimize
}
/* not found */
return null;
} | NONSATD | true | return null;
}
/* search for column */
for (ReportHeaderGroup rhg : this.rptHdrGrps) {
int C = rhg.getColIndex(); | public ReportHeaderGroup getReportHeaderGroup(int col)
{
/* no report header groups? */
if (ListTools.isEmpty(this.rptHdrGrps)) {
return null;
}
/* search for column */
for (ReportHeaderGroup rhg : this.rptHdrGrps) {
int C = rhg.getColIndex();
if (col == C) {
return rhg;
}
// TODO: optimize
}
/* not found */
return null;
} | public ReportHeaderGroup getReportHeaderGroup(int col)
{
/* no report header groups? */
if (ListTools.isEmpty(this.rptHdrGrps)) {
return null;
}
/* search for column */
for (ReportHeaderGroup rhg : this.rptHdrGrps) {
int C = rhg.getColIndex();
if (col == C) {
return rhg;
}
// TODO: optimize
}
/* not found */
return null;
} |
34,109 | 3 | // TODO: optimize | public ReportHeaderGroup getReportHeaderGroup(int col)
{
/* no report header groups? */
if (ListTools.isEmpty(this.rptHdrGrps)) {
return null;
}
/* search for column */
for (ReportHeaderGroup rhg : this.rptHdrGrps) {
int C = rhg.getColIndex();
if (col == C) {
return rhg;
}
// TODO: optimize
}
/* not found */
return null;
} | DESIGN | true | return rhg;
}
// TODO: optimize
}
/* not found */ | /* no report header groups? */
if (ListTools.isEmpty(this.rptHdrGrps)) {
return null;
}
/* search for column */
for (ReportHeaderGroup rhg : this.rptHdrGrps) {
int C = rhg.getColIndex();
if (col == C) {
return rhg;
}
// TODO: optimize
}
/* not found */
return null;
} | public ReportHeaderGroup getReportHeaderGroup(int col)
{
/* no report header groups? */
if (ListTools.isEmpty(this.rptHdrGrps)) {
return null;
}
/* search for column */
for (ReportHeaderGroup rhg : this.rptHdrGrps) {
int C = rhg.getColIndex();
if (col == C) {
return rhg;
}
// TODO: optimize
}
/* not found */
return null;
} |
34,109 | 4 | /* not found */ | public ReportHeaderGroup getReportHeaderGroup(int col)
{
/* no report header groups? */
if (ListTools.isEmpty(this.rptHdrGrps)) {
return null;
}
/* search for column */
for (ReportHeaderGroup rhg : this.rptHdrGrps) {
int C = rhg.getColIndex();
if (col == C) {
return rhg;
}
// TODO: optimize
}
/* not found */
return null;
} | NONSATD | true | // TODO: optimize
}
/* not found */
return null;
} | return null;
}
/* search for column */
for (ReportHeaderGroup rhg : this.rptHdrGrps) {
int C = rhg.getColIndex();
if (col == C) {
return rhg;
}
// TODO: optimize
}
/* not found */
return null;
} | public ReportHeaderGroup getReportHeaderGroup(int col)
{
/* no report header groups? */
if (ListTools.isEmpty(this.rptHdrGrps)) {
return null;
}
/* search for column */
for (ReportHeaderGroup rhg : this.rptHdrGrps) {
int C = rhg.getColIndex();
if (col == C) {
return rhg;
}
// TODO: optimize
}
/* not found */
return null;
} |
25,919 | 0 | // get remote repositories | private void buildDependencyTree( Queue<DependencyNode> nodeQueue, boolean full, boolean online, Session session, Map<String, Profile> profiles, PomFileLoader loader, Log log )
{
int neededLevels = full ? -1 : 1;
while( !nodeQueue.isEmpty() )
{
DependencyNode node = nodeQueue.poll();
if( neededLevels >= 0 && node.getLevel() >= neededLevels )
continue;
node.collectDependencyManagement( profiles, session.projects(), log );
Map<DependencyKey, RawDependency> localDependencies = getHierarchicalDependencies( session, node.getProject(), null, online, profiles, log );
if( localDependencies == null )
continue;
for( Entry<DependencyKey, RawDependency> e : localDependencies.entrySet() )
{
DependencyKey dependencyKey = e.getKey();
RawDependency dependency = e.getValue();
if( dependency.isOptional() && !node.isRoot() )
continue;
GroupArtifact ga = new GroupArtifact( dependencyKey.getGroupId(), dependencyKey.getArtifactId() );
if( isGroupArtifactExcluded( node, ga ) )
continue;
DependencyNode existingNode = node.searchNodeForGroupArtifact( ga );
if( existingNode != null )
{
if( existingNode.getLevel() <= node.getLevel() + 1 )
continue;
else
existingNode.removeFromParent();
}
final Optional<VersionScope> optionalVs = getVersionScopeFromDependencyManagement( node, dependencyKey, dependency );
final VersionScope vs;
if(optionalVs.isPresent() )
{
vs = optionalVs.get();
}
else
{
vs = dependency.getVs();
if( node.isRoot() )
{
if(vs.getScope() == null) {
vs.setScope( Scope.COMPILE );
}
}
else
{
Scope scope = Scope.getScopeTransformation( node.getVs().getScope(), dependency.getVs().getScope() );
if(scope == null )
continue;
vs.setScope( scope );
}
}
Scope scope = vs.getScope();
assert scope != null;
assert vs.getVersion() != null : "null version of dependency " + dependencyKey + " -> " + dependency + " (for project " + project + ")";
if( scope == Scope.IMPORT || scope == Scope.SYSTEM )
continue;
// get remote repositories
List<Repository> additionalRepos = getProjectRepositories( session, node.getProject(), log );
Gav dependencyGav = new Gav( dependencyKey.getGroupId(), dependencyKey.getArtifactId(), vs.getVersion() );
Project childProject = null;
if( neededLevels < 0 || node.getLevel() >= neededLevels )
{
childProject = session.projects().forGav( dependencyGav );
if( childProject == null )
{
File pomFile = loader.loadPomFileForGav( dependencyGav, additionalRepos, log );
if( pomFile == null )
{
log.html( Tools.errorMessage( "cannot fetch project " + dependencyGav + " referenced in " + node.getProject() ) );
continue;
}
PomAnalysis analysis = new PomAnalysis( session, loader, null, false, log );
analysis.addFile( pomFile );
Set<Project> loadedProjects = analysis.loadProjects();
if( loadedProjects.size() != 1 )
{
log.html( Tools.errorMessage( "cannot fetch project " + dependencyGav + " referenced in " + node.getProject() ) );
continue;
}
childProject = loadedProjects.iterator().next();
analysis.completeLoadedProjects();
analysis.addCompletedProjectsToSession();
Set<Project> addedToGraph = analysis.addCompletedProjectsToGraph();
if( !addedToGraph.contains( childProject ) )
{
log.html( Tools.errorMessage( "cannot fetch project " + dependencyGav + " referenced in " + node.getProject() ) );
continue;
}
}
if( childProject == null )
{
// TODO : use specified repositories if needed !
log.html( Tools.warningMessage( "cannot fetch project " + dependencyGav + " referenced in " + node.getProject() + (dependency.isOptional() ? " (this is an optional dependency)" : "") ) );
continue;
}
}
DependencyNode child = new DependencyNode( childProject, dependencyKey, vs );
child.addExclusions( dependency.getExclusions() );
node.addChild( child );
DependencyManagement dm = node.getLocalManagement( dependencyKey );
if( dm != null )
child.addExclusions( dm.getExclusions() );
//FIXME is always false
if( scope == Scope.SYSTEM )
continue;
// TODO it seems to me that transitive dependency policy only
// applies to jar artifacts, is that true ??
// if( "jar".equals( dependencyKey.getType() ) )
nodeQueue.add( child );
}
}
} | NONSATD | true | if( scope == Scope.IMPORT || scope == Scope.SYSTEM )
continue;
// get remote repositories
List<Repository> additionalRepos = getProjectRepositories( session, node.getProject(), log );
Gav dependencyGav = new Gav( dependencyKey.getGroupId(), dependencyKey.getArtifactId(), vs.getVersion() ); | if(scope == null )
continue;
vs.setScope( scope );
}
}
Scope scope = vs.getScope();
assert scope != null;
assert vs.getVersion() != null : "null version of dependency " + dependencyKey + " -> " + dependency + " (for project " + project + ")";
if( scope == Scope.IMPORT || scope == Scope.SYSTEM )
continue;
// get remote repositories
List<Repository> additionalRepos = getProjectRepositories( session, node.getProject(), log );
Gav dependencyGav = new Gav( dependencyKey.getGroupId(), dependencyKey.getArtifactId(), vs.getVersion() );
Project childProject = null;
if( neededLevels < 0 || node.getLevel() >= neededLevels )
{
childProject = session.projects().forGav( dependencyGav );
if( childProject == null )
{
File pomFile = loader.loadPomFileForGav( dependencyGav, additionalRepos, log );
if( pomFile == null ) | vs = dependency.getVs();
if( node.isRoot() )
{
if(vs.getScope() == null) {
vs.setScope( Scope.COMPILE );
}
}
else
{
Scope scope = Scope.getScopeTransformation( node.getVs().getScope(), dependency.getVs().getScope() );
if(scope == null )
continue;
vs.setScope( scope );
}
}
Scope scope = vs.getScope();
assert scope != null;
assert vs.getVersion() != null : "null version of dependency " + dependencyKey + " -> " + dependency + " (for project " + project + ")";
if( scope == Scope.IMPORT || scope == Scope.SYSTEM )
continue;
// get remote repositories
List<Repository> additionalRepos = getProjectRepositories( session, node.getProject(), log );
Gav dependencyGav = new Gav( dependencyKey.getGroupId(), dependencyKey.getArtifactId(), vs.getVersion() );
Project childProject = null;
if( neededLevels < 0 || node.getLevel() >= neededLevels )
{
childProject = session.projects().forGav( dependencyGav );
if( childProject == null )
{
File pomFile = loader.loadPomFileForGav( dependencyGav, additionalRepos, log );
if( pomFile == null )
{
log.html( Tools.errorMessage( "cannot fetch project " + dependencyGav + " referenced in " + node.getProject() ) );
continue;
}
PomAnalysis analysis = new PomAnalysis( session, loader, null, false, log );
analysis.addFile( pomFile );
Set<Project> loadedProjects = analysis.loadProjects();
if( loadedProjects.size() != 1 )
{
log.html( Tools.errorMessage( "cannot fetch project " + dependencyGav + " referenced in " + node.getProject() ) ); |
25,919 | 1 | // TODO : use specified repositories if needed ! | private void buildDependencyTree( Queue<DependencyNode> nodeQueue, boolean full, boolean online, Session session, Map<String, Profile> profiles, PomFileLoader loader, Log log )
{
int neededLevels = full ? -1 : 1;
while( !nodeQueue.isEmpty() )
{
DependencyNode node = nodeQueue.poll();
if( neededLevels >= 0 && node.getLevel() >= neededLevels )
continue;
node.collectDependencyManagement( profiles, session.projects(), log );
Map<DependencyKey, RawDependency> localDependencies = getHierarchicalDependencies( session, node.getProject(), null, online, profiles, log );
if( localDependencies == null )
continue;
for( Entry<DependencyKey, RawDependency> e : localDependencies.entrySet() )
{
DependencyKey dependencyKey = e.getKey();
RawDependency dependency = e.getValue();
if( dependency.isOptional() && !node.isRoot() )
continue;
GroupArtifact ga = new GroupArtifact( dependencyKey.getGroupId(), dependencyKey.getArtifactId() );
if( isGroupArtifactExcluded( node, ga ) )
continue;
DependencyNode existingNode = node.searchNodeForGroupArtifact( ga );
if( existingNode != null )
{
if( existingNode.getLevel() <= node.getLevel() + 1 )
continue;
else
existingNode.removeFromParent();
}
final Optional<VersionScope> optionalVs = getVersionScopeFromDependencyManagement( node, dependencyKey, dependency );
final VersionScope vs;
if(optionalVs.isPresent() )
{
vs = optionalVs.get();
}
else
{
vs = dependency.getVs();
if( node.isRoot() )
{
if(vs.getScope() == null) {
vs.setScope( Scope.COMPILE );
}
}
else
{
Scope scope = Scope.getScopeTransformation( node.getVs().getScope(), dependency.getVs().getScope() );
if(scope == null )
continue;
vs.setScope( scope );
}
}
Scope scope = vs.getScope();
assert scope != null;
assert vs.getVersion() != null : "null version of dependency " + dependencyKey + " -> " + dependency + " (for project " + project + ")";
if( scope == Scope.IMPORT || scope == Scope.SYSTEM )
continue;
// get remote repositories
List<Repository> additionalRepos = getProjectRepositories( session, node.getProject(), log );
Gav dependencyGav = new Gav( dependencyKey.getGroupId(), dependencyKey.getArtifactId(), vs.getVersion() );
Project childProject = null;
if( neededLevels < 0 || node.getLevel() >= neededLevels )
{
childProject = session.projects().forGav( dependencyGav );
if( childProject == null )
{
File pomFile = loader.loadPomFileForGav( dependencyGav, additionalRepos, log );
if( pomFile == null )
{
log.html( Tools.errorMessage( "cannot fetch project " + dependencyGav + " referenced in " + node.getProject() ) );
continue;
}
PomAnalysis analysis = new PomAnalysis( session, loader, null, false, log );
analysis.addFile( pomFile );
Set<Project> loadedProjects = analysis.loadProjects();
if( loadedProjects.size() != 1 )
{
log.html( Tools.errorMessage( "cannot fetch project " + dependencyGav + " referenced in " + node.getProject() ) );
continue;
}
childProject = loadedProjects.iterator().next();
analysis.completeLoadedProjects();
analysis.addCompletedProjectsToSession();
Set<Project> addedToGraph = analysis.addCompletedProjectsToGraph();
if( !addedToGraph.contains( childProject ) )
{
log.html( Tools.errorMessage( "cannot fetch project " + dependencyGav + " referenced in " + node.getProject() ) );
continue;
}
}
if( childProject == null )
{
// TODO : use specified repositories if needed !
log.html( Tools.warningMessage( "cannot fetch project " + dependencyGav + " referenced in " + node.getProject() + (dependency.isOptional() ? " (this is an optional dependency)" : "") ) );
continue;
}
}
DependencyNode child = new DependencyNode( childProject, dependencyKey, vs );
child.addExclusions( dependency.getExclusions() );
node.addChild( child );
DependencyManagement dm = node.getLocalManagement( dependencyKey );
if( dm != null )
child.addExclusions( dm.getExclusions() );
//FIXME is always false
if( scope == Scope.SYSTEM )
continue;
// TODO it seems to me that transitive dependency policy only
// applies to jar artifacts, is that true ??
// if( "jar".equals( dependencyKey.getType() ) )
nodeQueue.add( child );
}
}
} | IMPLEMENTATION | true | if( childProject == null )
{
// TODO : use specified repositories if needed !
log.html( Tools.warningMessage( "cannot fetch project " + dependencyGav + " referenced in " + node.getProject() + (dependency.isOptional() ? " (this is an optional dependency)" : "") ) );
continue; | analysis.addCompletedProjectsToSession();
Set<Project> addedToGraph = analysis.addCompletedProjectsToGraph();
if( !addedToGraph.contains( childProject ) )
{
log.html( Tools.errorMessage( "cannot fetch project " + dependencyGav + " referenced in " + node.getProject() ) );
continue;
}
}
if( childProject == null )
{
// TODO : use specified repositories if needed !
log.html( Tools.warningMessage( "cannot fetch project " + dependencyGav + " referenced in " + node.getProject() + (dependency.isOptional() ? " (this is an optional dependency)" : "") ) );
continue;
}
}
DependencyNode child = new DependencyNode( childProject, dependencyKey, vs );
child.addExclusions( dependency.getExclusions() );
node.addChild( child );
DependencyManagement dm = node.getLocalManagement( dependencyKey );
if( dm != null )
child.addExclusions( dm.getExclusions() ); | PomAnalysis analysis = new PomAnalysis( session, loader, null, false, log );
analysis.addFile( pomFile );
Set<Project> loadedProjects = analysis.loadProjects();
if( loadedProjects.size() != 1 )
{
log.html( Tools.errorMessage( "cannot fetch project " + dependencyGav + " referenced in " + node.getProject() ) );
continue;
}
childProject = loadedProjects.iterator().next();
analysis.completeLoadedProjects();
analysis.addCompletedProjectsToSession();
Set<Project> addedToGraph = analysis.addCompletedProjectsToGraph();
if( !addedToGraph.contains( childProject ) )
{
log.html( Tools.errorMessage( "cannot fetch project " + dependencyGav + " referenced in " + node.getProject() ) );
continue;
}
}
if( childProject == null )
{
// TODO : use specified repositories if needed !
log.html( Tools.warningMessage( "cannot fetch project " + dependencyGav + " referenced in " + node.getProject() + (dependency.isOptional() ? " (this is an optional dependency)" : "") ) );
continue;
}
}
DependencyNode child = new DependencyNode( childProject, dependencyKey, vs );
child.addExclusions( dependency.getExclusions() );
node.addChild( child );
DependencyManagement dm = node.getLocalManagement( dependencyKey );
if( dm != null )
child.addExclusions( dm.getExclusions() );
//FIXME is always false
if( scope == Scope.SYSTEM )
continue;
// TODO it seems to me that transitive dependency policy only
// applies to jar artifacts, is that true ??
// if( "jar".equals( dependencyKey.getType() ) )
nodeQueue.add( child );
}
}
} |
25,919 | 2 | //FIXME is always false | private void buildDependencyTree( Queue<DependencyNode> nodeQueue, boolean full, boolean online, Session session, Map<String, Profile> profiles, PomFileLoader loader, Log log )
{
int neededLevels = full ? -1 : 1;
while( !nodeQueue.isEmpty() )
{
DependencyNode node = nodeQueue.poll();
if( neededLevels >= 0 && node.getLevel() >= neededLevels )
continue;
node.collectDependencyManagement( profiles, session.projects(), log );
Map<DependencyKey, RawDependency> localDependencies = getHierarchicalDependencies( session, node.getProject(), null, online, profiles, log );
if( localDependencies == null )
continue;
for( Entry<DependencyKey, RawDependency> e : localDependencies.entrySet() )
{
DependencyKey dependencyKey = e.getKey();
RawDependency dependency = e.getValue();
if( dependency.isOptional() && !node.isRoot() )
continue;
GroupArtifact ga = new GroupArtifact( dependencyKey.getGroupId(), dependencyKey.getArtifactId() );
if( isGroupArtifactExcluded( node, ga ) )
continue;
DependencyNode existingNode = node.searchNodeForGroupArtifact( ga );
if( existingNode != null )
{
if( existingNode.getLevel() <= node.getLevel() + 1 )
continue;
else
existingNode.removeFromParent();
}
final Optional<VersionScope> optionalVs = getVersionScopeFromDependencyManagement( node, dependencyKey, dependency );
final VersionScope vs;
if(optionalVs.isPresent() )
{
vs = optionalVs.get();
}
else
{
vs = dependency.getVs();
if( node.isRoot() )
{
if(vs.getScope() == null) {
vs.setScope( Scope.COMPILE );
}
}
else
{
Scope scope = Scope.getScopeTransformation( node.getVs().getScope(), dependency.getVs().getScope() );
if(scope == null )
continue;
vs.setScope( scope );
}
}
Scope scope = vs.getScope();
assert scope != null;
assert vs.getVersion() != null : "null version of dependency " + dependencyKey + " -> " + dependency + " (for project " + project + ")";
if( scope == Scope.IMPORT || scope == Scope.SYSTEM )
continue;
// get remote repositories
List<Repository> additionalRepos = getProjectRepositories( session, node.getProject(), log );
Gav dependencyGav = new Gav( dependencyKey.getGroupId(), dependencyKey.getArtifactId(), vs.getVersion() );
Project childProject = null;
if( neededLevels < 0 || node.getLevel() >= neededLevels )
{
childProject = session.projects().forGav( dependencyGav );
if( childProject == null )
{
File pomFile = loader.loadPomFileForGav( dependencyGav, additionalRepos, log );
if( pomFile == null )
{
log.html( Tools.errorMessage( "cannot fetch project " + dependencyGav + " referenced in " + node.getProject() ) );
continue;
}
PomAnalysis analysis = new PomAnalysis( session, loader, null, false, log );
analysis.addFile( pomFile );
Set<Project> loadedProjects = analysis.loadProjects();
if( loadedProjects.size() != 1 )
{
log.html( Tools.errorMessage( "cannot fetch project " + dependencyGav + " referenced in " + node.getProject() ) );
continue;
}
childProject = loadedProjects.iterator().next();
analysis.completeLoadedProjects();
analysis.addCompletedProjectsToSession();
Set<Project> addedToGraph = analysis.addCompletedProjectsToGraph();
if( !addedToGraph.contains( childProject ) )
{
log.html( Tools.errorMessage( "cannot fetch project " + dependencyGav + " referenced in " + node.getProject() ) );
continue;
}
}
if( childProject == null )
{
// TODO : use specified repositories if needed !
log.html( Tools.warningMessage( "cannot fetch project " + dependencyGav + " referenced in " + node.getProject() + (dependency.isOptional() ? " (this is an optional dependency)" : "") ) );
continue;
}
}
DependencyNode child = new DependencyNode( childProject, dependencyKey, vs );
child.addExclusions( dependency.getExclusions() );
node.addChild( child );
DependencyManagement dm = node.getLocalManagement( dependencyKey );
if( dm != null )
child.addExclusions( dm.getExclusions() );
//FIXME is always false
if( scope == Scope.SYSTEM )
continue;
// TODO it seems to me that transitive dependency policy only
// applies to jar artifacts, is that true ??
// if( "jar".equals( dependencyKey.getType() ) )
nodeQueue.add( child );
}
}
} | DEFECT | true | if( dm != null )
child.addExclusions( dm.getExclusions() );
//FIXME is always false
if( scope == Scope.SYSTEM )
continue; | log.html( Tools.warningMessage( "cannot fetch project " + dependencyGav + " referenced in " + node.getProject() + (dependency.isOptional() ? " (this is an optional dependency)" : "") ) );
continue;
}
}
DependencyNode child = new DependencyNode( childProject, dependencyKey, vs );
child.addExclusions( dependency.getExclusions() );
node.addChild( child );
DependencyManagement dm = node.getLocalManagement( dependencyKey );
if( dm != null )
child.addExclusions( dm.getExclusions() );
//FIXME is always false
if( scope == Scope.SYSTEM )
continue;
// TODO it seems to me that transitive dependency policy only
// applies to jar artifacts, is that true ??
// if( "jar".equals( dependencyKey.getType() ) )
nodeQueue.add( child );
}
}
} | Set<Project> addedToGraph = analysis.addCompletedProjectsToGraph();
if( !addedToGraph.contains( childProject ) )
{
log.html( Tools.errorMessage( "cannot fetch project " + dependencyGav + " referenced in " + node.getProject() ) );
continue;
}
}
if( childProject == null )
{
// TODO : use specified repositories if needed !
log.html( Tools.warningMessage( "cannot fetch project " + dependencyGav + " referenced in " + node.getProject() + (dependency.isOptional() ? " (this is an optional dependency)" : "") ) );
continue;
}
}
DependencyNode child = new DependencyNode( childProject, dependencyKey, vs );
child.addExclusions( dependency.getExclusions() );
node.addChild( child );
DependencyManagement dm = node.getLocalManagement( dependencyKey );
if( dm != null )
child.addExclusions( dm.getExclusions() );
//FIXME is always false
if( scope == Scope.SYSTEM )
continue;
// TODO it seems to me that transitive dependency policy only
// applies to jar artifacts, is that true ??
// if( "jar".equals( dependencyKey.getType() ) )
nodeQueue.add( child );
}
}
} |
25,919 | 3 | // TODO it seems to me that transitive dependency policy only
// applies to jar artifacts, is that true ??
// if( "jar".equals( dependencyKey.getType() ) ) | private void buildDependencyTree( Queue<DependencyNode> nodeQueue, boolean full, boolean online, Session session, Map<String, Profile> profiles, PomFileLoader loader, Log log )
{
int neededLevels = full ? -1 : 1;
while( !nodeQueue.isEmpty() )
{
DependencyNode node = nodeQueue.poll();
if( neededLevels >= 0 && node.getLevel() >= neededLevels )
continue;
node.collectDependencyManagement( profiles, session.projects(), log );
Map<DependencyKey, RawDependency> localDependencies = getHierarchicalDependencies( session, node.getProject(), null, online, profiles, log );
if( localDependencies == null )
continue;
for( Entry<DependencyKey, RawDependency> e : localDependencies.entrySet() )
{
DependencyKey dependencyKey = e.getKey();
RawDependency dependency = e.getValue();
if( dependency.isOptional() && !node.isRoot() )
continue;
GroupArtifact ga = new GroupArtifact( dependencyKey.getGroupId(), dependencyKey.getArtifactId() );
if( isGroupArtifactExcluded( node, ga ) )
continue;
DependencyNode existingNode = node.searchNodeForGroupArtifact( ga );
if( existingNode != null )
{
if( existingNode.getLevel() <= node.getLevel() + 1 )
continue;
else
existingNode.removeFromParent();
}
final Optional<VersionScope> optionalVs = getVersionScopeFromDependencyManagement( node, dependencyKey, dependency );
final VersionScope vs;
if(optionalVs.isPresent() )
{
vs = optionalVs.get();
}
else
{
vs = dependency.getVs();
if( node.isRoot() )
{
if(vs.getScope() == null) {
vs.setScope( Scope.COMPILE );
}
}
else
{
Scope scope = Scope.getScopeTransformation( node.getVs().getScope(), dependency.getVs().getScope() );
if(scope == null )
continue;
vs.setScope( scope );
}
}
Scope scope = vs.getScope();
assert scope != null;
assert vs.getVersion() != null : "null version of dependency " + dependencyKey + " -> " + dependency + " (for project " + project + ")";
if( scope == Scope.IMPORT || scope == Scope.SYSTEM )
continue;
// get remote repositories
List<Repository> additionalRepos = getProjectRepositories( session, node.getProject(), log );
Gav dependencyGav = new Gav( dependencyKey.getGroupId(), dependencyKey.getArtifactId(), vs.getVersion() );
Project childProject = null;
if( neededLevels < 0 || node.getLevel() >= neededLevels )
{
childProject = session.projects().forGav( dependencyGav );
if( childProject == null )
{
File pomFile = loader.loadPomFileForGav( dependencyGav, additionalRepos, log );
if( pomFile == null )
{
log.html( Tools.errorMessage( "cannot fetch project " + dependencyGav + " referenced in " + node.getProject() ) );
continue;
}
PomAnalysis analysis = new PomAnalysis( session, loader, null, false, log );
analysis.addFile( pomFile );
Set<Project> loadedProjects = analysis.loadProjects();
if( loadedProjects.size() != 1 )
{
log.html( Tools.errorMessage( "cannot fetch project " + dependencyGav + " referenced in " + node.getProject() ) );
continue;
}
childProject = loadedProjects.iterator().next();
analysis.completeLoadedProjects();
analysis.addCompletedProjectsToSession();
Set<Project> addedToGraph = analysis.addCompletedProjectsToGraph();
if( !addedToGraph.contains( childProject ) )
{
log.html( Tools.errorMessage( "cannot fetch project " + dependencyGav + " referenced in " + node.getProject() ) );
continue;
}
}
if( childProject == null )
{
// TODO : use specified repositories if needed !
log.html( Tools.warningMessage( "cannot fetch project " + dependencyGav + " referenced in " + node.getProject() + (dependency.isOptional() ? " (this is an optional dependency)" : "") ) );
continue;
}
}
DependencyNode child = new DependencyNode( childProject, dependencyKey, vs );
child.addExclusions( dependency.getExclusions() );
node.addChild( child );
DependencyManagement dm = node.getLocalManagement( dependencyKey );
if( dm != null )
child.addExclusions( dm.getExclusions() );
//FIXME is always false
if( scope == Scope.SYSTEM )
continue;
// TODO it seems to me that transitive dependency policy only
// applies to jar artifacts, is that true ??
// if( "jar".equals( dependencyKey.getType() ) )
nodeQueue.add( child );
}
}
} | DESIGN | true | if( scope == Scope.SYSTEM )
continue;
// TODO it seems to me that transitive dependency policy only
// applies to jar artifacts, is that true ??
// if( "jar".equals( dependencyKey.getType() ) )
nodeQueue.add( child );
} | }
DependencyNode child = new DependencyNode( childProject, dependencyKey, vs );
child.addExclusions( dependency.getExclusions() );
node.addChild( child );
DependencyManagement dm = node.getLocalManagement( dependencyKey );
if( dm != null )
child.addExclusions( dm.getExclusions() );
//FIXME is always false
if( scope == Scope.SYSTEM )
continue;
// TODO it seems to me that transitive dependency policy only
// applies to jar artifacts, is that true ??
// if( "jar".equals( dependencyKey.getType() ) )
nodeQueue.add( child );
}
}
} | log.html( Tools.errorMessage( "cannot fetch project " + dependencyGav + " referenced in " + node.getProject() ) );
continue;
}
}
if( childProject == null )
{
// TODO : use specified repositories if needed !
log.html( Tools.warningMessage( "cannot fetch project " + dependencyGav + " referenced in " + node.getProject() + (dependency.isOptional() ? " (this is an optional dependency)" : "") ) );
continue;
}
}
DependencyNode child = new DependencyNode( childProject, dependencyKey, vs );
child.addExclusions( dependency.getExclusions() );
node.addChild( child );
DependencyManagement dm = node.getLocalManagement( dependencyKey );
if( dm != null )
child.addExclusions( dm.getExclusions() );
//FIXME is always false
if( scope == Scope.SYSTEM )
continue;
// TODO it seems to me that transitive dependency policy only
// applies to jar artifacts, is that true ??
// if( "jar".equals( dependencyKey.getType() ) )
nodeQueue.add( child );
}
}
} |
1,344 | 0 | //TODO: this may take foreever. fix | private int generateNewTicketNumber()
{
//TODO: this may take foreever. fix
int generated = numberGenerator.next();
while(purchased.containsKey(generated)){
generated = numberGenerator.next();
}
return generated;
} | DEFECT | true | private int generateNewTicketNumber()
{
//TODO: this may take foreever. fix
int generated = numberGenerator.next();
while(purchased.containsKey(generated)){ | private int generateNewTicketNumber()
{
//TODO: this may take foreever. fix
int generated = numberGenerator.next();
while(purchased.containsKey(generated)){
generated = numberGenerator.next();
}
return generated;
} | private int generateNewTicketNumber()
{
//TODO: this may take foreever. fix
int generated = numberGenerator.next();
while(purchased.containsKey(generated)){
generated = numberGenerator.next();
}
return generated;
} |
17,729 | 0 | /**
* Place the cell within the grid layout at the specified row and column.
*
* @param parent - the cell's parent
* @param row - the row that the cell will be set at
* @param col - the column that the cell will be set at
*/ | public void setParentAtRowAndColumn(GridLayout parent, int row, int col)
{
// prepare the layout parameters for the EditText
// TODO: Consider caching the layout params and only changing the spec row and spec column
LayoutParams layoutParams = new GridLayout.LayoutParams();
layoutParams.width = LayoutParams.WRAP_CONTENT;
layoutParams.height = LayoutParams.WRAP_CONTENT;
// set the row and column in the correct location of the Sudoku Board
layoutParams.rowSpec = GridLayout.spec(row);
layoutParams.columnSpec = GridLayout.spec(col);
// set the layout params and add the EditText to the GridLayout parent
_text.setLayoutParams(layoutParams);
parent.addView(_text);
} | NONSATD | true | public void setParentAtRowAndColumn(GridLayout parent, int row, int col)
{
// prepare the layout parameters for the EditText
// TODO: Consider caching the layout params and only changing the spec row and spec column
LayoutParams layoutParams = new GridLayout.LayoutParams();
layoutParams.width = LayoutParams.WRAP_CONTENT;
layoutParams.height = LayoutParams.WRAP_CONTENT;
// set the row and column in the correct location of the Sudoku Board
layoutParams.rowSpec = GridLayout.spec(row);
layoutParams.columnSpec = GridLayout.spec(col);
// set the layout params and add the EditText to the GridLayout parent
_text.setLayoutParams(layoutParams);
parent.addView(_text);
} | public void setParentAtRowAndColumn(GridLayout parent, int row, int col)
{
// prepare the layout parameters for the EditText
// TODO: Consider caching the layout params and only changing the spec row and spec column
LayoutParams layoutParams = new GridLayout.LayoutParams();
layoutParams.width = LayoutParams.WRAP_CONTENT;
layoutParams.height = LayoutParams.WRAP_CONTENT;
// set the row and column in the correct location of the Sudoku Board
layoutParams.rowSpec = GridLayout.spec(row);
layoutParams.columnSpec = GridLayout.spec(col);
// set the layout params and add the EditText to the GridLayout parent
_text.setLayoutParams(layoutParams);
parent.addView(_text);
} | public void setParentAtRowAndColumn(GridLayout parent, int row, int col)
{
// prepare the layout parameters for the EditText
// TODO: Consider caching the layout params and only changing the spec row and spec column
LayoutParams layoutParams = new GridLayout.LayoutParams();
layoutParams.width = LayoutParams.WRAP_CONTENT;
layoutParams.height = LayoutParams.WRAP_CONTENT;
// set the row and column in the correct location of the Sudoku Board
layoutParams.rowSpec = GridLayout.spec(row);
layoutParams.columnSpec = GridLayout.spec(col);
// set the layout params and add the EditText to the GridLayout parent
_text.setLayoutParams(layoutParams);
parent.addView(_text);
} |