Source Code Cross Referenced for Cell.java in  » Testing » jwebunit » net » sourceforge » jwebunit » html » 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 » jwebunit » net.sourceforge.jwebunit.html 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /******************************************************************************
002:         * jWebUnit project (http://jwebunit.sourceforge.net)                         *
003:         * Distributed open-source, see full license under LICENCE.txt                *
004:         ******************************************************************************/package net.sourceforge.jwebunit.html;
005:
006:        import junit.framework.Assert;
007:
008:        import org.apache.regexp.RE;
009:        import org.apache.regexp.RESyntaxException;
010:
011:        /**
012:         * Represents a cell of an html table - a string value spanning an indicated amount of columns.
013:         * 
014:         * @author Jim Weaver
015:         * @author Julien Henry
016:         */
017:        public class Cell {
018:
019:            private int colspan;
020:
021:            private int rowspan;
022:
023:            private String value;
024:
025:            /**
026:             * Construct a cell with a default colspan/rowspan of 1.
027:             * 
028:             * @param value text expected within the cell.
029:             */
030:            public Cell(String value) {
031:                this (value, 1, 1);
032:            }
033:
034:            /**
035:             * Construct a cell with a specified colspan.
036:             * 
037:             * @param value text expected within the cell.
038:             * @param colspan number of columns the cell is expected to span.
039:             * @param rowspan number of rows the cell is expected to span.
040:             */
041:            public Cell(String value, int colspan, int rowspan) {
042:                this .value = value;
043:                this .colspan = colspan;
044:                this .rowspan = rowspan;
045:            }
046:
047:            /**
048:             * @return the colspan for this cell.
049:             */
050:            public int getColspan() {
051:                return colspan;
052:            }
053:
054:            /**
055:             * @return the rowspan for this cell.
056:             */
057:            public int getRowspan() {
058:                return rowspan;
059:            }
060:
061:            /**
062:             * @return the text for the cell.
063:             */
064:            public final String getValue() {
065:                return value;
066:            }
067:
068:            /**
069:             * Assert that the current cell equals given one. Check text, colspan and rowspan.
070:             * 
071:             * @param c given cell
072:             */
073:            public void assertEquals(Cell c) {
074:                Assert
075:                        .assertTrue(c.getValue() + " do not equal "
076:                                + this .getValue(), this .getValue().equals(
077:                                c.getValue()));
078:                Assert.assertTrue("Expected colspan was " + c.getColspan()
079:                        + " but was " + this .getColspan(),
080:                        this .getColspan() == c.getColspan());
081:                Assert.assertTrue("Expected rowspan was " + c.getRowspan()
082:                        + " but was " + this .getRowspan(),
083:                        this .getRowspan() == c.getRowspan());
084:            }
085:
086:            /**
087:             * Assert that the current cell matches given one. Check colspan and rowspan. Regexp is in text of given cell.
088:             * 
089:             * @param c given cell
090:             */
091:            public void assertMatch(Cell c) {
092:                RE re = getRE(c.getValue());
093:                Assert.assertTrue(c.getValue() + " do not match "
094:                        + this .getValue(), re.match(this .getValue()));
095:                Assert.assertTrue("Expected colspan was " + c.getColspan()
096:                        + " but was " + this .getColspan(),
097:                        this .getColspan() == c.getColspan());
098:                Assert.assertTrue("Expected rowspan was " + c.getRowspan()
099:                        + " but was " + this .getRowspan(),
100:                        this .getRowspan() == c.getRowspan());
101:            }
102:
103:            /**
104:             * Check if the current cell contains given text.
105:             * 
106:             * @param text given text.
107:             * @return true if the current cell contains given text.
108:             */
109:            public boolean equals(String text) {
110:                return this .getValue().equals(text);
111:            }
112:
113:            /**
114:             * Check if the current cell matches given text.
115:             * 
116:             * @param regexp given regexp.
117:             * @return true if the current cell matches given text.
118:             */
119:            public boolean match(String regexp) {
120:                RE re = getRE(regexp);
121:                return re.match(this .getValue());
122:            }
123:
124:            /**
125:             * Create a regexp.
126:             * 
127:             * @param regexp regexp pattern
128:             * @return regexp object
129:             */
130:            private RE getRE(String regexp) {
131:                RE re = null;
132:                try {
133:                    re = new RE(regexp, RE.MATCH_SINGLELINE);
134:                } catch (RESyntaxException e) {
135:                    Assert.fail(e.toString());
136:                }
137:                return re;
138:            }
139:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.