Java Doc for ReferenceManager.java in  » Wiki-Engine » JSPWiki » com » ecyrd » jspwiki » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Wiki Engine » JSPWiki » com.ecyrd.jspwiki 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.ecyrd.jspwiki.filters.BasicPageFilter
      com.ecyrd.jspwiki.ReferenceManager

ReferenceManager
public class ReferenceManager extends BasicPageFilter implements InternalModule,WikiEventListener(Code)
Keeps track of wikipage references:
  • What pages a given page refers to
  • What pages refer to a given page
This is a quick'n'dirty approach without any finesse in storage and searching algorithms; we trust java.util.*.

This class contains two HashMaps, m_refersTo and m_referredBy. The first is indexed by WikiPage names and contains a Collection of all WikiPages the page refers to. (Multiple references are not counted, naturally.) The second is indexed by WikiPage names and contains a Set of all pages that refer to the indexing page. (Notice - the keys of both Maps should be kept in sync.)

When a page is added or edited, its references are parsed, a Collection is received, and we crudely replace anything previous with this new Collection. We then check each referenced page name and make sure they know they are referred to by the new page.

Based on this information, we can perform non-optimal searches for e.g. unreferenced pages, top ten lists, etc.

The owning class must take responsibility of filling in any pre-existing information, probably by loading each and every WikiPage and calling this class to update the references when created.
author:
   ebu@memecry.net
since:
   1.6.1




Constructor Summary
public  ReferenceManager(WikiEngine engine)
     Builds a new ReferenceManager.

Method Summary
public  voidactionPerformed(WikiEvent event)
    
public synchronized  voidclearPageEntries(String pagename)
     Clears the references to a certain page so it's no longer in the map.
public  intdeepHashCode()
     This 'deepHashCode' can be used to determine if there were any modifications made to the underlying to and by maps of the ReferenceManager.
public  SetfindCreated()
     Returns a list of all pages that the ReferenceManager knows about. This should be roughly equivalent to PageManager.getAllPages(), but without the potential disk access overhead.
public  SetfindReferredBy(String pageName)
     Returns all pages that refer to this page.
public synchronized  CollectionfindReferrers(String pagename)
     Find all pages that refer to this page.
public  CollectionfindRefersTo(String pageName)
     Returns all pages that this page refers to.
public synchronized  CollectionfindUncreated()
     Finds all references to non-existant pages.
public synchronized  CollectionfindUnreferenced()
     Finds all unreferenced pages.
protected  MapgetReferredBy()
     Returns the referred-by list.
protected  MapgetRefersTo()
     Returns the refers-to list.
public  voidinitialize(Collection pages)
     Initializes the entire reference manager with the initial set of pages from the collection.
public synchronized  voidpageRemoved(WikiPage page)
     Updates the m_referedTo and m_referredBy hashmaps when a page has been deleted.

Within the m_refersTo map the pagename is a key.

public  voidpostSave(WikiContext context, String content)
     After the page has been saved, updates the reference lists.
public synchronized  voidupdateReferences(String page, Collection references)
     Updates the referred pages of a new or edited WikiPage.


Constructor Detail
ReferenceManager
public ReferenceManager(WikiEngine engine)(Code)
Builds a new ReferenceManager.
Parameters:
  engine - The WikiEngine to which this is managing references to.




Method Detail
actionPerformed
public void actionPerformed(WikiEvent event)(Code)



clearPageEntries
public synchronized void clearPageEntries(String pagename)(Code)
Clears the references to a certain page so it's no longer in the map.
Parameters:
  pagename - Name of the page to clear references for.



deepHashCode
public int deepHashCode()(Code)
This 'deepHashCode' can be used to determine if there were any modifications made to the underlying to and by maps of the ReferenceManager. The maps of the ReferenceManager are not synchronized, so someone could add/remove entries in them while the hashCode is being computed. Sum of the hashCodes for the to and by maps of theReferenceManager
since:
   2.3.24



findCreated
public Set findCreated()(Code)
Returns a list of all pages that the ReferenceManager knows about. This should be roughly equivalent to PageManager.getAllPages(), but without the potential disk access overhead. Note that this method is not guaranteed to return a Set of really all pages (especially during startup), but it is very fast. A Set of all defined page names that ReferenceManager knows about.
since:
   2.3.24



