1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.xar

File XarEntry.java

 

Coverage histogram

../../../img/srcFileCovDistChart5.png
74% of files have more coverage

Code metrics

2
16
9
1
138
58
10
0.62
1.78
9
1.11

Classes

Class Line # Actions
XarEntry 37 16 0% 10 14
0.481481548.1%
 

Contributing tests

This file is covered by 34 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: 7a51aabe59a1a343210839ad4e22798f00d17be3 $
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    * @param reference the reference of the document
51    */
 
52  582 toggle public XarEntry(LocalDocumentReference reference)
53    {
54  582 this(reference, null);
55    }
56   
57    /**
58    * @param reference the reference of the document
59    * @param name the name of the entry (ZIP style)
60    */
 
61  582 toggle public XarEntry(LocalDocumentReference reference, String name)
62    {
63  582 this(reference, name, XarModel.ACTION_OVERWRITE);
64    }
65   
66    /**
67    * @param reference the reference of the document
68    * @param defaultAction the default action associated to a XAR entry
69    * @since 7.2M1
70    */
 
71  9 toggle public XarEntry(LocalDocumentReference reference, int defaultAction)
72    {
73  9 this(reference, null, defaultAction);
74    }
75   
76    /**
77    * @param reference the reference of the document
78    * @param name the name of the entry (ZIP style)
79    * @param defaultAction the default action associated to a XAR entry (not used at the moment)
80    */
 
81  7613 toggle public XarEntry(LocalDocumentReference reference, String name, int defaultAction)
82    {
83  7613 super(reference);
84   
85  7613 this.entryName = name;
86    }
87   
88    /**
89    * @return the name of the entry in the ZIP (XAR) package
90    */
 
91  1340 toggle public String getEntryName()
92    {
93  1340 return this.entryName;
94    }
95   
96    /**
97    * @return the default action associated to the entry
98    */
 
99  2435 toggle public int getDefaultAction()
100    {
101  2435 return this.defaultAction;
102    }
103   
104    /**
105    * @return the space of the document
106    * @deprecated since 7.2M1, does not make much sense anymore with nested space
107    */
 
108  0 toggle @Deprecated
109    @Transient
110    public String getSpaceName()
111    {
112  0 return TOSTRING_SERIALIZER.serialize(extractReference(EntityType.SPACE));
113    }
114   
115    /**
116    * @return the name of the document
117    */
 
118  0 toggle @Transient
119    public String getDocumentName()
120    {
121  0 return getName();
122    }
123   
 
124  0 toggle @Override
125    public String toString()
126    {
127  0 StringBuilder str = new StringBuilder(super.toString());
128   
129  0 if (getEntryName() != null) {
130  0 str.append(' ');
131  0 str.append('(');
132  0 str.append(getEntryName());
133  0 str.append(')');
134    }
135   
136  0 return str.toString();
137    }
138    }