| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <!-- Generated by Apache Maven Doxia Site Renderer 1.8.1 from org.apache.maven.plugins:maven-pmd-plugin:3.15.0:cpd at 2022-09-06 --> |
| <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| <title>Apache Chainsaw – CPD Results</title> |
| <style type="text/css" media="all"> |
| @import url("./css/maven-base.css"); |
| @import url("./css/maven-theme.css"); |
| @import url("./css/site.css"); |
| </style> |
| <link rel="stylesheet" href="./css/print.css" type="text/css" media="print" /> |
| <meta http-equiv="Content-Language" content="en" /> |
| |
| </head> |
| <body class="composite"> |
| <div id="banner"> |
| <a href="http://logging.apache.org/" id="bannerLeft"><img src="images/ls-logo.jpg" alt="Logging Services"/></a> |
| <a href="http://logging.apache.org/log4j" id="bannerRight"><img src="images/logo.jpg" alt="Apache log4j"/></a> |
| <div class="clear"> |
| <hr/> |
| </div> |
| </div> |
| <div id="breadcrumbs"> |
| <div class="xleft"> |
| <span id="publishDate">Last Published: 2022-09-06</span> |
| | <span id="projectVersion">Version: 2.1.0</span> |
| | <a href="http://www.apache.org/" class="externalLink" title="Apache">Apache</a> > |
| <a href="http://logging.apache.org/" class="externalLink" title="Logging Services">Logging Services</a> > |
| <a href="http://logging.apache.org:80/chainsaw/" class="externalLink" title="Chainsaw">Chainsaw</a> > |
| CPD Results |
| </div> |
| <div class="xright"> </div> |
| <div class="clear"> |
| <hr/> |
| </div> |
| </div> |
| <div id="leftColumn"> |
| <div id="navcolumn"> |
| <h5>Get Chainsaw</h5> |
| <ul> |
| <li class="none"><a href="download.html" title="Download">Download</a></li> |
| <li class="none"><a href="changes-report.html" title="Changes">Changes</a></li> |
| <li class="none"><a href="https://www.apache.org/licenses/LICENSE-2.0" class="externalLink" title="License">License</a></li> |
| <li class="none"><a href="distributionnotes.html" title="Important Distribution Notes">Important Distribution Notes</a></li> |
| </ul> |
| <h5>About Chainsaw</h5> |
| <ul> |
| <li class="none"><a href="index.html" title="Introduction">Introduction</a></li> |
| <li class="none"><a href="quicktour.html" title="Quick Tour">Quick Tour</a></li> |
| <li class="none"><a href="zeroconf.html" title="Zeroconf">Zeroconf</a></li> |
| <li class="none"><a href="roadmap.html" title="Roadmap">Roadmap</a></li> |
| <li class="none"><a href="apidocs/index.html" title="JavaDoc">JavaDoc</a></li> |
| </ul> |
| <h5>Community</h5> |
| <ul> |
| <li class="none"><a href="mail-lists.html" title="Mailing Lists">Mailing Lists</a></li> |
| <li class="none"><a href="issue-tracking.html" title="Issue Tracking">Issue Tracking</a></li> |
| </ul> |
| <h5>Development</h5> |
| <ul> |
| <li class="none"><a href="source-repository.html" title="Repository">Repository</a></li> |
| <li class="none"><a href="xref/index.html" title="Cross Reference">Cross Reference</a></li> |
| <li class="none"><a href="dependencies.html" title="Dependencies">Dependencies</a></li> |
| <li class="none"><strong>Duplication</strong></li> |
| <li class="none"><a href="pmd.html" title="PMD">PMD</a></li> |
| </ul> |
| <h5>Apache</h5> |
| <ul> |
| <li class="none"><a href="http://www.apache.org" class="externalLink" title="Home">Home</a></li> |
| <li class="none"><a href="http://www.apache.org/foundation/sponsorship.html" class="externalLink" title="Sponsorship">Sponsorship</a></li> |
| <li class="none"><a href="http://www.apache.org/foundation/thanks.html" class="externalLink" title="Thanks">Thanks</a></li> |
| <li class="none"><a href="https://www.apache.org/security/" class="externalLink" title="Security">Security</a></li> |
| <li class="none"><a href="http://www.apachecon.com" class="externalLink" title="Conferences">Conferences</a></li> |
| </ul> |
| <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy"> |
| <img class="poweredBy" alt="Built by Maven" src="./images/logos/maven-feather.png" /> |
| </a> |
| </div> |
| </div> |
| <div id="bodyColumn"> |
| <div id="contentBox"> |
| <div class="section"> |
| <h2><a name="CPD_Results"></a>CPD Results</h2> |
| <p>The following document contains the results of PMD's <a class="externalLink" href="https://pmd.github.io/latest/pmd_userdocs_cpd.html">CPD</a> 6.38.0.</p></div> |
| <div class="section"> |
| <h2><a name="Duplications"></a>Duplications</h2> |
| <table border="0" class="bodyTable"> |
| <tr class="a"> |
| <th>File</th> |
| <th>Line</th></tr> |
| <tr class="b"> |
| <td>org/apache/log4j/xml/UtilLoggingXMLDecoder.java</td> |
| <td><a href="./xref/org/apache/log4j/xml/UtilLoggingXMLDecoder.html#L160">160</a></td></tr> |
| <tr class="a"> |
| <td>org/apache/log4j/xml/XMLDecoder.java</td> |
| <td><a href="./xref/org/apache/log4j/xml/XMLDecoder.html#L162">162</a></td></tr> |
| <tr class="b"><td colspan='2'> |
| <div> |
| <pre>new InputSource(new StringReader(buf.toString())); |
| document = docBuilder.parse(inputSource); |
| } catch (Exception e) { |
| e.printStackTrace(); |
| } |
| |
| return document; |
| } |
| |
| /** |
| * Decodes a File into a Vector of LoggingEvents. |
| * |
| * @param url the url of a file containing events to decode |
| * @return Vector of LoggingEvents |
| * @throws IOException if IO error during processing. |
| */ |
| public Vector<LoggingEvent> decode(final URL url) throws IOException { |
| LineNumberReader reader; |
| boolean isZipFile = url.getPath().toLowerCase().endsWith(".zip"); |
| InputStream inputStream; |
| if (isZipFile) { |
| inputStream = new ZipInputStream(url.openStream()); |
| //move stream to next entry so we can read it |
| ((ZipInputStream) inputStream).getNextEntry(); |
| } else { |
| inputStream = url.openStream(); |
| } |
| if (owner != null) { |
| reader = new LineNumberReader( |
| new InputStreamReader( |
| new ProgressMonitorInputStream(owner, |
| "Loading " + url, inputStream), ENCODING)); |
| } else { |
| reader = new LineNumberReader(new InputStreamReader(inputStream, ENCODING)); |
| } |
| Vector<LoggingEvent> v = new Vector<>(); |
| |
| String line; |
| Vector<LoggingEvent> events; |
| try { |
| while ((line = reader.readLine()) != null) { |
| StringBuilder buffer = new StringBuilder(line); |
| for (int i = 0; i < 1000; i++) { |
| buffer.append(reader.readLine()).append("\n"); |
| } |
| events = decodeEvents(buffer.toString()); |
| if (events != null) { |
| v.addAll(events); |
| } |
| } |
| } finally { |
| partialEvent = null; |
| try { |
| if (reader != null) { |
| reader.close(); |
| } |
| } catch (Exception e) { |
| e.printStackTrace(); |
| } |
| } |
| return v; |
| } |
| |
| /** |
| * Decodes a String representing a number of events into a |
| * Vector of LoggingEvents. |
| * |
| * @param document to decode events from |
| * @return Vector of LoggingEvents |
| */ |
| public Vector<LoggingEvent> decodeEvents(final String document) { |
| |
| if (document != null) { |
| |
| if (document.trim().equals("")) { |
| return null; |
| } |
| |
| String newDoc; |
| String newPartialEvent = null; |
| //separate the string into the last portion ending with </record> |
| // (which will be processed) and the partial event which |
| // will be combined and processed in the next section |
| |
| //if the document does not contain a record end, |
| // append it to the partial event string |
| if (document.lastIndexOf(RECORD_END) == -1) { |
| partialEvent = partialEvent + document; |
| return null; |
| } |
| |
| if (document.lastIndexOf(RECORD_END) + RECORD_END.length() |
| < document.length()) { |
| newDoc = document.substring(0, |
| document.lastIndexOf(RECORD_END) + RECORD_END.length()); |
| newPartialEvent = document.substring( |
| document.lastIndexOf(RECORD_END) + RECORD_END.length()); |
| } else { |
| newDoc = document; |
| } |
| if (partialEvent != null) { |
| newDoc = partialEvent + newDoc; |
| } |
| partialEvent = newPartialEvent; |
| |
| Document doc = parse(newDoc); |
| if (doc == null) { |
| return null; |
| } |
| return decodeEvents(doc); |
| } |
| return null; |
| } |
| |
| /** |
| * Converts the string data into an XML Document, and then soaks out the |
| * relevant bits to form a new LoggingEvent instance which can be used |
| * by any Log4j element locally. |
| * |
| * @param data XML fragment |
| * @return a single LoggingEvent or null |
| */ |
| public LoggingEvent decode(final String data) { |
| Document document = parse(data); |
| |
| if (document == null) { |
| return null; |
| } |
| |
| Vector<LoggingEvent> events = decodeEvents(document); |
| |
| if (events.size() > 0) { |
| return events.firstElement(); |
| } |
| |
| return null; |
| } |
| |
| /** |
| * Given a Document, converts the XML into a Vector of LoggingEvents. |
| * |
| * @param document XML document |
| * @return Vector of LoggingEvents |
| */ |
| private Vector<LoggingEvent> decodeEvents(final Document document) { |
| Vector<LoggingEvent> events = new Vector<>();</pre></div></td></tr></table> |
| <table border="0" class="bodyTable"> |
| <tr class="a"> |
| <th>File</th> |
| <th>Line</th></tr> |
| <tr class="b"> |
| <td>org/apache/log4j/chainsaw/icons/LineIconFactory.java</td> |
| <td><a href="./xref/org/apache/log4j/chainsaw/icons/LineIconFactory.html#L44">44</a></td></tr> |
| <tr class="a"> |
| <td>org/apache/log4j/chainsaw/icons/LineIconFactory.java</td> |
| <td><a href="./xref/org/apache/log4j/chainsaw/icons/LineIconFactory.html#L77">77</a></td></tr> |
| <tr class="b"><td colspan='2'> |
| <div> |
| <pre>public static Icon createExpandIcon() { |
| int size = 8; |
| int xOffSet = 0; |
| int yOffSet = 0; |
| try { |
| GraphicsEnvironment environment = |
| GraphicsEnvironment.getLocalGraphicsEnvironment(); |
| BufferedImage image = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB); |
| Graphics2D g2D = |
| environment.createGraphics( |
| image); |
| g2D.setBackground(new Color(0, 0, 0, 0)); |
| g2D.clearRect(0, 0, size, size); |
| g2D.setStroke(new BasicStroke(1.5f)); |
| g2D.setRenderingHint( |
| RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); |
| g2D.setColor(Color.black); |
| g2D.drawLine( |
| xOffSet, (size / 2) + yOffSet, size - xOffSet, |
| (size / 2) + yOffSet);</pre></div></td></tr></table> |
| <table border="0" class="bodyTable"> |
| <tr class="a"> |
| <th>File</th> |
| <th>Line</th></tr> |
| <tr class="b"> |
| <td>org/apache/log4j/net/MulticastAppender.java</td> |
| <td><a href="./xref/org/apache/log4j/net/MulticastAppender.html#L84">84</a></td></tr> |
| <tr class="a"> |
| <td>org/apache/log4j/net/UDPAppender.java</td> |
| <td><a href="./xref/org/apache/log4j/net/UDPAppender.html#L104">104</a></td></tr> |
| <tr class="b"><td colspan='2'> |
| <div> |
| <pre>super(false); |
| } |
| |
| /** |
| * Open the multicast sender for the <b>RemoteHost</b> and <b>Port</b>. |
| */ |
| public void activateOptions() { |
| try { |
| hostname = InetAddress.getLocalHost().getHostName(); |
| } catch (UnknownHostException uhe) { |
| try { |
| hostname = InetAddress.getLocalHost().getHostAddress(); |
| } catch (UnknownHostException uhe2) { |
| hostname = "unknown"; |
| } |
| } |
| |
| //allow system property of application to be primary |
| if (application == null) { |
| application = System.getProperty(Constants.APPLICATION_KEY); |
| } else { |
| if (System.getProperty(Constants.APPLICATION_KEY) != null) { |
| application = application + "-" + System.getProperty(Constants.APPLICATION_KEY); |
| } |
| } |
| |
| if (remoteHost != null) { |
| address = getAddressByName(remoteHost);</pre></div></td></tr></table> |
| <table border="0" class="bodyTable"> |
| <tr class="a"> |
| <th>File</th> |
| <th>Line</th></tr> |
| <tr class="b"> |
| <td>org/apache/log4j/xml/XMLDecoder.java</td> |
| <td><a href="./xref/org/apache/log4j/xml/XMLDecoder.html#L357">357</a></td></tr> |
| <tr class="a"> |
| <td>org/apache/log4j/xml/XMLDecoder.java</td> |
| <td><a href="./xref/org/apache/log4j/xml/XMLDecoder.html#L397">397</a></td></tr> |
| <tr class="b"><td colspan='2'> |
| <div> |
| <pre>NodeList propertyList = list.item(y).getChildNodes(); |
| int propertyLength = propertyList.getLength(); |
| |
| for (int i = 0; i < propertyLength; i++) { |
| String propertyTag = propertyList.item(i).getNodeName(); |
| |
| if (propertyTag.equalsIgnoreCase("log4j:data")) { |
| Node property = propertyList.item(i); |
| String name = |
| property.getAttributes().getNamedItem("name").getNodeValue(); |
| String value = |
| property.getAttributes().getNamedItem("value").getNodeValue(); |
| properties.put(name, value); |
| } |
| } |
| } |
| |
| if (tagName.equalsIgnoreCase("log4j:throwable")) {</pre></div></td></tr></table> |
| <table border="0" class="bodyTable"> |
| <tr class="a"> |
| <th>File</th> |
| <th>Line</th></tr> |
| <tr class="b"> |
| <td>org/apache/log4j/chainsaw/LogPanel.java</td> |
| <td><a href="./xref/org/apache/log4j/chainsaw/LogPanel.html#L3857">3857</a></td></tr> |
| <tr class="a"> |
| <td>org/apache/log4j/chainsaw/LogPanel.java</td> |
| <td><a href="./xref/org/apache/log4j/chainsaw/LogPanel.html#L3877">3877</a></td></tr> |
| <tr class="b"><td colspan='2'> |
| <div> |
| <pre>} else if (e.getType() == TableModelEvent.DELETE) { |
| //find each eventwrapper with an id in the deleted range and remove it... |
| // System.out.println("delete- current warnings: " + warnings.size() + ", errors: " + errors.size() + ", first row: " + firstRow + ", last row: " + lastRow + ", displayed event count: " + displayedEvents.size() ); |
| for (Iterator<ThumbnailLoggingEventWrapper> iter = secondaryList.iterator(); iter.hasNext(); ) { |
| ThumbnailLoggingEventWrapper wrapper = iter.next(); |
| if ((wrapper.rowNum >= firstRow) && (wrapper.rowNum <= lastRow)) { |
| // System.out.println("deleting find: " + wrapper); |
| iter.remove(); |
| } |
| } |
| for (Iterator<ThumbnailLoggingEventWrapper> iter = primaryList.iterator(); iter.hasNext(); ) { |
| ThumbnailLoggingEventWrapper wrapper = iter.next(); |
| if ((wrapper.rowNum >= firstRow) && (wrapper.rowNum <= lastRow)) { |
| // System.out.println("deleting error: " + wrapper); |
| iter.remove(); |
| } |
| }</pre></div></td></tr></table> |
| <table border="0" class="bodyTable"> |
| <tr class="a"> |
| <th>File</th> |
| <th>Line</th></tr> |
| <tr class="b"> |
| <td>org/apache/log4j/xml/UtilLoggingXMLDecoder.java</td> |
| <td><a href="./xref/org/apache/log4j/xml/UtilLoggingXMLDecoder.html#L410">410</a></td></tr> |
| <tr class="a"> |
| <td>org/apache/log4j/xml/XMLDecoder.java</td> |
| <td><a href="./xref/org/apache/log4j/xml/XMLDecoder.html#L426">426</a></td></tr> |
| <tr class="b"><td colspan='2'> |
| <div> |
| <pre>} |
| } |
| |
| LocationInfo info; |
| if ((fileName != null) |
| || (className != null) |
| || (methodName != null) |
| || (lineNumber != null)) { |
| info = new LocationInfo(fileName, className, methodName, lineNumber); |
| } else { |
| info = LocationInfo.NA_LOCATION_INFO; |
| } |
| |
| ThrowableInformation throwableInfo = null; |
| if (exception != null) { |
| throwableInfo = new ThrowableInformation(exception); |
| } |
| |
| LoggingEvent loggingEvent = new LoggingEvent(null, |
| logger, timeStamp, level, message, |
| threadName, |
| throwableInfo, |
| ndc, |
| info, |
| properties); |
| |
| events.add(loggingEvent);</pre></div></td></tr></table> |
| <table border="0" class="bodyTable"> |
| <tr class="a"> |
| <th>File</th> |
| <th>Line</th></tr> |
| <tr class="b"> |
| <td>org/apache/log4j/chainsaw/LogPanel.java</td> |
| <td><a href="./xref/org/apache/log4j/chainsaw/LogPanel.html#L3634">3634</a></td></tr> |
| <tr class="a"> |
| <td>org/apache/log4j/chainsaw/LogPanel.java</td> |
| <td><a href="./xref/org/apache/log4j/chainsaw/LogPanel.html#L3710">3710</a></td></tr> |
| <tr class="b"><td colspan='2'> |
| <div> |
| <pre>i++; |
| //only add if there is a color defined |
| if (primaryMatches(wrapper)) { |
| primaryList.add(wrapper); |
| } |
| } |
| revalidate(); |
| repaint(); |
| } |
| |
| public void paintComponent(Graphics g) { |
| super.paintComponent(g); |
| |
| int rowCount = table.getRowCount(); |
| if (rowCount == 0) { |
| return; |
| } |
| //use event pane height as reference height - max component height will be extended by event height if |
| // last row is rendered, so subtract here |
| int height = eventsPane.getHeight(); |
| int maxHeight = Math.min(maxEventHeight, (height / rowCount)); |
| int minHeight = Math.max(1, maxHeight); |
| int componentHeight = height - minHeight; |
| int eventHeight = minHeight; |
| |
| //draw all events |
| for (Object aPrimaryList : primaryList) {</pre></div></td></tr></table> |
| <table border="0" class="bodyTable"> |
| <tr class="a"> |
| <th>File</th> |
| <th>Line</th></tr> |
| <tr class="b"> |
| <td>org/apache/log4j/xml/UtilLoggingXMLDecoder.java</td> |
| <td><a href="./xref/org/apache/log4j/xml/UtilLoggingXMLDecoder.html#L438">438</a></td></tr> |
| <tr class="a"> |
| <td>org/apache/log4j/xml/XMLDecoder.java</td> |
| <td><a href="./xref/org/apache/log4j/xml/XMLDecoder.html#L462">462</a></td></tr> |
| <tr class="b"><td colspan='2'> |
| <div> |
| <pre>} |
| return events; |
| } |
| |
| /** |
| * Get contents of CDATASection. |
| * |
| * @param n CDATASection |
| * @return text content of all text or CDATA children of node. |
| */ |
| private String getCData(final Node n) { |
| StringBuilder buf = new StringBuilder(); |
| NodeList nl = n.getChildNodes(); |
| |
| for (int x = 0; x < nl.getLength(); x++) { |
| Node innerNode = nl.item(x); |
| |
| if ( |
| (innerNode.getNodeType() == Node.TEXT_NODE) |
| || (innerNode.getNodeType() == Node.CDATA_SECTION_NODE)) { |
| buf.append(innerNode.getNodeValue()); |
| } |
| } |
| |
| return buf.toString(); |
| } |
| }</pre></div></td></tr></table></div> |
| </div> |
| </div> |
| <div class="clear"> |
| <hr/> |
| </div> |
| <div id="footer"> |
| <div class="xright"> |
| Copyright © 2002–2022 <a href="https://www.apache.org/">The Apache Software Foundation</a>. |
| All rights reserved. </div> |
| <div class="clear"> |
| <hr/> |
| </div> |
| </div> |
| </body> |
| </html> |