List of usage examples for java.util LinkedList getLast
public E getLast()
From source file:gov.nih.nci.ncicb.cadsr.ocbrowser.struts.actions.ObjectClassRelationshipAction.java
/** * * @param mapping The ActionMapping used to select this instance. * @param form The optional ActionForm bean for this request. * @param request The HTTP Request we are processing. * @param response The HTTP Response we are processing. * * @return/*from w ww . j a v a 2s. c o m*/ * * @throws IOException * @throws ServletException */ public ActionForward navigateOCR(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { DynaActionForm dynaForm = (DynaActionForm) form; String obcIdSeq = (String) dynaForm.get(OC_IDSEQ); String ocrIndex = (String) dynaForm.get(OCR_INDEX); String direction = (String) dynaForm.get(OCR_DIRECTION); Integer crumbsIndex = (Integer) dynaForm.get(OCR_BR_CRUMBS_INDEX); if (log.isDebugEnabled()) { log.info("ocr for With object class " + obcIdSeq); log.info("ocr index " + ocrIndex); log.info("direction " + direction); } try { //Get ocr navigation crumbs LinkedList crumbs = (LinkedList) getSessionObject(request, OCR_NAVIGATION_BEAN); if (crumbs == null) { crumbs = new LinkedList(); setSessionObject(request, OCR_NAVIGATION_BEAN, crumbs, true); } if (crumbs.isEmpty()) { OCRNavigationBean bean = new OCRNavigationBean(); ObjectClass currObjectClass = (ObjectClass) getSessionObject(request, OBJECT_CLASS); bean.setObjectClass(currObjectClass); crumbs.add(bean); } else { //Set the OCR_NAVIGATION_BEAN to current navigation path int currSize = crumbs.size(); int currIndex = crumbsIndex.intValue(); boolean nodesRemoved = false; for (int i = currIndex; i < currSize - 1; ++i) { crumbs.removeLast(); nodesRemoved = true; } if (nodesRemoved) { OCRNavigationBean newLastNavBean = (OCRNavigationBean) crumbs.getLast(); newLastNavBean.setOcr(null); newLastNavBean.setShowDirection(false); } } OCRNavigationBean lastNavBean = (OCRNavigationBean) crumbs.getLast(); //Make sure same object is not navigated // need review if (lastNavBean.getObjectClass().getId() != obcIdSeq) { //get the list of ocrs depending on the direction clicked List oldList = (List) getSessionObject(request, direction); ObjectClassRelationship navigatedOCR = (ObjectClassRelationship) oldList .get(Integer.parseInt(ocrIndex)); OCBrowserService service = this.getApplicationServiceLocator().findOCBrowserService(); ObjectClass objClass = service.getObjectClass(obcIdSeq); List ocrs = service.getAssociationsForOC(obcIdSeq); //Set the current OCRID dynaForm.set(CURR_OCR_IDSEQ, navigatedOCR.getId()); Map ocrMap = OCUtils.sortByOCRTypes(ocrs, obcIdSeq); setSessionObject(request, OBJECT_CLASS, objClass, true); setSessionObject(request, OUT_GOING_OCRS, ocrMap.get(OUT_GOING_OCRS), true); setSessionObject(request, IN_COMMING_OCRS, ocrMap.get(IN_COMMING_OCRS), true); setSessionObject(request, BIDIRECTIONAL_OCRS, ocrMap.get(BIDIRECTIONAL_OCRS), true); //Update old bean lastNavBean.setOcr(navigatedOCR); lastNavBean.setDirection(direction); lastNavBean.setShowDirection(true); //Add new link OCRNavigationBean bean = new OCRNavigationBean(); bean.setObjectClass(objClass); crumbs.add(bean); //set the crumbs index dynaForm.set(OCR_BR_CRUMBS_INDEX, new Integer(crumbs.size() - 1)); } } catch (ServiceLocatorException exp) { if (log.isErrorEnabled()) { log.error("Exception on getObjectClassRelationships obid= " + obcIdSeq); } return mapping.findForward(FAILURE); } return mapping.findForward(SUCCESS); }
From source file:se.trixon.pacoma.collage.Page.java
/** * * @return Representation of the page in ASCII art *//*from w w w . java 2 s. c o m*/ @Override public String toString() { /* Returns something like: [62 52] [125 134-- ------] [62 87] [62 47] [62 66] [125 132-- [62 45] [62 46] ------] [62 49] ------] [62 78] ------] [62 49] [62 45] [125 102-- ------] [62 49] [62 65] [125 135-- [62 85] [62 53] [125 91-- [125 89-- [62 64] ------] */ LinkedList<String> lines = new LinkedList<>(); int n = 0; boolean end = false; while (!end) { lines.add(""); end = true; for (Column col : mColumns) { String[] cells = col.toString().split("\\n"); int w = 0; for (String s : cells) { w = Math.max(w, s.length()); } if (col != mColumns.getLast()) { w += 1; } String cell = StringUtils.repeat(" ", w); if (n < cells.length) { cell = cells[n] + StringUtils.repeat(" ", w - cells[n].length()); if (n < cells.length - 1) { end = false; } } lines.set(lines.size() - 1, lines.getLast() + cell); } n++; } return String.join("\n", lines); }
From source file:org.eclipse.swordfish.core.configuration.xml.XmlToPropertiesTransformerImpl.java
public void loadConfiguration(URL path) { Assert.notNull(path);/* w w w . ja va 2s . 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:com.wolvereness.bluebutton.crash.ExceptionMessage.java
public Report(final String text) { final ArrayList<String> lines; { // _LINES_/*from w w w . j a v a2 s . co m*/ int i; if ((i = text.indexOf('\r')) != -1) { if (text.startsWith("\r\n", i)) { // StartsWith prevents OOB exception lines = Splitter.splitAll(text, "\r\n"); } else { lines = Splitter.splitAll(text, '\r'); } } else { lines = Splitter.splitAll(text, '\n'); } } // _LINES_ final ImmutableMap.Builder<Nodes, Node> nodes = ImmutableMap.builder(); final ListIterator<String> it = lines.listIterator(lines.size() - 1); { // _DETAILS_ int count = 0; // Number of lines with no "- " for sub-listing while (true) { String entry = it.previous(); if (entry.startsWith(START)) { if (entry.startsWith(WORLD, 2)) { continue; // Process this at end } final int colon = entry.indexOf(':'); Nodes type = Nodes.valueOf(entry.substring(2, colon).toUpperCase().replace(' ', '_')); if (type == null) { type = Nodes._NA; } final List<String> subList = lines.subList(it.nextIndex(), it.nextIndex() + count); final Node node = type.makeNode(entry.substring(colon + 1), subList); nodes.put(type, node); count = 0; // Reset count, as it is used for sub-listing } else if (entry.equals(DETAILS_START)) { { final ArrayList<String> worlds = new ArrayList<String>(); while (it.hasNext()) { entry = it.next(); if (entry.startsWith(WORLD_START)) { worlds.add(entry); } } nodes.put(Nodes.WORLD, Nodes.WORLD.makeNode(null, worlds)); } while (!it.previous().equals(DETAILS_START)) { } if (!it.previous().equals("")) // NOTE_0- blank line preceding details check, see NOTE_0- below throw new IllegalStateException("Expected blank line in " + lines.toString()); while (!it.previous().startsWith(DESCRIPTION_START)) { } it.next(); // Description_start it.next(); // Blank line break; // We're done in the loop } else { count++; } } } // _DETAILS_ { // _STACK_ final LinkedList<ExceptionMessage> exceptions = new LinkedList<ExceptionMessage>(); final List<StackTraceElement> stacks = new ArrayList<StackTraceElement>(); final List<String> description = new ArrayList<String>(); description.add(it.next()); // Initialize; first line is always first exception for (String entry = it.next(); !entry.equals(DETAILS_START); entry = it.next()) { // Read in all the exception information. // Apocalypse if the formating changes... if (entry.startsWith(STACK_START)) { // Normal stack element stacks.add(toStackTraceElement(entry)); } else if (entry.startsWith(STACK_MORE_START)) { // "... n more" final line final ExceptionMessage previous = exceptions.getLast(); final List<StackTraceElement> previousTrace = previous.getStackTrace(); entry = entry.substring(STACK_MORE_START.length(), entry.length() - STACK_MORE_END.length()); final int stackCount = Integer.valueOf(entry); stacks.addAll(previousTrace.subList(previousTrace.size() - stackCount, previousTrace.size())); exceptions.add(new ExceptionMessage(description, stacks)); // Reset our counters description.clear(); stacks.clear(); } else if (entry.startsWith(CAUSED_START)) { // Finish old exception if (description.size() != 0) { exceptions.add(new ExceptionMessage(description, stacks)); description.clear(); stacks.clear(); } // New exception description.add(entry.substring(CAUSED_START.length())); } else { // Random description information description.add(entry); } } description.remove(description.size() - 1); // NOTE_0- There will be a blank line here, see NOTE_0- above if (description.size() != 0) { exceptions.add(new ExceptionMessage(description, stacks)); } this.exceptions = ImmutableList.copyOf(exceptions); } // _STACK_ while (!it.previous().startsWith(DESCRIPTION_START)) { } // This puts us on the line before the "description:" it.next(); // Push iterator for description_start to hit twice this.description = it.previous().substring(DESCRIPTION_START.length()); { // _TIMESTAMP_ final String timeStamp = it.previous().substring(TIME_START.length()); Date time = null; try { time = (Date) DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.parseObject(timeStamp); } catch (final ParseException ex) { try { time = new SimpleDateFormat().parse(timeStamp); } catch (final ParseException e) { } } this.time = time == null ? new Date(0l) : time; } // _TIMESTAMP_ it.previous(); // Blank line after joke this.fun = it.previous(); this.nodes = nodes.build(); }
From source file:jext2.DataBlockAccess.java
/** * Splice the allocated branch onto inode * @throws IOException/*from ww w . j a v a 2 s. co m*/ */ @NotThreadSafe(useLock = true) private void spliceBranch(long logicalBlock, int[] offsets, long[] blockNrs, LinkedList<Long> newBlockNrs) throws IoError { int existDepth = blockNrs.length; if (existDepth == 0) { /* add direct block */ long[] directBlocks = inode.getBlock(); directBlocks[offsets[0]] = newBlockNrs.getFirst().longValue(); } else { ByteBuffer buf = blocks.read(blockNrs[existDepth - 1]); Ext2fsDataTypes.putLE32U(buf, newBlockNrs.getFirst().longValue(), offsets[existDepth] * 4); buf.rewind(); blocks.write(blockNrs[existDepth - 1], buf); } lastAllocLogicalBlock = logicalBlock; lastAllocPhysicalBlock = newBlockNrs.getLast().intValue(); inode.setBlocks(inode.getBlocks() + newBlockNrs.size() * (superblock.getBlocksize() / 512)); inode.setModificationTime(new Date()); }
From source file:lv.semti.morphology.webservice.VerbResource.java
private String tagChunk(LinkedList<Word> tokens) { LinkedHashSet<String> tags = new LinkedHashSet<String>(); // da?di minjumi. norm?li bu tikai ar sintakses analzi //tags.add(String.valueOf(tokens.size())); //tags.add(tokens.get(0).getToken()); //tags.add(tokens.get(0).getPartOfSpeech()); if (tokens.size() > 1 && tokens.get(0).isRecognized() && tokens.get(0).hasAttribute(AttributeNames.i_PartOfSpeech, AttributeNames.v_Preposition)) { // ja fr?ze s?kas ar priev?rdu for (Wordform wf : tokens.get(0).wordforms) { //tags.add(wf.getDescription()); if (wf.isMatchingStrong(AttributeNames.i_PartOfSpeech, AttributeNames.v_Preposition)) { String ncase = wf.getValue(AttributeNames.i_Rekcija); if (ncase != null) tags.add(wf.getToken() + caseCode(ncase)); }// w w w.j av a 2 s.c o m } } //ja s?kas ar saikli, tad vareetu buut paliigteikums if (tokens.size() > 1 && tokens.get(0).isRecognized() && tokens.get(0).hasAttribute(AttributeNames.i_PartOfSpeech, AttributeNames.v_Conjunction)) { tags.add("S"); } if (tags.isEmpty()) return tagWord(tokens.getLast(), false); // Ja nesaprat?m, dodam pdj? v?rda analzi - Gunta teica, ka esot ticam?k t? return formatJSON(tags); }
From source file:org.mycore.common.content.transformer.MCRXSLTransformer.java
protected LinkedList<TransformerHandler> getTransformHandlerList(MCRParameterCollector parameterCollector) throws TransformerConfigurationException, SAXException { checkTemplateUptodate();/* w w w . j a v a 2s . c om*/ LinkedList<TransformerHandler> xslSteps = new LinkedList<TransformerHandler>(); //every transformhandler shares the same ErrorListener instance MCRErrorListener errorListener = MCRErrorListener.getInstance(); for (Templates template : templates) { TransformerHandler handler = tFactory.newTransformerHandler(template); parameterCollector.setParametersTo(handler.getTransformer()); handler.getTransformer().setErrorListener(errorListener); if (TRACE_LISTENER_ENABLED) { TransformerImpl transformer = (TransformerImpl) handler.getTransformer(); TraceManager traceManager = transformer.getTraceManager(); try { traceManager.addTraceListener(TRACE_LISTENER); } catch (TooManyListenersException e) { LOGGER.warn("Could not add MCRTraceListener.", e); } } if (!xslSteps.isEmpty()) { Result result = new SAXResult(handler); xslSteps.getLast().setResult(result); } xslSteps.add(handler); } return xslSteps; }
From source file:rn.beleg.protocol.Protocol.java
/** * Decode a received byte[] and creates an reply * * @param received the received byte[]/*from w w w. j ava 2 s . c o m*/ * * @return the reply */ public byte[] decode(byte[] received) { byte[] session = this.receivedToSession(received); LinkedList<DataPackage> list; ReceivePackage receivePackage; output.info("Getting package with length " + received.length); output.info(String.format("Session %s", ByteUtilities.byteToHex(session))); // Create lists with data packages if (this.firstPackagesContainsKey(session)) { FirstPackage firstPackage = getFirstPackage(session); if (firstPackages == null) { clean(session); output.error("No first package found for this session."); return new byte[0]; } if (this.dataPackagesContainsKey(session)) { list = getDataPackages(session); } else { list = new LinkedList<DataPackage>(); dataPackages.put(session, list); } DataPackage dataPackage; boolean isLast = false; int total = 0; for (DataPackage dp : list) { total += dp.getData().length; } if (list.size() > 0) { DataPackage lastPackage = list.getLast(); // its the last package? If true, calc crc isLast = firstPackage.getFileLength() <= total + received.length - 3; // sessionid + packageid = 3 byte dataPackage = new DataPackage(received, isLast); if (lastPackage.getPackageId() == dataPackage.getPackageId()) { output.error( String.format("Getting two packages with id %s in a row", lastPackage.getPackageId())); return new byte[0]; } } else { dataPackage = new DataPackage(received); } total += dataPackage.getData().length; output.info(String.format("Total received %s of %s", total, firstPackage.getFileLength())); output.info(String.format("Data part size %s", dataPackage.getData().length)); list.add(dataPackage); if (isLast) { output.info("Last package, try to create file"); byte[] fileData = new byte[0]; for (DataPackage p : list) { fileData = ByteUtilities.appendByteArrays(fileData, p.getData()); } // check CRC, if (!Arrays.equals(CRC32.calc(fileData), list.getLast().getCrc())) { clean(session); output.error("CRC does not match"); return new byte[0]; } output.info("CRC ok"); try { String fileName = firstPackage.getFileName(); File file = new File(fileName); String extension = FilenameUtils.getExtension(fileName); String baseName = FilenameUtils.getBaseName(fileName); int i = 1; while (file.exists() && !file.isDirectory()) { file = new File(baseName + i + "." + extension); i++; } FileOutputStream fileOutputStream = new FileOutputStream(file); fileOutputStream.write(fileData); fileOutputStream.close(); this.clean(session); output.success("Write file to: " + file.getAbsolutePath()); } catch (Exception e) { output.error(e.getMessage()); System.exit(2); } } receivePackage = new ReceivePackage(session, ByteUtilities.intToByte(dataPackage.getPackageId())); } else { output.info("New session."); try { FirstPackage firstPackage = new FirstPackage(received); output.info("Received start package"); output.info(String.format("Session %s", Integer.toHexString(ByteUtilities.byteArrayToInt(firstPackage.getSessionId())))); output.info(String.format("FileNameLength %s", firstPackage.getFileNameLength())); output.info(String.format("Filename %s", firstPackage.getFileName())); output.info(String.format("FileLength %s", firstPackage.getFileLength())); firstPackages.put(session, firstPackage); // First package -> new session -> no other handling required receivePackage = new ReceivePackage(session, ByteUtilities.intToByte(firstPackage.getPackageId())); } catch (NoStartPackageException e) { output.error("Not a start package"); return new byte[0]; } } return receivePackage.serialize(); }
From source file:org.wso2.carbon.ui.BreadCrumbGenerator.java
/** * Generates breadcrumb html content./*from www . j av a2 s .c o m*/ * 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.eclipse.wb.internal.core.xml.model.description.ComponentDescriptionHelper.java
private static ComponentDescription getDescriptionEx(EditorContext context, Class<?> componentClass) throws Exception { ComponentDescription componentDescription = new ComponentDescription(componentClass); // prepare description resources, from generic to specific LinkedList<ClassResourceInfo> descriptionInfos; {/*from www . jav a 2 s . co m*/ descriptionInfos = Lists.newLinkedList(); DescriptionHelper.addDescriptionResources(descriptionInfos, context.getLoadingContext(), componentClass); Assert.isTrueException(!descriptionInfos.isEmpty(), IExceptionConstants.DESCRIPTION_NO_DESCRIPTIONS, componentClass.getName()); } // prepare Digester Digester digester; { digester = new Digester(); digester.setLogger(new NoOpLog()); addRules(digester, context, componentClass); } // read descriptions from generic to specific for (ClassResourceInfo descriptionInfo : descriptionInfos) { ResourceInfo resourceInfo = descriptionInfo.resource; // read next description { //componentDescription.setCurrentClass(descriptionInfo.clazz); digester.push(componentDescription); // do parse InputStream is = resourceInfo.getURL().openStream(); try { digester.parse(is); } finally { IOUtils.closeQuietly(is); } } // clear parts that can not be inherited if (descriptionInfo.clazz == componentClass) { setDescriptionWithInnerTags(componentDescription, resourceInfo); } else { componentDescription.clearCreations(); componentDescription.setDescription(null); } } // set toolkit if (componentDescription.getToolkit() == null) { for (int i = descriptionInfos.size() - 1; i >= 0; i--) { ClassResourceInfo descriptionInfo = descriptionInfos.get(i); ToolkitDescription toolkit = descriptionInfo.resource.getToolkit(); if (toolkit != null) { componentDescription.setToolkit(toolkit); break; } } } // mark for caching presentation if (shouldCachePresentation(descriptionInfos.getLast(), componentClass)) { componentDescription.setPresentationCached(true); } // final operations setIcon(context, componentDescription, componentClass); useDescriptionProcessors(context, componentDescription); componentDescription.postProcess(); // done return componentDescription; }