001/* 002 * (C) Copyright 2006-2007 Nuxeo SAS <http://nuxeo.com> and others 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the Eclipse Public License v1.0 006 * which accompanies this distribution, and is available at 007 * http://www.eclipse.org/legal/epl-v10.html 008 * 009 * Contributors: 010 * Jean-Marc Orliaguet, Chalmers 011 * 012 * $Id$ 013 */ 014 015package org.nuxeo.theme.formats; 016 017import java.util.Enumeration; 018import java.util.Properties; 019 020import org.nuxeo.theme.relations.Predicate; 021 022public class DefaultFormat implements Format { 023 024 private String description; 025 026 private FormatType formatType; 027 028 private Properties properties = new Properties(); 029 030 private Integer uid; 031 032 private String name; 033 034 private boolean remote = false; 035 036 private boolean customized = false; 037 038 private boolean external; 039 040 public Integer getUid() { 041 return uid; 042 } 043 044 public void setUid(final Integer uid) { 045 this.uid = uid; 046 } 047 048 public String hash() { 049 if (uid == null) { 050 return null; 051 } 052 return uid.toString(); 053 } 054 055 public Predicate getPredicate() { 056 return formatType.getPredicate(); 057 } 058 059 public FormatType getFormatType() { 060 return formatType; 061 } 062 063 public void setFormatType(final FormatType formatType) { 064 this.formatType = formatType; 065 } 066 067 public String getName() { 068 return name; 069 } 070 071 public void setName(final String name) { 072 this.name = name; 073 } 074 075 /* Properties */ 076 077 public String getProperty(final String key) { 078 return properties.getProperty(key); 079 } 080 081 public void setProperty(final String key, final String value) { 082 properties.setProperty(key, value); 083 } 084 085 public Enumeration<?> getPropertyNames() { 086 return properties.propertyNames(); 087 } 088 089 public boolean hasProperties() { 090 return !properties.isEmpty(); 091 } 092 093 public Properties getProperties() { 094 return properties; 095 } 096 097 public void setProperties(final Properties properties) { 098 this.properties = properties; 099 } 100 101 public String getDescription() { 102 return description; 103 } 104 105 public void setDescription(final String description) { 106 this.description = description; 107 } 108 109 public void clonePropertiesOf(final Format source) { 110 Properties sourceProperties = source.getProperties(); 111 for (Object key : sourceProperties.keySet()) { 112 String propertyName = (String) key; 113 setProperty(propertyName, sourceProperties.getProperty(propertyName)); 114 } 115 } 116 117 public boolean isNamed() { 118 return false; 119 } 120 121 public boolean isRemote() { 122 return remote; 123 } 124 125 public void setRemote(boolean remote) { 126 this.remote = remote; 127 } 128 129 public boolean isCustomized() { 130 return customized; 131 } 132 133 public void setCustomized(boolean customized) { 134 this.customized = customized; 135 } 136 137 public void setExternal(boolean external) { 138 this.external = external; 139 } 140 141 public boolean isExternal() { 142 return external; 143 } 144}