EMMA Coverage Report (generated Wed Oct 26 13:47:17 EDT 2011)
[all classes][org.jclouds.ovf]

COVERAGE SUMMARY FOR SOURCE FILE [Disk.java]

nameclass, %method, %block, %line, %
Disk.java100% (2/2)57%  (13/23)59%  (141/240)56%  (30.9/55)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Disk100% (1/1)31%  (4/13)53%  (85/161)39%  (14.9/38)
compareTo (Disk): int 0%   (0/1)0%   (0/16)0%   (0/3)
equals (Object): boolean 0%   (0/1)0%   (0/37)0%   (0/13)
getCapacity (): Long 0%   (0/1)0%   (0/3)0%   (0/1)
getCapacityAllocationUnits (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getFileRef (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getFormat (): URI 0%   (0/1)0%   (0/3)0%   (0/1)
getId (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getParentRef (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getPopulatedSize (): Long 0%   (0/1)0%   (0/3)0%   (0/1)
hashCode (): int 100% (1/1)89%  (17/19)97%  (3.9/4)
Disk (String, Long, String, String, URI, Long, String): void 100% (1/1)100% (24/24)100% (9/9)
builder (): Disk$Builder 100% (1/1)100% (4/4)100% (1/1)
toString (): String 100% (1/1)100% (40/40)100% (1/1)
     
class Disk$Builder100% (1/1)90%  (9/10)71%  (56/79)94%  (16/17)
fromDisk (Disk): Disk$Builder 0%   (0/1)0%   (0/23)0%   (0/1)
Disk$Builder (): void 100% (1/1)100% (3/3)100% (1/1)
build (): Disk 100% (1/1)100% (18/18)100% (1/1)
capacity (Long): Disk$Builder 100% (1/1)100% (5/5)100% (2/2)
capacityAllocationUnits (String): Disk$Builder 100% (1/1)100% (5/5)100% (2/2)
fileRef (String): Disk$Builder 100% (1/1)100% (5/5)100% (2/2)
format (URI): Disk$Builder 100% (1/1)100% (5/5)100% (2/2)
id (String): Disk$Builder 100% (1/1)100% (5/5)100% (2/2)
parentRef (String): Disk$Builder 100% (1/1)100% (5/5)100% (2/2)
populatedSize (Long): Disk$Builder 100% (1/1)100% (5/5)100% (2/2)

1/**
2 * Licensed to jclouds, Inc. (jclouds) under one or more
3 * contributor license agreements.  See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership.  jclouds licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License.  You may obtain a copy of the License at
9 *
10 *   http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied.  See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19package org.jclouds.ovf;
20 
21import java.net.URI;
22 
23/**
24 * 
25 * @author Adrian Cole
26 */
27public class Disk implements Comparable<Disk>{
28   public static Builder builder() {
29      return new Builder();
30   }
31 
32   public static class Builder {
33      private String id;
34      private Long capacity;
35      private String parentRef;
36      private String fileRef;
37      private URI format;
38      private Long populatedSize;
39      private String capacityAllocationUnits;
40 
41      /**
42       * @see Disk#getId
43       */
44      public Builder id(String id) {
45         this.id = id;
46         return this;
47      }
48 
49      /**
50       * @see Disk#getCapacity
51       */
52      public Builder capacity(Long capacity) {
53         this.capacity = capacity;
54         return this;
55      }
56 
57      /**
58       * @see Disk#getParentRef
59       */
60      public Builder parentRef(String parentRef) {
61         this.parentRef = parentRef;
62         return this;
63      }
64 
65      /**
66       * @see Disk#getFileRef
67       */
68      public Builder fileRef(String fileRef) {
69         this.fileRef = fileRef;
70         return this;
71      }
72 
73      /**
74       * @see Disk#getFormat
75       */
76      public Builder format(URI format) {
77         this.format = format;
78         return this;
79      }
80 
81      /**
82       * @see Disk#getPopulatedSize
83       */
84      public Builder populatedSize(Long populatedSize) {
85         this.populatedSize = populatedSize;
86         return this;
87      }
88 
89      /**
90       * @see Disk#getCapacityAllocationUnits
91       */
92      public Builder capacityAllocationUnits(String capacityAllocationUnits) {
93         this.capacityAllocationUnits = capacityAllocationUnits;
94         return this;
95      }
96 
97      public Disk build() {
98         return new Disk(id, capacity, parentRef, fileRef, format, populatedSize, capacityAllocationUnits);
99      }
100 
101      public Builder fromDisk(Disk in) {
102         return id(in.getId()).capacity(in.getCapacity()).parentRef(in.getParentRef()).fileRef(in.getFileRef()).format(
103                  in.getFormat()).populatedSize(in.getPopulatedSize()).capacityAllocationUnits(
104                  in.getCapacityAllocationUnits());
105      }
106   }
107 
108   private final String id;
109   private final Long capacity;
110   private final String parentRef;
111   private final String fileRef;
112   private final URI format;
113   private final Long populatedSize;
114   private final String capacityAllocationUnits;
115 
116   public Disk(String id, Long capacity, String parentRef, String fileRef, URI format, Long populatedSize,
117            String capacityAllocationUnits) {
118      this.id = id;
119      this.capacity = capacity;
120      this.parentRef = parentRef;
121      this.fileRef = fileRef;
122      this.format = format;
123      this.populatedSize = populatedSize;
124      this.capacityAllocationUnits = capacityAllocationUnits;
125   }
126 
127   /**
128    * Each virtual disk is represented by a Disk element that shall be given a identifier using the
129    * {@code id} attribute, the identifier shall be unique within the {@link DiskSection}.
130    */
131   public String getId() {
132      return id;
133   }
134 
135   /**
136    * The capacity of a virtual disk shall be specified by the {@code capacity} attribute with an
137    * xs:long integer value. The default unit of allocation shall be bytes.
138    */
139   public Long getCapacity() {
140      return capacity;
141   }
142 
143   /**
144    * OVF allows a disk image to be represented as a set of modified blocks in comparison to a
145    * parent image. The use of parent disks can often significantly reduce the size of an OVF
146    * package, if it contains multiple disks with similar content. For a Disk element, a parent disk
147    * may optionally be specified using the {@code parentRef} attribute, which shall contain a valid
148    * ovf:id reference to a different Disk element. If a disk block does not exist locally, lookup
149    * for that disk block then occurs in the parent disk. In {@link DiskSection}, parent Disk
150    * elements shall occur before child Disk elements that refer to them.
151    */
152   public String getParentRef() {
153      return parentRef;
154   }
155 
156   /**
157    * The ovf:fileRef attribute denotes the virtual disk content by identifying an existing File
158    * element in the References element, the File element is identified by matching its {@code id}
159    * attribute value with the {@code fileRef} attribute value. Omitting the {@code fileRef}
160    * attribute shall indicate an empty disk. In this case, the disk shall be created and the entire
161    * disk content zeroed at installation time. The guest software will typically format empty disks
162    * in some file system format.
163    */
164   public String getFileRef() {
165      return fileRef;
166   }
167 
168   /**
169    * The format URI of a non-empty virtual disk shall be specified by the {@code format} attribute.
170    */
171   public URI getFormat() {
172      return format;
173   }
174 
175   /**
176    * For non-empty disks, the actual used size of the disk may optionally be specified using the
177    * {@code populatedSize} attribute. The unit of this attribute is always bytes. {@code
178    * populatedSize} is allowed to be an estimate of used disk size but shall not be larger than
179    * {@code capacity}.
180    */
181   public Long getPopulatedSize() {
182      return populatedSize;
183   }
184 
185   /**
186    * The optional string attribute {@code ovf:capacityAllocationUnits} may be used to specify a
187    * particular unit of allocation. Values for {@code ovf:capacityAllocationUnits} shall match the
188    * format for programmatic units defined in DSP0004.
189    */
190   public String getCapacityAllocationUnits() {
191      return capacityAllocationUnits;
192   }
193 
194   @Override
195   public int hashCode() {
196      final int prime = 31;
197      int result = 1;
198      result = prime * result + ((id == null) ? 0 : id.hashCode());
199      return result;
200   }
201 
202   @Override
203   public boolean equals(Object obj) {
204      if (this == obj)
205         return true;
206      if (obj == null)
207         return false;
208      if (getClass() != obj.getClass())
209         return false;
210      Disk other = (Disk) obj;
211      if (id == null) {
212         if (other.id != null)
213            return false;
214      } else if (!id.equals(other.id))
215         return false;
216      return true;
217   }
218 
219   @Override
220   public String toString() {
221      return String
222               .format(
223                        "[id=%s, capacity=%s, capacityAllocationUnits=%s, fileRef=%s, format=%s, parentRef=%s, populatedSize=%s]",
224                        id, capacity, capacityAllocationUnits, fileRef, format, parentRef, populatedSize);
225   }
226 
227   /**
228    * {@inheritDoc}
229    */
230   @Override
231   public int compareTo(Disk o) {
232      if (id == null)
233         return -1;
234      return (this == o) ? 0 : id.compareTo(o.id);
235   }
236}

[all classes][org.jclouds.ovf]
EMMA 2.0.5312 (C) Vladimir Roubtsov