Source Code Cross Referenced for CheckSOIF.java in  » Portal » Open-Portal » com » sun » portal » search » soif » 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 » Portal » Open Portal » com.sun.portal.search.soif 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  cksoif - Reads in templates from stdin and prints whether or not
003:         *  it's a legal SOIF template.
004:         *
005:         *  Usage: cksoif
006:         */
007:        package com.sun.portal.search.soif;
008:
009:        import com.sun.portal.search.util.*;
010:        import java.io.*;
011:        import java.util.*;
012:
013:        class CheckSOIF {
014:
015:            static void usage() {
016:                System.out
017:                        .print("Usage: CheckSOIF [-qacvio] [infile] [outfile]\n"
018:                                + "       -q quiet\n"
019:                                + "       -a don't dump attributes\n"
020:                                + "       -c don't dump stats (attribute counts, content size, etc)\n"
021:                                + "       -v dump attribute values\n"
022:                                + "       -i input SOIF character encoding\n"
023:                                + "       -o output SOIF character encoding\n");
024:            }
025:
026:            public static void main(String[] args) throws Exception {
027:
028:                String ifn = null;
029:                String ofn = null;
030:
031:                SOIFInputStream cx = null;
032:                SOIFOutputStream ocx = null;
033:                SOIF s;
034:
035:                int n = 0, nok = 0;
036:                boolean cntflag = true, attrsflag = true, quiet = false, valflag = false;
037:                String iencoding = SOIF.defaultEncoding;
038:                String oencoding = SOIF.defaultEncoding;
039:
040:                Getopt gopt = new Getopt(args, "qacvi:o:");
041:
042:                int c;
043:                while ((c = gopt.getopt()) != -1) {
044:                    switch (c) {
045:                    case 'q':
046:                        quiet = true;
047:                        break;
048:                    case 'a':
049:                        attrsflag = false;
050:                        break;
051:                    case 'c':
052:                        cntflag = false;
053:                        break;
054:                    case 'v':
055:                        valflag = true;
056:                        break;
057:                    case 'i':
058:                        iencoding = gopt.optArg;
059:                        break;
060:                    case 'o':
061:                        oencoding = gopt.optArg;
062:                        break;
063:                    default:
064:                        usage();
065:                        System.exit(1);
066:                    }
067:                }
068:
069:                // do we have an input file name?
070:                if ((args.length - gopt.optInd) > 0)
071:                    ifn = args[gopt.optInd++];
072:
073:                // do we have an output file name?
074:                if ((args.length - gopt.optInd) > 0)
075:                    ofn = args[gopt.optInd++];
076:
077:                if (args.length - gopt.optInd > 0) {
078:                    usage();
079:                    System.exit(1);
080:                }
081:
082:                if (ifn != null)
083:                    if (ifn.equals("-"))
084:                        cx = new SOIFInputStream(System.in, iencoding);
085:                    else
086:                        cx = new SOIFInputStream(ifn, iencoding);
087:
088:                if (ofn != null)
089:                    if (ofn.equals("-"))
090:                        ocx = new SOIFOutputStream(System.out, oencoding);
091:                    else
092:                        ocx = new SOIFOutputStream(ofn, oencoding);
093:
094:                n = nok = 0;
095:
096:                for (;;) {
097:
098:                    n++;
099:
100:                    try {
101:                        s = cx.readSOIF();
102:                    } catch (Exception e) {
103:                        System.out.println("Attempt " + n + ":\t " + e);
104:                        continue;
105:                    }
106:
107:                    if (s == null)
108:                        break;
109:
110:                    if (!quiet) {
111:                        System.out.println("Attempt " + n + ":\tValid SOIF");
112:                        System.out
113:                                .println("Attempt " + n + ":\tSOIF analysis:");
114:                        System.out.println("  URL:\t" + s.getURL());
115:                        System.out.println("  Schema-Name:\t"
116:                                + s.getSchemaName());
117:
118:                        if (cntflag) {
119:                            int ac = s.getAttributeCount();
120:                            //int as = s.getAttributeSize());
121:                            //int vc = s.getValueCount());
122:                            //int vs = s.getValueSize());
123:                            //int ts = s.getTotalSize());
124:                            int cs = s.contentSize();
125:
126:                            if (!quiet) {
127:                                System.out.println("  AttributeCount:\t" + ac);
128:                                //System.out.println("  AttributeSize:\t" + as);
129:                                //System.out.println("  ValueCount:\t" + vc);
130:                                //System.out.println("  ValueSize:\t" + vs);
131:                                //System.out.println("  TotalSize:\t" + ts);
132:                                System.out.println("  ContentSize:\t" + cs);
133:                            }
134:                        }
135:                        if (attrsflag) {
136:                            Set attrs;
137:                            int cnt;
138:                            if (!quiet)
139:                                System.out.println("  Attributes:\t");
140:                            if ((attrs = s.getAttributes()) != null) {
141:                                cnt = attrs.size();
142:                                if (cnt == 0) {
143:                                    if (!quiet)
144:                                        System.out.println("EMPTY");
145:                                } else {
146:                                    //Arrays.sort(attrs, cnt+1, sizeof(String ), qsort_cmp);
147:                                    for (Iterator i = attrs.iterator(); i
148:                                            .hasNext();) {
149:                                        String att = (String) i.next();
150:                                        if (!quiet)
151:                                            System.out.print(att + " ");
152:                                        if (valflag)
153:                                            System.out.println("= "
154:                                                    + s.getValue(att));
155:                                    }
156:                                    if (!quiet)
157:                                        System.out.println();
158:                                }
159:                            } else {
160:                                if (!quiet)
161:                                    System.out.println("EMPTY");
162:                            }
163:                        }
164:                    }
165:
166:                    if (ocx != null)
167:                        ocx.write(s);
168:                    String pt = s.getValue("partial-text");
169:                    nok++;
170:                }
171:                System.out.println("Successfully parsed " + nok
172:                        + " SOIF objects, in " + (n - 1) + " attempts");
173:                if (ocx != null)
174:                    ocx.close();
175:            }
176:
177:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.