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

File TargetDocumentDescriptor.java

 

Coverage histogram

../../../../img/srcFileCovDistChart4.png
78% of files have more coverage

Code metrics

4
15
8
1
125
55
11
0.73
1.88
8
1.38

Classes

Class Line # Actions
TargetDocumentDescriptor 33 15 0% 11 17
0.3703703637%
 

Contributing tests

This file is covered by 1 test. .

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.officeimporter.splitter;
21   
22    import org.xwiki.component.manager.ComponentLookupException;
23    import org.xwiki.component.manager.ComponentManager;
24    import org.xwiki.model.reference.DocumentReference;
25    import org.xwiki.model.reference.EntityReferenceSerializer;
26   
27    /**
28    * Descriptor for specifying a reference to the document into which an office document is going to be saved.
29    *
30    * @version $Id: 769ff621a462d6f3a2101b831f00bb4de19bda31 $
31    * @since 2.2M1
32    */
 
33    public class TargetDocumentDescriptor
34    {
35    /**
36    * Target document reference.
37    */
38    private final DocumentReference documentReference;
39   
40    /**
41    * The object used to serialize entity references.
42    */
43    private EntityReferenceSerializer<String> serializer;
44   
45    /**
46    * Parent document reference.
47    */
48    private DocumentReference parentReference;
49   
50    /**
51    * Creates a new {@link TargetDocumentDescriptor} instance.
52    *
53    * @param documentReference reference of the target document
54    * @param componentManager used to lookup the entity reference serializer
55    */
 
56  5 toggle public TargetDocumentDescriptor(DocumentReference documentReference, ComponentManager componentManager)
57    {
58  5 this.documentReference = documentReference;
59  5 try {
60  5 this.serializer = componentManager.getInstance(EntityReferenceSerializer.TYPE_STRING);
61    } catch (ComponentLookupException e) {
62    // Shouldn't happen.
63  0 this.serializer = null;
64    }
65    }
66   
67    /**
68    * @return target document reference name.
69    */
 
70  5 toggle public DocumentReference getDocumentReference()
71    {
72  5 return this.documentReference;
73    }
74   
75    /**
76    * @return target document reference as a string.
77    */
 
78  0 toggle public String getDocumentReferenceAsString()
79    {
80  0 return serializer.serialize(getDocumentReference());
81    }
82   
83    /**
84    * @return target parent document reference
85    */
 
86  0 toggle public DocumentReference getParentReference()
87    {
88  0 return this.parentReference;
89    }
90   
91    /**
92    * @return name of the parent document reference
93    */
 
94  0 toggle public String getParentReferenceAsString()
95    {
96  0 return (null != getParentReference()) ? serializer.serialize(getParentReference()) : null;
97    }
98   
99    /**
100    * Sets the name of the parent document reference.
101    *
102    * @param parentReference parent document reference
103    */
 
104  4 toggle public void setParentReference(DocumentReference parentReference)
105    {
106  4 this.parentReference = parentReference;
107    }
108   
 
109  0 toggle @Override
110    public boolean equals(Object obj)
111    {
112  0 boolean equals = false;
113  0 if (obj instanceof TargetDocumentDescriptor) {
114  0 TargetDocumentDescriptor other = (TargetDocumentDescriptor) obj;
115  0 equals = other.getDocumentReference().equals(getDocumentReference());
116    }
117  0 return equals;
118    }
119   
 
120  5 toggle @Override
121    public int hashCode()
122    {
123  5 return getDocumentReference().hashCode();
124    }
125    }