while (it.hasNext()) { String id = it.next(); IComponentInfo c = get(id); if (c.getType().equals(IComponent.TYPE.EVENT)) { IEvent event = (IEvent) c; Calendar sd = event.getDtStart(); if (startDate.equals(sd)) result.add(id); } else if (c.getType().equals(IComponent.TYPE.TODO)) { ITodo todo = (ITodo) c; Calendar sd = todo.getDtStart(); Calendar endDate = todo.getDue(); IDateRange dr = new DateRange(startDate, endDate); if (startDate.equals(sd)) result.add(id); } else throw new IllegalArgumentException( "unsupported component type " + c.getType()); }
Document doc = retrieveDocument(is); Element menubarElement = doc.getRootElement(); if (menubarElement.getName().equals(MenuXMLDecoder.MENUBAR) == false) { LOG.severe("root element <menubar> expected"); return null; } ExtendableMenuBar menuBar = new ExtendableMenuBar(); Iterator it = menubarElement.getChildren().listIterator(); while (it.hasNext()) { Element menuElement = (Element) it.next(); if (menuElement.getName().equals(MenuXMLDecoder.MENU)) { String menuId = menuElement .getAttributeValue(MenuXMLDecoder.ID); String menuName = mediator.getString("menu", "mainframe", menuId); ExtendableMenu menu = new ExtendableMenu(menuId, menuName); parseMenu(menu, menuElement); menuBar.add(menu); } } return menuBar;
Clone fragments detected by clone detection tool
File path: /columba-1.4-src/calendar/src/main/java/org/columba/calendar/store/LocalCalendarStore.java File path: /columba-1.4-src/core/src/main/java/org/columba/core/gui/menu/MenuXMLDecoder.java
Method name: Iterator findByStartDate(Calendar) Method name: ExtendableMenuBar createMenuBar(InputStream)
Number of AST nodes: 16 Number of AST nodes: 16
1
while (it.hasNext()) {
2
			String id = it.next();
1
Document doc = retrieveDocument(is);
3
			IComponentInfo c = get(id);
2
		Element menubarElement = doc.getRootElement();
4
			if (c.getType().equals(IComponent.TYPE.EVENT)) {
3
		if (menubarElement.getName().equals(
5
				IEvent event = (IEvent) c;
6
				Calendar sd = event.getDtStart();
7
				if (startDate.equals(sd))
8
					result.add(id);
9
			} else if (c
4
MenuXMLDecoder.MENUBAR) == false) {
5
			LOG.severe("root element <menubar> expected");
6
			return null;
7
		}
8
		ExtendableMenuBar menuBar = new ExtendableMenuBar();
9
		Iterator it = menubarElement.getChildren().listIterator();
10
		while (it.hasNext()) {
11
			Element menuElement = (Element) it.next();
10
.getType().equals(IComponent.TYPE.TODO)) {
12
			if (menuElement.getName().equals(MenuXMLDecoder.MENU)) {
11
				ITodo todo = (ITodo) c;
13
				
12
				Calendar sd = todo.getDtStart(
14
String menuId = menuElement
13
);
15
						.getAttributeValue(MenuXMLDecoder.ID);
14
				Calendar endDate = todo.getDue(
16
				String menuName = mediator.getString("menu", "mainframe",
15
);
17
						menuId);
16
				IDateRange dr = new DateRange(startDate, endDate);
18
				ExtendableMenu menu = new ExtendableMenu(menuId, menuName);
17
				if (startDate.equals(sd))
19
				
18
					result
20
parseMenu(menu, menuElement);
19
.add(id);
21
				menuBar.add(menu);
20
			} else
22
			}
21
				throw new IllegalArgumentException(
22
						"unsupported component type " + c.getType());
23
		}
23
		}
24
		return menuBar;
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.5
Clones locationClones are in different classes
Number of node comparisons2