1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.xar

File XarEntry.java

 

Coverage histogram

../../../img/srcFileCovDistChart6.png
72% of files have more coverage

Code metrics

2
22
13
1
194
78
14
0.64
1.69
13
1.08

Classes

Class Line # Actions
XarEntry 37 22 0% 14 16
0.567567656.8%
 

Contributing tests

This file is covered by 35 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.xar;
21   
22    import java.beans.Transient;
23   
24    import org.xwiki.model.EntityType;
25    import org.xwiki.model.reference.LocalDocumentReference;
26    import org.xwiki.xar.internal.model.XarModel;
27   
28    /**
29    * An entry (wiki page) in a XAR package.
30    * <p>
31    * Reuse LocalDocumentReference equals and hashCode implementation so that the entry can be used as a
32    * {@link LocalDocumentReference} in a map.
33    *
34    * @version $Id: 86e580c40e6905a69eb9e39eb4e24b106bf211ad $
35    * @since 5.4RC1
36    */
 
37    public class XarEntry extends LocalDocumentReference
38    {
39    /**
40    * @see #getEntryName()
41    */
42    private String entryName;
43   
44    /**
45    * @see #getDefaultAction()
46    */
47    private int defaultAction;
48   
49    /**
50    * @see #getEntryType()
51    */
52    private String entryType;
53   
54    /**
55    * @param reference the reference of the document
56    */
 
57  5964 toggle public XarEntry(LocalDocumentReference reference)
58    {
59  5964 this(reference, null);
60    }
61   
62    /**
63    * @param reference the reference of the document
64    * @param name the name of the entry (ZIP style)
65    */
 
66  5964 toggle public XarEntry(LocalDocumentReference reference, String name)
67    {
68  5964 this(reference, name, XarModel.ACTION_OVERWRITE);
69    }
70   
71    /**
72    * @param reference the reference of the document
73    * @param name the name of the entry (ZIP style)
74    * @param entryType the type of the entry
75    * @since 10.3
76    */
 
77  0 toggle public XarEntry(LocalDocumentReference reference, String name, String entryType)
78    {
79  0 this(reference, name, XarModel.ACTION_OVERWRITE, entryType);
80    }
81   
82    /**
83    * @param reference the reference of the document
84    * @param defaultAction the default action associated to a XAR entry
85    * @since 7.2M1
86    */
 
87  6 toggle public XarEntry(LocalDocumentReference reference, int defaultAction)
88    {
89  6 this(reference, defaultAction, null);
90    }
91   
92    /**
93    * @param reference the reference of the document
94    * @param defaultAction the default action associated to a XAR entry
95    * @param entryType the type of the entry
96    * @since 10.3
97    */
 
98  9 toggle public XarEntry(LocalDocumentReference reference, int defaultAction, String entryType)
99    {
100  9 this(reference, null, defaultAction, entryType);
101    }
102   
103    /**
104    * @param reference the reference of the document
105    * @param name the name of the entry (ZIP style)
106    * @param defaultAction the default action associated to a XAR entry (not used at the moment)
107    */
 
108  6162 toggle public XarEntry(LocalDocumentReference reference, String name, int defaultAction)
109    {
110  6162 this(reference, name, defaultAction, null);
111    }
112   
113    /**
114    * @param reference the reference of the document
115    * @param name the name of the entry (ZIP style)
116    * @param defaultAction the default action associated to a XAR entry (not used at the moment)
117    * @param entryType the type of the entry
118    * @since 10.3
119    */
 
120  62529 toggle public XarEntry(LocalDocumentReference reference, String name, int defaultAction, String entryType)
121    {
122  62529 super(reference);
123   
124  62529 this.entryName = name;
125  62529 this.defaultAction = defaultAction;
126  62529 this.entryType = entryType;
127    }
128   
129    /**
130    * @return the name of the entry in the ZIP (XAR) package
131    */
 
132  22235 toggle public String getEntryName()
133    {
134  22235 return this.entryName;
135    }
136   
137    /**
138    * @return the type of the entry
139    * @since 10.3
140    */
 
141  59741 toggle public String getEntryType()
142    {
143  59740 return this.entryType;
144    }
145   
146    /**
147    * @return the name of the document
148    */
 
149  0 toggle @Transient
150    public String getDocumentName()
151    {
152  0 return getName();
153    }
154   
 
155  0 toggle @Override
156    public String toString()
157    {
158  0 StringBuilder str = new StringBuilder(super.toString());
159   
160  0 if (getEntryName() != null) {
161  0 str.append(' ');
162  0 str.append('(');
163  0 str.append(getEntryName());
164  0 str.append(')');
165    }
166   
167  0 return str.toString();
168    }
169   
170    // Deprecated
171   
172    /**
173    * @return the default action associated to the entry
174    * @deprecated kept for retro compatibility reason (since this used to exist in XAR format) but this method never
175    * really been used in XWiki Standard. Similar concept (among other things) are exposed through
176    * {@link #getEntryType()}.
177    */
 
178  12817 toggle @Deprecated
179    public int getDefaultAction()
180    {
181  12817 return this.defaultAction;
182    }
183   
184    /**
185    * @return the space of the document
186    * @deprecated since 7.2M1, does not make much sense anymore with nested space
187    */
 
188  0 toggle @Deprecated
189    @Transient
190    public String getSpaceName()
191    {
192  0 return TOSTRING_SERIALIZER.serialize(extractReference(EntityType.SPACE));
193    }
194    }