org.vfny.geoserver.config.StyleConfig Maven / Gradle / Ivy
/* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
* This code is licensed under the GPL 2.0 license, availible at the root
* application directory.
*/
package org.vfny.geoserver.config;
import org.vfny.geoserver.global.dto.StyleDTO;
import java.io.File;
/**
* StyleConfig purpose.
*
*
* Defines the style ids to be used by the wms.
* The files must be contained in geoserver/misc/wms/styles.
* We're working on finding a better place for them,
* but for now that's where you must put them if you want them
* on the server.
*
*
* @author dzwiers, Refractions Research, Inc.
* @version $Id: StyleConfig.java 6326 2007-03-15 18:36:40Z jdeolive $
*/
public class StyleConfig {
/** The syle id. */
private String id = "";
/** The file which contains more information about the style. */
private File filename = null;
/** whether this is the system's default style. */
private boolean _default = false;
/**
* StyleConfig constructor.
*
*
* Creates a StyleConfig to represent an instance with default data.
*
*
* @see defaultSettings()
*/
public StyleConfig() {
id = "";
filename = null;
_default = false;
}
/**
* Simple copy constructor.
*
* Used to duplicate a StyleConfig during editing.
*
* @param style StyleConfig to copy
*/
public StyleConfig(StyleConfig style) {
if (style == null) {
throw new NullPointerException("Non null StyleConfig required");
}
id = style.getId();
filename = new File(style.getFilename().toString());
_default = style.isDefault();
}
/**
* StyleConfig constructor.
*
*
* Creates a copy of the StyleDTO provided. All the data structures are
* cloned.
*
*
* @param style The style to copy.
*
* @throws NullPointerException DOCUMENT ME!
*/
public StyleConfig(StyleDTO style) {
if (style == null) {
throw new NullPointerException("Non null StyleDTO required");
}
id = style.getId();
filename = new File(style.getFilename().toString());
_default = style.isDefault();
}
/**
* Implement loadDTO.
*
*
* Stores the data provided for the specified StyleDTO object
*
*
* @param obj a StyleDTO object
*
* @throws NullPointerException DOCUMENT ME!
*
* @see org.vfny.geoserver.config.DataStructure#loadDTO(java.lang.Object)
*/
public void update(StyleDTO obj) {
if (obj == null) {
throw new NullPointerException("Style Data Transfer Object required");
}
StyleDTO sDto = (StyleDTO) obj;
id = sDto.getId();
filename = new File(sDto.getFilename().toString());
_default = sDto.isDefault();
}
/**
* Implement toDTO.
*
*
* Creates a StyleDTO which represents the data in this config object.
*
*
* @return a copy of this classes data in a StyleDTO object.
*
* @see org.vfny.geoserver.config.DataStructure#toDTO()
*/
public StyleDTO toDTO() {
StyleDTO sDto = new StyleDTO();
sDto.setDefault(_default);
sDto.setFilename(new File(filename.toString()));
sDto.setId(id);
return sDto;
}
/**
* isDefault purpose.
*
*
* Description ...
*
*
* @return
*/
public boolean isDefault() {
return _default;
}
/**
* getFilename purpose.
*
*
* Description ...
*
*
* @return
*/
public File getFilename() {
return filename;
}
/**
* getId purpose.
*
*
* Description ...
*
*
* @return
*/
public String getId() {
return id;
}
/**
* setDefault purpose.
*
*
* Description ...
*
*
* @param b
*/
public void setDefault(boolean b) {
_default = b;
}
/**
* setFilename purpose.
*
*
* Description ...
*
*
* @param file
*/
public void setFilename(File file) {
filename = file;
}
/**
* setId purpose.
*
*
* Description ...
*
*
* @param string
*/
public void setId(String string) {
id = string;
}
}