List of usage examples for java.util LinkedList removeLast
public E removeLast()
From source file:com.heliosapm.script.AbstractDeployedScript.java
public String[] getPathSegments(final int trim) { if (trim == 0) return pathSegments.clone(); final int pLength = pathSegments.length; final int absTrim = Math.abs(trim); if (absTrim > pLength) throw new IllegalArgumentException("The requested trim [" + trim + "] is larger than the path segment [" + pathSegments.length + "]"); if (absTrim == pLength) return new String[0]; LinkedList<String> psegs = new LinkedList<String>(Arrays.asList(pathSegments)); for (int i = 0; i < absTrim; i++) { if (trim < 0) psegs.removeFirst();/*from ww w .j a v a 2s . c o m*/ else psegs.removeLast(); } return psegs.toArray(new String[pLength - absTrim]); }
From source file:uniol.apt.adt.automaton.FiniteAutomatonUtility.java
/** * Find a word whose prefixes (including the word) conform to a given predicate and which itself also conforms * to a second predicate.//from w w w. j a v a2s .c o m * * This method uses a depth-first search. A breath-first search would use more memory. * * @param a The automaton whose accepted words should get checked. * @param prefixPredicate The predicate to check the prefixes. * @param wordPredicate The predicate to check the words. * @return A word which conforms to the predicates. */ static public List<String> findPredicateWord(FiniteAutomaton a, Predicate<List<String>> prefixPredicate, Predicate<List<String>> wordPredicate) { MinimalDeterministicFiniteAutomaton dfa = minimizeInternal(a); Deque<Pair<DFAState, Iterator<Symbol>>> trace = new ArrayDeque<>(); LinkedList<String> word = new LinkedList<>(); DFAState initial = dfa.getInitialState(); DFAState sinkState = findSinkState(dfa); trace.add(new Pair<>(initial, initial.getDefinedSymbols().iterator())); while (!trace.isEmpty()) { Pair<DFAState, Iterator<Symbol>> pair = trace.peekLast(); if (!pair.getSecond().hasNext()) { trace.removeLast(); word.pollLast(); } else { Symbol symbol = pair.getSecond().next(); DFAState nextState = pair.getFirst().getFollowingState(symbol); if (!nextState.equals(sinkState)) { word.add(symbol.getEvent()); List<String> roWord = ListUtils.unmodifiableList(word); if (prefixPredicate.evaluate(roWord)) { trace.addLast(new Pair<>(nextState, nextState.getDefinedSymbols().iterator())); if (nextState.isFinalState() && wordPredicate.evaluate(roWord)) return word; } else { word.removeLast(); } } } } return null; }
From source file:ome.services.graphs.GraphState.java
/** * Walk throw the sub-spec graph again, using the results provided to build * up a graph of {@link GraphStep} instances. *//* w w w . j ava 2 s. co m*/ private void parse(GraphSpec spec, GraphTables tables, LinkedList<GraphStep> stack, long[] match) throws GraphException { final List<GraphEntry> entries = spec.entries(); for (int i = 0; i < entries.size(); i++) { final GraphEntry entry = entries.get(i); final GraphSpec subSpec = entry.getSubSpec(); Iterator<List<long[]>> it = tables.columnSets(entry, match); while (it.hasNext()) { List<long[]> columnSet = it.next(); if (columnSet.size() == 0) { continue; } // For the spec containers, we create a single step // per column-set. if (subSpec != null) { GraphStep step = factory.create(steps.size(), stack, spec, entry, null); stack.add(step); parse(subSpec, tables, stack, columnSet.get(0)); stack.removeLast(); this.steps.add(step); } else { // But for the actual entries, we create a step per // individual row. for (long[] cols : columnSet) { GraphStep step = factory.create(steps.size(), stack, spec, entry, cols); this.steps.add(step); } } } } }
From source file:appeng.items.tools.powered.ToolColorApplicator.java
private ItemStack findNextColor(final ItemStack is, final ItemStack anchor, final int scrollOffset) { ItemStack newColor = null;// w w w . java2 s . c o m final IMEInventory<IAEItemStack> inv = AEApi.instance().registries().cell().getCellInventory(is, null, StorageChannel.ITEMS); if (inv != null) { final IItemList<IAEItemStack> itemList = inv .getAvailableItems(AEApi.instance().storage().createItemList()); if (anchor == null) { final IAEItemStack firstItem = itemList.getFirstItem(); if (firstItem != null) { newColor = firstItem.getItemStack(); } } else { final LinkedList<IAEItemStack> list = new LinkedList<IAEItemStack>(); for (final IAEItemStack i : itemList) { list.add(i); } Collections.sort(list, new Comparator<IAEItemStack>() { @Override public int compare(final IAEItemStack a, final IAEItemStack b) { return ItemSorters.compareInt(a.getItemDamage(), b.getItemDamage()); } }); if (list.size() <= 0) { return null; } IAEItemStack where = list.getFirst(); int cycles = 1 + list.size(); while (cycles > 0 && !where.equals(anchor)) { list.addLast(list.removeFirst()); cycles--; where = list.getFirst(); } if (scrollOffset > 0) { list.addLast(list.removeFirst()); } if (scrollOffset < 0) { list.addFirst(list.removeLast()); } return list.get(0).getItemStack(); } } if (newColor != null) { this.setColor(is, newColor); } return newColor; }
From source file:com.linuxbox.enkive.web.StatsServlet.java
private void consolidateMapsHelper(Map<String, Object> templateData, Map<String, Object> consolidatedMap, LinkedList<String> path, List<ConsolidationKeyHandler> statKeys, List<Map<String, Object>> serviceData) { for (String key : templateData.keySet()) { path.addLast(key);/* w w w . ja v a 2 s . c o m*/ ConsolidationKeyHandler matchingConsolidationDefinition = findMatchingPath(path, statKeys); if (matchingConsolidationDefinition != null) { TreeSet<Map<String, Object>> dataSet = new TreeSet<Map<String, Object>>(new NumComparator()); for (Map<String, Object> dataMap : serviceData) { Map<String, Object> dataVal = createMap(getDataVal(dataMap, path)); if (dataVal != null && !dataVal.isEmpty()) { dataVal.put(STAT_TIMESTAMP, dataMap.get(STAT_TIMESTAMP)); dataSet.add(dataVal); } } putOnPath(path, consolidatedMap, dataSet); } else { if (templateData.get(key) instanceof Map) { consolidateMapsHelper((Map<String, Object>) templateData.get(key), consolidatedMap, path, statKeys, serviceData); } } path.removeLast(); } }
From source file:org.eclipse.swordfish.core.configuration.xml.XmlToPropertiesTransformerImpl.java
public void loadConfiguration(URL path) { Assert.notNull(path);//from ww w . j av a2 s . co m InputStream inputStream = null; try { inputStream = path.openStream(); XMLInputFactory inputFactory = XMLInputFactory.newInstance(); LinkedList<String> currentElements = new LinkedList<String>(); XMLEventReader eventReader = inputFactory.createXMLEventReader(inputStream); Map<String, List<String>> props = new HashMap<String, List<String>>(); // Read the XML document while (eventReader.hasNext()) { XMLEvent event = eventReader.nextEvent(); if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) { putElement(props, getQualifiedName(currentElements), event.asCharacters().getData()); } else if (event.isStartElement()) { currentElements.add(event.asStartElement().getName().getLocalPart()); for (Iterator attrIt = event.asStartElement().getAttributes(); attrIt.hasNext();) { Attribute attribute = (Attribute) attrIt.next(); putElement(props, getQualifiedName(currentElements) + "[@" + attribute.getName() + "]", attribute.getValue()); } } else if (event.isAttribute()) { } else if (event.isEndElement()) { String lastElem = event.asEndElement().getName().getLocalPart(); if (!currentElements.getLast().equals(lastElem)) { throw new UnsupportedOperationException(lastElem + "," + currentElements.getLast()); } currentElements.removeLast(); } } properties = flattenProperties(props); } catch (Exception ex) { throw new SwordfishException(ex); } finally { if (inputStream != null) { try { inputStream.close(); } catch (IOException ex) { } } } }
From source file:org.wso2.carbon.ui.BreadCrumbGenerator.java
/** * Generates breadcrumb html content.//from w w w. j a v a 2 s .c om * Please do not add line breaks to places where HTML content is written. * It makes debugging difficult. * @param request * @param currentPageHeader * @return String */ public HashMap<String, String> getBreadCrumbContent(HttpServletRequest request, BreadCrumbItem currentBreadcrumbItem, String jspFilePath, boolean topPage, boolean removeLastItem) { String breadcrumbCookieString = ""; //int lastIndexofSlash = jspFilePath.lastIndexOf(System.getProperty("file.separator")); //int lastIndexofSlash = jspFilePath.lastIndexOf('/'); StringBuffer content = new StringBuffer(); StringBuffer cookieContent = new StringBuffer(); HashMap<String, String> breadcrumbContents = new HashMap<String, String>(); HashMap<String, BreadCrumbItem> breadcrumbs = (HashMap<String, BreadCrumbItem>) request.getSession() .getAttribute("breadcrumbs"); String menuId = request.getParameter("item"); String region = request.getParameter("region"); String ordinalStr = request.getParameter("ordinal"); if (topPage) { //some wizards redirect to index page of the component after doing some operations. //Hence a map of region & menuId for component/index page is maintained & retrieved //by passing index page (eg: ../service-mgt/index.jsp) //This logic should run only for pages marked as toppage=true if (menuId == null && region == null) { HashMap<String, String> indexPageBreadcrumbParamMap = (HashMap<String, String>) request.getSession() .getAttribute("index-page-breadcrumb-param-map"); //eg: indexPageBreadcrumbParamMap contains ../service-mgt/index.jsp : region1,services_list_menu pattern if (indexPageBreadcrumbParamMap != null && !(indexPageBreadcrumbParamMap.isEmpty())) { String params = indexPageBreadcrumbParamMap.get(jspFilePath); if (params != null) { region = params.substring(0, params.indexOf(',')); menuId = params.substring(params.indexOf(',') + 1); } } } } if (menuId != null && region != null) { String key = region.trim() + "-" + menuId.trim(); HashMap<String, String> breadcrumbMap = (HashMap<String, String>) request.getSession() .getAttribute(region + "menu-id-breadcrumb-map"); String breadCrumb = ""; if (breadcrumbMap != null && !(breadcrumbMap.isEmpty())) { breadCrumb = breadcrumbMap.get(key); } if (breadCrumb != null) { content.append("<table cellspacing=\"0\"><tr>"); Locale locale = CarbonUIUtil.getLocaleFromSession(request); String homeText = CarbonUIUtil.geti18nString("component.home", "org.wso2.carbon.i18n.Resources", locale); content.append("<td class=\"breadcrumb-link\"><a href=\"" + CarbonUIUtil.getHomePage() + "\">" + homeText + "</a></td>"); cookieContent.append(breadCrumb); cookieContent.append("#"); generateBreadcrumbForMenuPath(content, breadcrumbs, breadCrumb, true); } } else { HashMap<String, List<BreadCrumbItem>> links = (HashMap<String, List<BreadCrumbItem>>) request .getSession().getAttribute("page-breadcrumbs"); //call came within a page. Retrieve the breadcrumb cookie Cookie[] cookies = request.getCookies(); for (int a = 0; a < cookies.length; a++) { Cookie cookie = cookies[a]; if ("current-breadcrumb".equals(cookie.getName())) { breadcrumbCookieString = cookie.getValue(); //bringing back the , breadcrumbCookieString = breadcrumbCookieString.replace("%2C", ","); //bringing back the # breadcrumbCookieString = breadcrumbCookieString.replace("%23", "#"); if (log.isDebugEnabled()) { log.debug("cookie :" + cookie.getName() + " : " + breadcrumbCookieString); } } } if (links != null) { if (log.isDebugEnabled()) { log.debug("size of page-breadcrumbs is : " + links.size()); } content.append("<table cellspacing=\"0\"><tr>"); Locale locale = CarbonUIUtil.getLocaleFromSession(request); String homeText = CarbonUIUtil.geti18nString("component.home", "org.wso2.carbon.i18n.Resources", locale); content.append("<td class=\"breadcrumb-link\"><a href=\"" + CarbonUIUtil.getHomePage() + "\">" + homeText + "</a></td>"); String menuBreadcrumbs = ""; if (breadcrumbCookieString.indexOf('#') > -1) { menuBreadcrumbs = breadcrumbCookieString.substring(0, breadcrumbCookieString.indexOf('#')); } cookieContent.append(menuBreadcrumbs); cookieContent.append("#"); generateBreadcrumbForMenuPath(content, breadcrumbs, menuBreadcrumbs, false); int clickedBreadcrumbLocation = 0; if (ordinalStr != null) { //only clicking on already made page breadcrumb link will send this via request parameter try { clickedBreadcrumbLocation = Integer.parseInt(ordinalStr); } catch (NumberFormatException e) { // Do nothing log.warn("Found String for breadcrumb ordinal"); } } String pageBreadcrumbs = ""; if (breadcrumbCookieString.indexOf('#') > -1) { pageBreadcrumbs = breadcrumbCookieString.substring(breadcrumbCookieString.indexOf('#') + 1); } StringTokenizer st2 = new StringTokenizer(pageBreadcrumbs, "*"); String[] tokens = new String[st2.countTokens()]; int count = 0; String previousToken = ""; while (st2.hasMoreTokens()) { String currentToken = st2.nextToken(); //To avoid page refresh create breadcrumbs if (!currentToken.equals(previousToken)) { previousToken = currentToken; tokens[count] = currentToken; count++; } } //jspSubContext should be the same across all the breadcrumbs //(cookie is updated everytime a page is loaded) List<BreadCrumbItem> breadcrumbItems = null; // if(tokens != null && tokens.length > 0){ //String token = tokens[0]; //String jspSubContext = token.substring(0, token.indexOf('+')); //breadcrumbItems = links.get("../"+jspSubContext); // } LinkedList<String> tokenJSPFileOrder = new LinkedList<String>(); LinkedList<String> jspFileSubContextOrder = new LinkedList<String>(); HashMap<String, String> jspFileSubContextMap = new HashMap<String, String>(); for (int a = 0; a < tokens.length; a++) { String token = tokens[a]; if (token != null) { String jspFileName = token.substring(token.indexOf('+') + 1); String jspSubContext = token.substring(0, token.indexOf('+')); jspFileSubContextMap.put(jspFileName, jspSubContext); tokenJSPFileOrder.add(jspFileName); jspFileSubContextOrder.add(jspSubContext + "^" + jspFileName); } } if (clickedBreadcrumbLocation > 0) { int tokenCount = tokenJSPFileOrder.size(); while (tokenCount > clickedBreadcrumbLocation) { String lastItem = tokenJSPFileOrder.getLast(); if (log.isDebugEnabled()) { log.debug("Removing breacrumbItem : " + lastItem); } tokenJSPFileOrder.removeLast(); jspFileSubContextOrder.removeLast(); tokenCount = tokenJSPFileOrder.size(); } } boolean lastBreadcrumbItemAvailable = false; if (clickedBreadcrumbLocation == 0) { String tmp = getSubContextFromUri(currentBreadcrumbItem.getLink()) + "+" + currentBreadcrumbItem.getId(); if (!previousToken.equals(tmp)) { //To prevent page refresh lastBreadcrumbItemAvailable = true; } } if (tokenJSPFileOrder != null) { //found breadcrumb items for given sub context for (int i = 0; i < jspFileSubContextOrder.size(); i++) { String token = tokenJSPFileOrder.get(i); //String jspFileName = token.substring(token.indexOf('+')+1); //String jspSubContext = jspFileSubContextMap.get(jspFileName); String fileContextToken = jspFileSubContextOrder.get(i); String jspFileName = fileContextToken.substring(fileContextToken.indexOf('^') + 1); String jspSubContext = fileContextToken.substring(0, fileContextToken.indexOf('^')); if (jspSubContext != null) { breadcrumbItems = links.get("../" + jspSubContext); } if (breadcrumbItems != null) { int bcSize = breadcrumbItems.size(); for (int a = 0; a < bcSize; a++) { BreadCrumbItem tmp = breadcrumbItems.get(a); if (tmp.getId().equals(jspFileName)) { if (tmp.getLink().startsWith("#")) { content.append("<td class=\"breadcrumb-link\"> > " + tmp.getConvertedText() + "</td>"); } else { //if((a+1) == bcSize){ //if((a+1) == bcSize && clickedBreadcrumbLocation > 0){ if ((((a + 1) == bcSize) && !(lastBreadcrumbItemAvailable)) || removeLastItem) { content.append("<td class=\"breadcrumb-link\"> > " + tmp.getConvertedText() + "</td>"); } else { content.append("<td class=\"breadcrumb-link\"> > <a href=\"" + appendOrdinal(tmp.getLink(), i + 1) + "\">" + tmp.getConvertedText() + "</a></td>"); } } cookieContent.append(getSubContextFromUri(tmp.getLink()) + "+" + token + "*"); } } } } } //add last breadcrumb item if (lastBreadcrumbItemAvailable && !(removeLastItem)) { String tmp = getSubContextFromUri(currentBreadcrumbItem.getLink()) + "+" + currentBreadcrumbItem.getId(); cookieContent.append(tmp); cookieContent.append("*"); content.append("<td class=\"breadcrumb-link\"> > " + currentBreadcrumbItem.getConvertedText() + "</td>"); } content.append("</tr></table>"); } } breadcrumbContents.put("html-content", content.toString()); String finalCookieContent = cookieContent.toString(); if (removeLastItem && breadcrumbCookieString != null && breadcrumbCookieString.trim().length() > 0) { finalCookieContent = breadcrumbCookieString; } breadcrumbContents.put("cookie-content", finalCookieContent); return breadcrumbContents; }
From source file:org.openxdm.xcap.client.test.error.CannotDeleteTest.java
@Test public void test() throws HttpException, IOException, JAXBException, InterruptedException { // create uri UserDocumentUriKey key = new UserDocumentUriKey(appUsage.getAUID(), user, documentName); String content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<resource-lists xmlns=\"urn:ietf:params:xml:ns:resource-lists\">" + "<list name=\"friends\">" + "<entry uri=\"sip:alice@example.com\"/>" + //"<entry-ref ref=\"resource-lists/users/sip%3Ababel%40example.com/index/~~/resource-lists/list\"/>" + "<list name=\"enemies\"/>" + "<external anchor=\"http://localhost:8888/xcap-root/resource-lists/users/sip%3Abill%40example.com/index/~~/resource-lists/list\"/>" + "<entry-ref ref=\"resource-lists/users/sip%3Ababel%40example.com/index/~~/resource-lists/list\"/>" + "<cannot-delete name=\"fake\" xmlns=\"extension\"/>" + "<cannot-delete name=\"fake\" xmlns=\"extension\"/>" + //"<entry uri=\"sip:alice@example.com\"/>" + "</list>" + "</resource-lists>"; // send put request and get response Response response = client.put(key, appUsage.getMimetype(), content, null); // check put response assertTrue("Put response must exists", response != null); assertTrue("Put response code should be 201", response.getCode() == 201); // create element selector LinkedList<ElementSelectorStep> elementSelectorSteps = new LinkedList<ElementSelectorStep>(); ElementSelectorStep step1 = new ElementSelectorStep("resource-lists"); ElementSelectorStep step2 = new ElementSelectorStep("list"); elementSelectorSteps.add(step1);//from w ww. ja va 2 s.c o m elementSelectorSteps.addLast(step2); ElementSelector elementSelector = new ElementSelector(elementSelectorSteps); // create namespace bindings to be used in this test Map<String, String> nsBindings = new HashMap<String, String>(); nsBindings.put("pre", "extension"); // create exception for return codes CannotDeleteConflictException exception = new CannotDeleteConflictException(); // create elem uri ElementSelectorStep step3 = new ElementSelectorStepByPos("*", 5); elementSelectorSteps.addLast(step3); UserElementUriKey elementKey = new UserElementUriKey(appUsage.getAUID(), user, documentName, elementSelector, nsBindings); // send delete and get response Response deleteResponse = client.delete(elementKey, null); assertTrue("Delete response must exists", deleteResponse != null); assertTrue( "Delete response content must be the expected and the response code should be " + exception.getResponseStatus(), deleteResponse.getCode() == exception.getResponseStatus() && deleteResponse.getContent().equals(exception.getResponseContent())); // create elem uri step3 = new ElementSelectorStepByPos("pre:cannot-delete", 1); elementSelectorSteps.removeLast(); elementSelectorSteps.addLast(step3); elementKey = new UserElementUriKey(appUsage.getAUID(), user, documentName, elementSelector, nsBindings); // send delete request and get response deleteResponse = client.delete(elementKey, null); assertTrue("Delete response must exists", deleteResponse != null); assertTrue( "Delete response content must be the expected and the response code should be " + exception.getResponseStatus(), deleteResponse.getCode() == exception.getResponseStatus() && deleteResponse.getContent().equals(exception.getResponseContent())); //create elem uri step3 = new ElementSelectorStepByPosAttr("*", 5, "name", "fake"); elementSelectorSteps.removeLast(); elementSelectorSteps.addLast(step3); elementKey = new UserElementUriKey(appUsage.getAUID(), user, documentName, elementSelector, nsBindings); // send delete request and get response deleteResponse = client.delete(elementKey, null); assertTrue("Delete response must exists", deleteResponse != null); assertTrue( "Delete response content must be the expected and the response code should be " + exception.getResponseStatus(), deleteResponse.getCode() == exception.getResponseStatus() && deleteResponse.getContent().equals(exception.getResponseContent())); // send delete request and get response step3 = new ElementSelectorStepByPosAttr("pre:cannot-delete", 1, "name", "fake"); elementSelectorSteps.removeLast(); elementSelectorSteps.addLast(step3); elementKey = new UserElementUriKey(appUsage.getAUID(), user, documentName, elementSelector, nsBindings); deleteResponse = client.delete(elementKey, null); assertTrue("Delete response must exists", deleteResponse != null); assertTrue( "Delete response content must be the expected and the response code should be " + exception.getResponseStatus(), deleteResponse.getCode() == exception.getResponseStatus() && deleteResponse.getContent().equals(exception.getResponseContent())); // clean up client.delete(key, null); }
From source file:com.mirth.connect.plugins.dashboardstatus.DashboardConnectorEventListener.java
@Override protected void processEvent(Event event) { if (event instanceof ConnectionStatusEvent) { ConnectionStatusEvent connectionStatusEvent = (ConnectionStatusEvent) event; String channelId = connectionStatusEvent.getChannelId(); Integer metaDataId = connectionStatusEvent.getMetaDataId(); String information = connectionStatusEvent.getMessage(); Timestamp timestamp = new Timestamp(event.getDateTime()); String connectorId = channelId + "_" + metaDataId; ConnectionStatusEventType eventType = connectionStatusEvent.getState(); ConnectionStatusEventType connectionStatusEventType = eventType; Integer connectorCount = null; Integer maximum = null;/* w w w .j av a 2 s . c o m*/ if (event instanceof ConnectorCountEvent) { ConnectorCountEvent connectorCountEvent = (ConnectorCountEvent) connectionStatusEvent; maximum = connectorCountEvent.getMaximum(); Boolean increment = connectorCountEvent.isIncrement(); if (maximum != null) { maxConnectionMap.put(connectorId, maximum); } else { maximum = maxConnectionMap.get(connectorId); } AtomicInteger count = connectorCountMap.get(connectorId); if (count == null) { count = new AtomicInteger(); connectorCountMap.put(connectorId, count); } if (increment != null) { if (increment) { count.incrementAndGet(); } else { count.decrementAndGet(); } } connectorCount = count.get(); if (connectorCount == 0) { connectionStatusEventType = ConnectionStatusEventType.IDLE; } else { connectionStatusEventType = ConnectionStatusEventType.CONNECTED; } } String stateString = null; if (connectionStatusEventType.isState()) { Color color = getColor(connectionStatusEventType); stateString = connectionStatusEventType.toString(); if (connectorCount != null) { if (maximum != null && connectorCount.equals(maximum)) { stateString += " <font color='red'>(" + connectorCount + ")</font>"; } else if (connectorCount > 0) { stateString += " (" + connectorCount + ")"; } } connectorStateMap.put(connectorId, new Object[] { color, stateString }); } SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS"); String channelName = ""; String connectorType = ""; LinkedList<String[]> channelLog = null; Channel channel = ControllerFactory.getFactory().createChannelController() .getDeployedChannelById(channelId); if (channel != null) { channelName = channel.getName(); // grab the channel's log from the HashMap, if not exist, create // one. if (connectorInfoLogs.containsKey(channelId)) { channelLog = connectorInfoLogs.get(channelId); } else { channelLog = new LinkedList<String[]>(); } if (metaDataId == 0) { connectorType = "Source: " + channel.getSourceConnector().getTransportName() + " (" + channel.getSourceConnector().getTransformer().getInboundDataType().toString() + " -> " + channel.getSourceConnector().getTransformer().getOutboundDataType().toString() + ")"; } else { Connector connector = getConnectorFromMetaDataId(channel.getDestinationConnectors(), metaDataId); connectorType = "Destination: " + connector.getTransportName() + " - " + connector.getName(); } } if (channelLog != null) { synchronized (this) { if (channelLog.size() == MAX_LOG_SIZE) { channelLog.removeLast(); } channelLog.addFirst( new String[] { String.valueOf(logId), channelName, dateFormat.format(timestamp), connectorType, ((ConnectionStatusEvent) event).getState().toString(), information, channelId, Integer.toString(metaDataId) }); if (entireConnectorInfoLogs.size() == MAX_LOG_SIZE) { entireConnectorInfoLogs.removeLast(); } entireConnectorInfoLogs.addFirst( new String[] { String.valueOf(logId), channelName, dateFormat.format(timestamp), connectorType, ((ConnectionStatusEvent) event).getState().toString(), information, channelId, Integer.toString(metaDataId) }); logId++; // put the channel log into the HashMap. connectorInfoLogs.put(channelId, channelLog); } } } }
From source file:org.commonjava.maven.atlas.spi.jung.effective.JungEGraphDriver.java
private void dfsIterate(final ProjectVersionRef node, final ProjectNetTraversal traversal, final LinkedList<ProjectRelationship<?>> path, final int pass) { final List<ProjectRelationship<?>> edges = getSortedOutEdges(node); if (edges != null) { for (final ProjectRelationship<?> edge : edges) { if (traversal.traverseEdge(edge, path, pass)) { if (!(edge instanceof ParentRelationship) || !((ParentRelationship) edge).isTerminus()) { ProjectVersionRef target = edge.getTarget(); if (target instanceof ArtifactRef) { target = ((ArtifactRef) target).asProjectVersionRef(); }/* ww w . ja v a2 s .c om*/ // FIXME: Are there cases where a traversal needs to see cycles?? boolean cycle = false; for (final ProjectRelationship<?> item : path) { if (item.getDeclaring().equals(target)) { cycle = true; break; } } if (!cycle) { path.addLast(edge); dfsIterate(target, traversal, path, pass); path.removeLast(); } } traversal.edgeTraversed(edge, path, pass); } } } }