/* Package GeoTools/WMS Implementation
* Copyright (C) 2001 Cameron Shorter (camerons@users.sourceforge.net)
* Artur Hefczyc (kobit@users.sourceforge.net)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id: WMSFormat.java,v 1.6 2002/01/31 10:20:33 ianturton Exp $
* $Author: ianturton $
* $Date: 2002/01/31 10:20:33 $
*/
package uk.ac.leeds.ccg.ogc;
import uk.ac.leeds.ccg.ogc.*;
/**
* Describe class WMSFormat
here.
*
* @author Artur Hefczyc
* @version $Revision: 1.6 $
*/
public class WMSFormat {
/**
* Variable sFormat
contains identyfication
* string returned by the WebMapService
*/
protected String sFormat = null;
/**
* Variable iFormat
contains internal
* GeoTools/ogc constant to ease identify format.
* Format constants are defined in OGCConstants
* @see OGCConstants
*/
protected int iFormat = 0;
/**
*/
public WMSFormat()
{}
public WMSFormat(String format) {
setFormat(format);
}
public WMSFormat(int format) {
setFormat(format);
}
public void setFormat(String format) {
iFormat = 0;
sFormat = format;
for(int i = 1; i < OGCConstants.MAP_FORMATS.length; i++){
if(OGCConstants.MAP_FORMAT_DESCRIPTION[i].equals(sFormat)) {
iFormat = i;
break;
}
}
if(iFormat!=0) return;
for(int i = 1; i < OGCConstants.MAP_FORMATS.length; i++){
String type = OGCConstants.MAP_FORMATS[i];
int in = type.indexOf('/');
if(in==-1) continue;
String form = type.substring(in+1);
if(form.equalsIgnoreCase(sFormat)) {
iFormat = i;
sFormat = type;
break;
}
}
}
public void setFormat(int format) {
iFormat = format;
sFormat = OGCConstants.MAP_FORMATS[iFormat];
}
public void setFormat(String str_format, int int_format)
throws IllegalArgumentException {
if(!OGCConstants.MAP_FORMATS[int_format].equals(str_format))
throw new IllegalArgumentException("String format is not consent with int format.");
sFormat = str_format;
iFormat = int_format;
}
public String toString() {
return sFormat;
}
public String getFormatStr() {
return OGCConstants.MAP_FORMATS[iFormat];
}
public int getFormatInt() {
return iFormat;
}
public String getFormatExtension() {
int idx = sFormat.indexOf("/");
if(idx == -1) return sFormat;
else return sFormat.substring(idx+1);
}
}
/*
* Changes in file:
*
* $Log: WMSFormat.java,v $
* Revision 1.6 2002/01/31 10:20:33 ianturton
* modified setFormat(String name) to handle new formats better added new
* format style names to constants
*
* Revision 1.5 2001/12/20 15:27:23 ianturton
* various fixes and small mods to make WMSExample actually run. Can now
* display an image if you remember to choose gif or jpg as output. Still
* crashes if you zoom in.
*
* Revision 1.4 2001/10/24 09:40:18 kobit
* Added LOG cvs keyword to the end of file
*
*
*/