1 package org.springframework.samples.imagedb; 2 3 import org.springframework.util.Assert; 4 5 11 public class ImageDescriptor { 12 13 public static final int SHORT_DESCRIPTION_MAX_LENGTH = 1000; 14 15 private final String name; 16 17 private final String description; 18 19 protected ImageDescriptor(String name, String description) { 20 Assert.notNull(name, "No image name specified"); 21 this.name = name; 22 this.description = (description != null ? description : ""); 23 } 24 25 public String getName() { 26 return name; 27 } 28 29 public String getDescription() { 30 return description; 31 } 32 33 public String getShortDescription() { 34 return (description == null || description.length() <= SHORT_DESCRIPTION_MAX_LENGTH) ? 35 description : description.substring(0, SHORT_DESCRIPTION_MAX_LENGTH); 36 } 37 38 public int getDescriptionLength() { 39 return (description != null ? description.length() : 0); 40 } 41 42 } 43 | Popular Tags |