Source Code Cross Referenced for FxThumbnailURIConfigurator.java in  » J2EE » fleXive » com » flexive » war » 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 » J2EE » fleXive » com.flexive.war 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /***************************************************************
002:         *  This file is part of the [fleXive](R) project.
003:         *
004:         *  Copyright (c) 1999-2007
005:         *  UCS - unique computing solutions gmbh (http://www.ucs.at)
006:         *  All rights reserved
007:         *
008:         *  The [fleXive](R) project is free software; you can redistribute
009:         *  it and/or modify it under the terms of the GNU General Public
010:         *  License as published by the Free Software Foundation;
011:         *  either version 2 of the License, or (at your option) any
012:         *  later version.
013:         *
014:         *  The GNU General Public License can be found at
015:         *  http://www.gnu.org/copyleft/gpl.html.
016:         *  A copy is found in the textfile GPL.txt and important notices to the
017:         *  license from the author are found in LICENSE.txt distributed with
018:         *  these libraries.
019:         *
020:         *  This library is distributed in the hope that it will be useful,
021:         *  but WITHOUT ANY WARRANTY; without even the implied warranty of
022:         *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
023:         *  GNU General Public License for more details.
024:         *
025:         *  For further information about UCS - unique computing solutions gmbh,
026:         *  please see the company website: http://www.ucs.at
027:         *
028:         *  For further information about [fleXive](R), please see the
029:         *  project website: http://www.flexive.org
030:         *
031:         *
032:         *  This copyright notice MUST APPEAR in all copies of the file!
033:         ***************************************************************/package com.flexive.war;
034:
035:        import com.flexive.shared.FxSharedUtils;
036:        import com.flexive.shared.FxLanguage;
037:        import com.flexive.shared.EJBLookup;
038:        import com.flexive.shared.exceptions.FxApplicationException;
039:        import com.flexive.shared.content.FxPK;
040:
041:        import java.awt.*;
042:        import java.util.regex.Pattern;
043:
044:        import org.apache.commons.lang.StringUtils;
045:
046:        /**
047:         * Configuration helper that parses a URI for thumbnail configuration parameters
048:         *
049:         * @author Markus Plesser (markus.plesser@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
050:         */
051:        public class FxThumbnailURIConfigurator {
052:
053:            private final static Pattern pPK = Pattern
054:                    .compile("^pk\\d+(\\.(\\d+|MAX|LIVE))?");
055:            private final static Pattern pXPath = Pattern.compile("^xp.+");
056:            private final static Pattern pSize = Pattern.compile("s[0123]");
057:            private final static Pattern pLang = Pattern
058:                    .compile("^lang[a-zA-Z]{2}");
059:            private final static Pattern pLangFallback = Pattern
060:                    .compile("^lfb[01]");
061:
062:            private String URI;
063:            private FxPK pk = null;
064:            private String xp = null;
065:            private String lang = null;
066:            private Boolean langFallback = null;
067:            private String err500 = null;
068:            private String err404 = null;
069:            private String err403 = null;
070:            private int size = 0;
071:            private int scaleWidth = -1, scaleHeight = -1;
072:            private byte rot = 0;
073:            private Boolean flipH = null, flipV = null;
074:            private Rectangle crop = null;
075:            private String filename = null; //filename is last parameter (optional) if it contains a dot and does not match another parameter
076:
077:            public FxThumbnailURIConfigurator(String URI) {
078:                this .URI = URI;
079:                parse();
080:            }
081:
082:            /**
083:             * Valid options are:
084:             * <ul>
085:             * <li><code>pk{n.m}</code>  - id and version of the content, if no version is given the live version is used</li>
086:             * <li><code>xp{path}</code>  - URL encoded XPath of the property containing the image (optional, else default will be used)</li>
087:             * <li><code>lang{lang}</code> - 2-digit ISO language code
088:             * <li><code>lfb{0,1}</code> - language fallback: 0=generate error if language not found, 1=fall back to default language
089:             * <li><code>e{3 digit error number}u{error url}</code> - URL encoded error url to redirect for http errors specified in {error number}, if no number is given then the url is a fallback for unclassified errors
090:             * <li><code>s{0,1,2,3}</code>  - use a predefined image/thumbnail size, 0=default</li>
091:             * <li><code>w{n}</code> - scale to width</li>
092:             * <li><code>h{n}</code> - scale to height</li>
093:             * <li><code>rot{90,180,270}</code> - rotate 90, 180 or 270 degrees (rotate is always executed before flip operations)</li>
094:             * <li><code>flip{h,v}</code> - flip horizontal or vertical (rotate is always executed before flip operations)</li>
095:             * <li><code>cropx{x}y{y}w{w}h{h}</code> - crop a box from image defined by x,y,w(idth),h(eight), scaling applies to cropped image!</li>
096:             * </ul>
097:             */
098:            private void parse() {
099:                String[] elements = URI.split("\\/");
100:                for (String element : elements) {
101:                    if (pk == null && pPK.matcher(element).matches()) {
102:                        pk = FxPK.fromString(element.substring(2));
103:                    }
104:                    if (xp == null && pXPath.matcher(element).matches()) {
105:                        xp = FxSharedUtils.decodeXPath(element.substring(2));
106:                    }
107:                    if (size == 0 && pSize.matcher(element).matches())
108:                        size = Integer.parseInt(element.substring(1));
109:                    if (lang == null && pLang.matcher(element).matches())
110:                        lang = element.substring(4);
111:                    if (langFallback == null
112:                            && pLangFallback.matcher(element).matches())
113:                        langFallback = "1".equals(element.substring(3));
114:                }
115:                if (xp == null)
116:                    xp = "/";
117:            }
118:
119:            public boolean hasPK() {
120:                return pk != null;
121:            }
122:
123:            public String getXPath() {
124:                return xp;
125:            }
126:
127:            public FxPK getPK() {
128:                return pk;
129:            }
130:
131:            public int getSize() {
132:                return size;
133:            }
134:
135:            public String getLanguageIso() {
136:                return lang;
137:            }
138:
139:            public FxLanguage getLanguage() throws FxApplicationException {
140:                return StringUtils.isNotBlank(lang) ? EJBLookup
141:                        .getLanguageEngine().load(lang) : null;
142:            }
143:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.