Salome HOME
e7e5c1410102e73f8893ae82c50208d3a8c222bb
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / service / dto / FileDTO.java
1 /*****************************************************************************
2  * Company         OPEN CASCADE
3  * Application     SIMAN
4  * File            $Id$ 
5  * Creation date   14.11.2012
6  * @author         $Author$
7  * @version        $Revision$
8  * @copyright      OPEN CASCADE 2012
9  *****************************************************************************/
10
11 package org.splat.service.dto;
12
13 /**
14  * Document's file DTO.
15  */
16 public class FileDTO {
17
18         /**
19          * True if the file is a result file for a document.
20          */
21         private boolean _isResult; // RKV: NOPMD: isResult method is used as getter
22         /**
23          * File state: "Y" - actual, "O" - outdated, "N" - taken from other study.
24          */
25         private char _state;
26         /**
27          * Automatic processing instruction: "file-import", "file-download", etc.
28          */
29         private String _processing;
30         /**
31          * File path from the repository root.
32          */
33         private String _path;
34
35         /**
36          * Constructor with initialization.
37          * 
38          * @param relativePath
39          *            relative file path
40          * @param state
41          *            file state
42          * @param processing
43          *            processing instruction: file-download or file-import
44          * @param isResult
45          *            true if the file is result
46          */
47         public FileDTO(final String relativePath, final char state,
48                         final String processing, final boolean isResult) {
49                 _path = relativePath;
50                 _state = state;
51                 _processing = processing;
52                 _isResult = isResult;
53         }
54         
55         /**
56          * Constructor with initialization.
57          * 
58          * @param relativePath
59          *            relative file path
60          */
61         public FileDTO(final String relativePath) {
62                 _path = relativePath;
63         }
64
65         /**
66          * Get the isResult.
67          * 
68          * @return the isResult
69          */
70         public boolean isResult() {
71                 return _isResult;
72         }
73
74         /**
75          * Set the isResult.
76          * 
77          * @param isResult
78          *            the isResult to set
79          */
80         public void setResult(final boolean isResult) {
81                 _isResult = isResult;
82         }
83
84         /**
85          * Get the state.
86          * 
87          * @return the state
88          */
89         public char getState() {
90                 return _state;
91         }
92
93         /**
94          * Set the state.
95          * 
96          * @param state
97          *            the state to set
98          */
99         public void setState(final char state) {
100                 _state = state;
101         }
102
103         /**
104          * Get the processing.
105          * 
106          * @return the processing
107          */
108         public String getProcessing() {
109                 return _processing;
110         }
111
112         /**
113          * Set the processing.
114          * 
115          * @param processing
116          *            the processing to set
117          */
118         public void setProcessing(final String processing) {
119                 _processing = processing;
120         }
121
122         /**
123          * Get the path.
124          * 
125          * @return the path
126          */
127         public String getPath() {
128                 return _path;
129         }
130
131         /**
132          * Set the path.
133          * 
134          * @param path
135          *            the path to set
136          */
137         public void setPath(final String path) {
138                 _path = path;
139         }
140
141         /**
142          * {@inheritDoc}
143          * 
144          * @see java.lang.Object#toString()
145          */
146         @Override
147         public String toString() {
148                 StringBuffer buf = new StringBuffer();
149                 String indent = "        ";
150                 String ftype = "Source";
151                 if (isResult()) {
152                         ftype = "Result";
153                 }
154                 String fstate = "file-actual";
155                 if (getState() == 'O') {
156                         fstate = "file-outdated";
157                 }
158                 buf.append(indent).append(ftype).append(" file: ").append(getPath())
159                                 .append('\n').append(indent).append(
160                                                 "    Automatic processing: ").append(getProcessing())
161                                 .append('\n').append(indent).append("    State: ").append(
162                                                 fstate).append('\n');
163                 return buf.toString();
164         }
165 }