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

File LocalDocumentReference.java

 

Coverage histogram

../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

0
15
10
1
151
52
10
0.67
1.5
10
1

Classes

Class Line # Actions
LocalDocumentReference 32 15 0% 10 0
1.0100%
 

Contributing tests

This file is covered by 224 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.model.reference;
21   
22    import java.util.Locale;
23   
24    import org.xwiki.model.EntityType;
25   
26    /**
27    * Represents a reference to a document in the current wiki.
28    *
29    * @version $Id: c836395a74397b907fe06bb6b5ad69475e921b90 $
30    * @since 5.0M1
31    */
 
32    public class LocalDocumentReference extends EntityReference
33    {
34    /**
35    * Create a new Document reference in the current wiki.
36    *
37    * @param spaceName the name of the space containing the document, must not be null
38    * @param pageName the name of the document, must not be null
39    */
 
40  6278 toggle public LocalDocumentReference(String spaceName, String pageName)
41    {
42  6278 super(pageName, EntityType.DOCUMENT, new EntityReference(spaceName, EntityType.SPACE));
43    }
44   
45    /**
46    * Create a new Document reference in the current wiki.
47    *
48    * @param spaceNames an ordered list of the names of the spaces containing the document from root space to last one,
49    * must not be null
50    * @param pageName the name of the document
51    * @since 7.3M1
52    */
 
53  141 toggle public LocalDocumentReference(Iterable<String> spaceNames, String pageName)
54    {
55  141 super(pageName, EntityType.DOCUMENT, constructSpaceReference(spaceNames));
56    }
57   
58    /**
59    * Create a new Document reference in the current wiki.
60    *
61    * @param spaceName the name of the space containing the document, must not be null
62    * @param pageName the name of the document, must not be null
63    * @param locale the new locale for this reference
64    * @since 5.3RC1
65    */
 
66  14 toggle public LocalDocumentReference(String spaceName, String pageName, Locale locale)
67    {
68  14 super(pageName, EntityType.DOCUMENT, new EntityReference(spaceName, EntityType.SPACE));
69   
70  14 setLocale(locale);
71    }
72   
73    /**
74    * @param documentReference the full document reference
75    * @since 5.2M2
76    */
 
77  884 toggle public LocalDocumentReference(DocumentReference documentReference)
78    {
79  884 super(documentReference, documentReference.getWikiReference(), null);
80    }
81   
82    /**
83    * @param reference the reference to clone
84    * @since 5.4RC1
85    */
 
86  7613 toggle public LocalDocumentReference(EntityReference reference)
87    {
88  7613 super(reference);
89    }
90   
91    /**
92    * @param entityReference the reference
93    * @param locale the new locale for this reference, if null, locale is removed
94    * @since 5.3RC1
95    */
 
96  18415 toggle public LocalDocumentReference(EntityReference entityReference, Locale locale)
97    {
98  18415 super(entityReference);
99   
100  18415 setLocale(locale);
101    }
102   
103    /**
104    * Create a new Document reference in the current wiki.
105    *
106    * @param pageName the name of the document, must not be null
107    * @param spaceReference the reference of the space, must not be null
108    * @since 7.2M1
109    */
 
110  6343 toggle public LocalDocumentReference(String pageName, EntityReference spaceReference)
111    {
112  6343 super(pageName, EntityType.DOCUMENT, spaceReference);
113    }
114   
115    /**
116    * Create a relative space reference in from a list of space names.
117    *
118    * @param spaceNames the list of space name from root to child
119    * @return the space reference
120    */
 
121  141 toggle private static EntityReference constructSpaceReference(Iterable<String> spaceNames)
122    {
123  141 EntityReference spaceReference = null;
124   
125  141 for (String spaceName : spaceNames) {
126  283 spaceReference = new EntityReference(spaceName, EntityType.SPACE, spaceReference);
127    }
128   
129  141 return spaceReference;
130    }
131   
132    /**
133    * @return the locale of this document reference
134    * @since 5.3RC1
135    */
 
136  943 toggle public Locale getLocale()
137    {
138  943 return (Locale) getParameter(DocumentReference.LOCALE);
139    }
140   
141    /**
142    * Set the locale of this document reference.
143    *
144    * @since 5.3RC1
145    * @param locale the locale of this document reference
146    */
 
147  18429 toggle protected void setLocale(Locale locale)
148    {
149  18429 setParameter(DocumentReference.LOCALE, locale);
150    }
151    }