Source Code Cross Referenced for ApprovalMatch.java in  » Authentication-Authorization » ejbca » org » ejbca » util » query » 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 » Authentication Authorization » ejbca » org.ejbca.util.query 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*************************************************************************
002:         *                                                                       *
003:         *  EJBCA: The OpenSource Certificate Authority                          *
004:         *                                                                       *
005:         *  This software is free software; you can redistribute it and/or       *
006:         *  modify it under the terms of the GNU Lesser General Public           *
007:         *  License as published by the Free Software Foundation; either         *
008:         *  version 2.1 of the License, or any later version.                    *
009:         *                                                                       *
010:         *  See terms of license at gnu.org.                                     *
011:         *                                                                       *
012:         *************************************************************************/package org.ejbca.util.query;
013:
014:        /**
015:         * A class used by Query class to build a query for ejbca log module. Inherits BasicMatch.  Main
016:         * function is getQueryString which returns a fragment of SQL statment.
017:         *
018:         * @author TomSelleck
019:         * @version $Id: ApprovalMatch.java,v 1.3 2007/05/04 09:06:39 anatom Exp $
020:         *
021:         * @see org.ejbca.util.query.BasicMatch
022:         * @see org.ejbca.util.query.TimeMatch
023:         * @see org.ejbca.util.query.ApprovalMatch
024:         */
025:        public class ApprovalMatch extends BasicMatch {
026:            // Public Constants
027:
028:            public static final int MATCH_WITH_UNIQUEID = 0;
029:            public static final int MATCH_WITH_APPROVALID = 1;
030:            public static final int MATCH_WITH_APPROVALTYPE = 2;
031:            public static final int MATCH_WITH_ENDENTITYPROFILEID = 3;
032:            public static final int MATCH_WITH_CAID = 4;
033:            public static final int MATCH_WITH_REQUESTADMINCERTISSUERDN = 5;
034:            public static final int MATCH_WITH_REQUESTADMINCERTSERIALNUMBER = 6;
035:            public static final int MATCH_WITH_STATUS = 7;
036:            public static final int MATCH_WITH_REMAININGAPPROVALS = 8;
037:
038:            // Private Constants.
039:            static final String[] MATCH_WITH_SQLNAMES = { "id", "approvalid",
040:                    "approvaltype", "endentityprofileid", "caid",
041:                    "reqadmincertissuerdn", "reqadmincertsn", "status",
042:                    "remainingapprovals" }; // Represents the column names in approvals table.
043:
044:            // Public methods.
045:
046:            /**
047:             * Creates a new instance of LogMatch.
048:             *
049:             * @param matchwith determines which field i logentry table to match with.
050:             * @param matchtype determines how to match the field..
051:             * @param matchvalue the value to match with.
052:             *
053:             * @throws NumberFormatException if matchvalue constains illegal numbervalue when matching
054:             *         number field.
055:             */
056:            public ApprovalMatch(int matchwith, int matchtype, String matchvalue)
057:                    throws NumberFormatException {
058:                this .matchwith = matchwith;
059:                this .matchtype = matchtype;
060:                this .matchvalue = matchvalue;
061:
062:                // The row below does not do anthing but check that matchvalue contains
063:                // a legal number value when matching number field. See @throws clause.
064:                if (matchwith != MATCH_WITH_REQUESTADMINCERTISSUERDN
065:                        && matchwith != MATCH_WITH_REQUESTADMINCERTSERIALNUMBER) {
066:                    new Integer(matchvalue);
067:                }
068:            }
069:
070:            /**
071:             * Returns a SQL statement fragment from the given data.
072:             *
073:             * @return DOCUMENT ME!
074:             */
075:            public String getQueryString() {
076:                String returnval = "";
077:
078:                if (matchtype == BasicMatch.MATCH_TYPE_EQUALS) {
079:                    // Because some databases (read JavaDB/Derby) does not allow matching of integer with a string expression
080:                    // like "where status='10'" instead of "where status=10", we have to hav e some special handling here.
081:                    String stringChar = "'";
082:                    if ((matchwith >= MATCH_WITH_UNIQUEID && matchwith <= MATCH_WITH_CAID)
083:                            || (matchwith == MATCH_WITH_STATUS)
084:                            || (matchwith == MATCH_WITH_REMAININGAPPROVALS)) {
085:                        stringChar = "";
086:                    }
087:                    returnval = MATCH_WITH_SQLNAMES[matchwith] + " = "
088:                            + stringChar + matchvalue + stringChar;
089:                }
090:
091:                if (matchtype == BasicMatch.MATCH_TYPE_BEGINSWITH) {
092:                    returnval = MATCH_WITH_SQLNAMES[matchwith] + " LIKE '"
093:                            + matchvalue + "%'";
094:                }
095:
096:                if (matchtype == BasicMatch.MATCH_TYPE_CONTAINS) {
097:                    returnval = MATCH_WITH_SQLNAMES[matchwith] + " LIKE '%"
098:                            + matchvalue + "%'";
099:                }
100:
101:                return returnval;
102:            }
103:
104:            // getQueryString
105:
106:            /**
107:             * Checks if query data is ok.
108:             *
109:             * @return DOCUMENT ME!
110:             */
111:            public boolean isLegalQuery() {
112:                return !(matchvalue.trim().equals(""));
113:            }
114:
115:            // Private Methods
116:            // Private Fields.
117:            private int matchwith;
118:            private int matchtype;
119:            private String matchvalue;
120:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.