Source Code Cross Referenced for SVNCommitPacket.java in  » Source-Control » tmatesoft-SVN » org » tmatesoft » svn » core » wc » 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 » Source Control » tmatesoft SVN » org.tmatesoft.svn.core.wc 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ====================================================================
003:         * Copyright (c) 2004-2008 TMate Software Ltd.  All rights reserved.
004:         *
005:         * This software is licensed as described in the file COPYING, which
006:         * you should have received as part of this distribution.  The terms
007:         * are also available at http://svnkit.com/license.html
008:         * If newer versions of this license are posted there, you may use a
009:         * newer version instead, at your option.
010:         * ====================================================================
011:         */
012:        package org.tmatesoft.svn.core.wc;
013:
014:        import java.util.ArrayList;
015:        import java.util.Collection;
016:        import java.util.HashMap;
017:        import java.util.Map;
018:
019:        import org.tmatesoft.svn.core.SVNException;
020:        import org.tmatesoft.svn.core.internal.wc.admin.SVNWCAccess;
021:
022:        /**
023:         * The <b>SVNCommitPacket</b> is a storage for <b>SVNCommitItem</b>
024:         * objects which represent information on versioned items intended
025:         * for being committed to a repository.
026:         * 
027:         * <p>
028:         * Used by <b>SVNCommitClient</b> in {@link SVNCommitClient#doCollectCommitItems(File[], boolean, boolean, boolean) doCollectCommitItems()}
029:         * to collect and hold information on paths that have local changes.
030:         * 
031:         * @version 1.1.1
032:         * @author  TMate Software Ltd.
033:         * @see     SVNCommitItem
034:         */
035:        public class SVNCommitPacket {
036:            /**
037:             * This constant denotes an empty commit items storage (contains no
038:             * {@link SVNCommitItem} objects).
039:             */
040:            public static final SVNCommitPacket EMPTY = new SVNCommitPacket(
041:                    null, new SVNCommitItem[0], null);
042:
043:            private SVNCommitItem[] myCommitItems;
044:            private Map myLockTokens;
045:            private boolean[] myIsSkipped;
046:            private boolean myIsDisposed;
047:
048:            SVNCommitPacket(SVNWCAccess wcAccess, SVNCommitItem[] items,
049:                    Map lockTokens) {
050:                myCommitItems = items;
051:                myLockTokens = lockTokens;
052:                myIsSkipped = new boolean[items == null ? 0 : items.length];
053:                myIsDisposed = false;
054:
055:                if (wcAccess != null) {
056:                    for (int i = 0; i < items.length; i++) {
057:                        if (items[i].getWCAccess() == null) {
058:                            items[i].setWCAccess(wcAccess);
059:                        }
060:                    }
061:                }
062:            }
063:
064:            /**
065:             * Gets an array of <b>SVNCommitItem</b> objects stored in this
066:             * object.
067:             * 
068:             * @return an array of <b>SVNCommitItem</b> objects containing
069:             *         info of versioned items to be committed
070:             */
071:            public SVNCommitItem[] getCommitItems() {
072:                return myCommitItems;
073:            }
074:
075:            /**
076:             * Sets or unsets a versioned item to be skipped - 
077:             * whether or not it should be committed. 
078:             * 
079:             * 
080:             * @param item      an item that should be marked skipped
081:             * @param skipped   if <span class="javakeyword">true</span> the item is
082:             *                  set to be skipped (a commit operation should skip 
083:             *                  the item), otherwise - unskipped if it was
084:             *                  previously marked skipped
085:             * @see             #isCommitItemSkipped(SVNCommitItem)
086:             *                  
087:             */
088:            public void setCommitItemSkipped(SVNCommitItem item, boolean skipped) {
089:                int index = getItemIndex(item);
090:                if (index >= 0 && index < myIsSkipped.length) {
091:                    myIsSkipped[index] = skipped;
092:                }
093:            }
094:
095:            /**
096:             * Determines if an item intended for a commit is set to 
097:             * be skipped - that is not to be committed.
098:             * 
099:             * @param  item  an item to check
100:             * @return       <span class="javakeyword">true</span> if the item
101:             *               is set to be skipped, otherwise <span class="javakeyword">false</span>
102:             * @see          #setCommitItemSkipped(SVNCommitItem, boolean)   
103:             */
104:            public boolean isCommitItemSkipped(SVNCommitItem item) {
105:                int index = getItemIndex(item);
106:                if (index >= 0 && index < myIsSkipped.length) {
107:                    return myIsSkipped[index];
108:                }
109:                return true;
110:            }
111:
112:            /**
113:             * Determines if this object is disposed.
114:             * 
115:             * @return <span class="javakeyword">true</span> if disposed
116:             *         otherwise <span class="javakeyword">false</span>
117:             */
118:            public boolean isDisposed() {
119:                return myIsDisposed;
120:            }
121:
122:            /**
123:             * Disposes the current object.
124:             * 
125:             * @throws SVNException
126:             */
127:            public void dispose() throws SVNException {
128:                try {
129:                    for (int i = 0; i < myCommitItems.length; i++) {
130:                        if (myCommitItems[i] != null
131:                                && myCommitItems[i].getWCAccess() != null) {
132:                            myCommitItems[i].getWCAccess().close();
133:                        }
134:                    }
135:                } finally {
136:                    myIsDisposed = true;
137:                }
138:            }
139:
140:            private int getItemIndex(SVNCommitItem item) {
141:                for (int i = 0; myCommitItems != null
142:                        && i < myCommitItems.length; i++) {
143:                    SVNCommitItem commitItem = myCommitItems[i];
144:                    if (commitItem == item) {
145:                        return i;
146:                    }
147:                }
148:                return -1;
149:            }
150:
151:            Map getLockTokens() {
152:                return myLockTokens;
153:            }
154:
155:            SVNCommitPacket removeSkippedItems() {
156:                if (this  == EMPTY) {
157:                    return EMPTY;
158:                }
159:                Collection items = new ArrayList();
160:                Map lockTokens = myLockTokens == null ? null : new HashMap(
161:                        myLockTokens);
162:                for (int i = 0; myCommitItems != null
163:                        && i < myCommitItems.length; i++) {
164:                    SVNCommitItem commitItem = myCommitItems[i];
165:                    if (!myIsSkipped[i]) {
166:                        items.add(commitItem);
167:                    } else if (lockTokens != null) {
168:                        lockTokens.remove(commitItem.getURL().toString());
169:                    }
170:                }
171:                SVNCommitItem[] filteredItems = (SVNCommitItem[]) items
172:                        .toArray(new SVNCommitItem[items.size()]);
173:                return new SVNCommitPacket(null, filteredItems, lockTokens);
174:            }
175:
176:            /**
177:             * Gives a string representation of this object.
178:             * 
179:             * @return a string representing this object.
180:             */
181:            public String toString() {
182:                if (EMPTY == this ) {
183:                    return "[EMPTY]";
184:                }
185:                StringBuffer result = new StringBuffer();
186:                result.append("SVNCommitPacket: ");
187:                for (int i = 0; i < myCommitItems.length; i++) {
188:                    SVNCommitItem commitItem = myCommitItems[i];
189:                    result.append("\n");
190:                    if (commitItem.isAdded()) {
191:                        result.append("A");
192:                    } else if (commitItem.isDeleted()) {
193:                        result.append("D");
194:                    } else if (commitItem.isContentsModified()) {
195:                        result.append("M");
196:                    } else {
197:                        result.append("_");
198:                    }
199:                    if (commitItem.isPropertiesModified()) {
200:                        result.append("M");
201:                    } else {
202:                        result.append(" ");
203:                    }
204:                    result.append(" ");
205:                    if (commitItem.getPath() != null) {
206:                        result.append(commitItem.getPath());
207:                        result.append(" ");
208:                    }
209:                    result.append(commitItem.getFile().getAbsolutePath());
210:                    result.append("\n");
211:                    result.append(commitItem.getRevision());
212:                    result.append(" ");
213:                    result.append(commitItem.getURL());
214:                    if (commitItem.isCopied()) {
215:                        result.append("\n");
216:                        result.append("+");
217:                        result.append(commitItem.getCopyFromURL());
218:                    }
219:                    if (commitItem.isLocked()) {
220:                        result.append("\n");
221:                        result.append("LOCKED");
222:                    }
223:                }
224:                return result.toString();
225:            }
226:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.