Source Code Cross Referenced for PrefixTermTacletAppIndexCacheImpl.java in  » Testing » KeY » de » uka » ilkd » key » proof » 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 » Testing » KeY » de.uka.ilkd.key.proof 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // This file is part of KeY - Integrated Deductive Software Design
002:        // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
003:        //                         Universitaet Koblenz-Landau, Germany
004:        //                         Chalmers University of Technology, Sweden
005:        //
006:        // The KeY system is protected by the GNU General Public License. 
007:        // See LICENSE.TXT for details.
008:        //
009:        //
010:
011:        package de.uka.ilkd.key.proof;
012:
013:        import java.util.Map;
014:
015:        import de.uka.ilkd.key.logic.Term;
016:        import de.uka.ilkd.key.logic.op.ListOfQuantifiableVariable;
017:
018:        /**
019:         * The abstract superclass of caches for taclet app indexes that are implemented
020:         * using a common backend <code>LRUCache</code> (the backend is stored in
021:         * <code>TermTacletAppIndexCacheSet</code>). The backend is accessed in a way
022:         * that guarantees that two distinct instances of this class never interfere, by
023:         * choosing cache keys that are specific for a particular instance of
024:         * <code>PrefixTermTacletAppIndexCacheImpl</code> and cannot be created by
025:         * other instances. This ensures that it is safe to use one instance of
026:         * <code>LRUCache</code> for many instances of
027:         * <code>PrefixTermTacletAppIndexCacheImpl</code> (different proofs, different
028:         * proof branches, different locations).
029:         */
030:        abstract class PrefixTermTacletAppIndexCacheImpl extends
031:                PrefixTermTacletAppIndexCache {
032:
033:            private final Map cache;
034:
035:            protected PrefixTermTacletAppIndexCacheImpl(
036:                    ListOfQuantifiableVariable prefix, Map cache) {
037:                super (prefix);
038:                this .cache = cache;
039:            }
040:
041:            public TermTacletAppIndex getIndexForTerm(Term t) {
042:                final TermTacletAppIndex res = (TermTacletAppIndex) cache
043:                        .get(getQueryKey(t));
044:
045:                //       countAccess ( res != null );
046:
047:                return res;
048:            }
049:
050:            private int hits = 0, total = 0;
051:
052:            private void countAccess(boolean hit) {
053:                ++total;
054:                if (hit)
055:                    ++hits;
056:                if (total % 1000 == 0 && total != 0) {
057:                    System.out.println(name() + " " + hashCode() + ", size "
058:                            + cache.size() + ": " + ((double) hits)
059:                            / (double) total);
060:                }
061:            }
062:
063:            public void putIndexForTerm(Term t, TermTacletAppIndex index) {
064:                cache.put(getNewKey(t), index);
065:            }
066:
067:            /**
068:             * Only used for debugging purposes
069:             */
070:            protected abstract String name();
071:
072:            /**
073:             * @return a freshly created key for the term <code>t</code> that can be
074:             *         stored in the <code>cache</code>
075:             */
076:            private CacheKey getNewKey(Term t) {
077:                return new CacheKey(this , t);
078:            }
079:
080:            /**
081:             * @return a key for the term <code>t</code> that can be used for cache
082:             *         queries. Calling this method twice will return the same object
083:             *         (with different attribute values), i.e., the result is not
084:             *         supposed to be stored anywhere
085:             */
086:            private CacheKey getQueryKey(Term t) {
087:                queryCacheKey.analysedTerm = t;
088:                return queryCacheKey;
089:            }
090:
091:            private final CacheKey queryCacheKey = new CacheKey(this , null);
092:
093:            private static class CacheKey {
094:                private final PrefixTermTacletAppIndexCacheImpl parent;
095:                public Term analysedTerm;
096:
097:                public CacheKey(PrefixTermTacletAppIndexCacheImpl parent,
098:                        Term analysedTerm) {
099:                    this .parent = parent;
100:                    this .analysedTerm = analysedTerm;
101:                }
102:
103:                public boolean equals(Object obj) {
104:                    if (!(obj instanceof  CacheKey))
105:                        return false;
106:
107:                    final CacheKey objKey = (CacheKey) obj;
108:                    return parent == objKey.parent
109:                            && analysedTerm.equals(objKey.analysedTerm);
110:                }
111:
112:                public int hashCode() {
113:                    return parent.hashCode() * 3784831
114:                            + analysedTerm.hashCode();
115:                }
116:            }
117:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.