findReferredBy
public Set findReferredBy(String pageName)(Code)
Returns all pages that refer to this page. Note that this method returns an unmodifiable Map, which may be abruptly changed. So any access to any iterator may result in a ConcurrentModificationException.

The advantages of using this method over findReferrers() is that it is very fast, as it does not create a new object. The disadvantages are that it does not do any mapping between plural names, and you may end up getting a ConcurrentModificationException.
Parameters:
  pageName - Page name to query. A Set of Strings containing the names of all the pages that referto this page. May return null, if the page does not exist orhas not been indexed yet.
since:
   2.2.33




findReferrers
public synchronized Collection findReferrers(String pagename)(Code)
Find all pages that refer to this page. Returns null if the page does not exist or is not referenced at all, otherwise returns a collection containing page names (String) that refer to this one.


Parameters:
  pagename - The page to find referrers for. A Collection of Strings. (This is, in fact, a Set, and is likelyto change at some point to a Set). May return null, if the pagedoes not exist, or if it has no references.




findRefersTo
public Collection findRefersTo(String pageName)(Code)
Returns all pages that this page refers to. You can use this as a quick way of getting the links from a page, but note that it does not link any InterWiki, image, or external links. It does contain attachments, though.

The Collection returned is unmutable, so you cannot change it. It does reflect the current status and thus is a live object. So, if you are using any kind of an iterator on it, be prepared for ConcurrentModificationExceptions.

The returned value is a Collection, because a page may refer to another page multiple times.
Parameters:
  pageName - Page name to query A Collection of Strings containing the names of the pages that this pagerefers to. May return null, if the page does not exist or has notbeen indexed yet.
since:
   2.2.33




findUncreated
public synchronized Collection findUncreated()(Code)
Finds all references to non-existant pages. This requires a linear scan through m_refersTo values; each value must have a corresponding key entry in the reference Maps, otherwise such a page has never been created.

Returns a Collection containing Strings of unreferenced page names. Each non-existant page name is shown only once - we don't return information on who referred to it.




findUnreferenced
public synchronized Collection findUnreferenced()(Code)
Finds all unreferenced pages. This requires a linear scan through m_referredBy to locate keys with null or empty values.



getReferredBy
protected Map getReferredBy()(Code)
Returns the referred-by list. For debugging.



getRefersTo
protected Map getRefersTo()(Code)
Returns the refers-to list. For debugging.



initialize
public void initialize(Collection pages) throws ProviderException(Code)
Initializes the entire reference manager with the initial set of pages from the collection.
Parameters:
  pages - A collection of all pages you want to be included in the referencecount.
since:
   2.2



pageRemoved
public synchronized void pageRemoved(WikiPage page)(Code)
Updates the m_referedTo and m_referredBy hashmaps when a page has been deleted.

Within the m_refersTo map the pagename is a key. The whole key-value-set has to be removed to keep the map clean. Within the m_referredBy map the name is stored as a value. Since a key can have more than one value we have to delete just the key-value-pair referring page:deleted page.
Parameters:
  page - Name of the page to remove from the maps.




postSave
public void postSave(WikiContext context, String content)(Code)
After the page has been saved, updates the reference lists.



updateReferences
public synchronized void updateReferences(String page, Collection references)(Code)
Updates the referred pages of a new or edited WikiPage. If a refersTo entry for this page already exists, it is removed and a new one is built from scratch. Also calls updateReferredBy() for each referenced page.

This is the method to call when a new page has been created and we want to a) set up its references and b) notify the referred pages of the references. Use this method during run-time.
Parameters:
  page - Name of the page to update.
Parameters:
  references - A Collection of Strings, each one pointing to a page this page references.




Fields inherited from com.ecyrd.jspwiki.filters.BasicPageFilter
protected WikiEngine m_engine(Code)(Java Doc)

Methods inherited from com.ecyrd.jspwiki.filters.BasicPageFilter
public void destroy(WikiEngine engine)(Code)(Java Doc)
public void initialize(WikiEngine engine, Properties properties) throws FilterException(Code)(Java Doc)
public void postSave(WikiContext wikiContext, String content) throws FilterException(Code)(Java Doc)
public String postTranslate(WikiContext wikiContext, String htmlContent) throws FilterException(Code)(Java Doc)
public String preSave(WikiContext wikiContext, String content) throws FilterException(Code)(Java Doc)
public String preTranslate(WikiContext wikiContext, String content) throws FilterException(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.