Updates SettingsManager to use jackson xml serialization. Final

testing on all changes to xml serialization.
This commit is contained in:
Denny
2017-12-21 19:59:11 -05:00
parent 1d2d9e8630
commit 26b97f09b7
21 changed files with 469 additions and 433 deletions

View File

@@ -313,9 +313,12 @@ public class Channel extends Configuration implements Listener<FrequencyChangeEv
* Sets the primary decoder configuration used by this channel * Sets the primary decoder configuration used by this channel
*/ */
public void setDecodeConfiguration(DecodeConfiguration config) public void setDecodeConfiguration(DecodeConfiguration config)
{
if(config != null)
{ {
mDecodeConfiguration = config; mDecodeConfiguration = config;
} }
}
/** /**
* Gets the aux decoder configuration used by this channel. Aux decoders * Gets the aux decoder configuration used by this channel. Aux decoders
@@ -331,9 +334,12 @@ public class Channel extends Configuration implements Listener<FrequencyChangeEv
* Sets the decoder configuration used by this channel * Sets the decoder configuration used by this channel
*/ */
public void setAuxDecodeConfiguration(AuxDecodeConfiguration config) public void setAuxDecodeConfiguration(AuxDecodeConfiguration config)
{
if(config != null)
{ {
mAuxDecodeConfiguration = config; mAuxDecodeConfiguration = config;
} }
}
/** /**
* Returns the source configuration for this channel. A channel source * Returns the source configuration for this channel. A channel source
@@ -349,8 +355,11 @@ public class Channel extends Configuration implements Listener<FrequencyChangeEv
* Sets the source configuration for this channel. * Sets the source configuration for this channel.
*/ */
public void setSourceConfiguration(SourceConfiguration config) public void setSourceConfiguration(SourceConfiguration config)
{
if(config != null)
{ {
mSourceConfiguration = config; mSourceConfiguration = config;
}
//Clear the tune channel object so that it can be recreated if the //Clear the tune channel object so that it can be recreated if the
//source configuration changes //source configuration changes
@@ -370,9 +379,12 @@ public class Channel extends Configuration implements Listener<FrequencyChangeEv
* Sets the event logger configuration for this channel. * Sets the event logger configuration for this channel.
*/ */
public void setEventLogConfiguration(EventLogConfiguration config) public void setEventLogConfiguration(EventLogConfiguration config)
{
if(config != null)
{ {
mEventLogConfiguration = config; mEventLogConfiguration = config;
} }
}
/** /**
* Returns the recorder configuration for this channel. * Returns the recorder configuration for this channel.
@@ -387,9 +399,12 @@ public class Channel extends Configuration implements Listener<FrequencyChangeEv
* Sets the recorder configuration for this channel. * Sets the recorder configuration for this channel.
*/ */
public void setRecordConfiguration(RecordConfiguration config) public void setRecordConfiguration(RecordConfiguration config)
{
if(config != null)
{ {
mRecordConfiguration = config; mRecordConfiguration = config;
} }
}
/** /**
* Convenience method to construct a tuner channel object representing a * Convenience method to construct a tuner channel object representing a

View File

@@ -1,38 +1,40 @@
/******************************************************************************* /*
* SDR Trunk * *********************************************************************************************************************
* Copyright (C) 2014 Dennis Sheirer * sdrtrunk
* Copyright (C) 2014-2017 Dennis Sheirer
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* it under the terms of the GNU General Public License as published by * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* the Free Software Foundation, either version 3 of the License, or * later version.
* (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* but WITHOUT ANY WARRANTY; without even the implied warranty of * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* 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 * You should have received a copy of the GNU General Public License along with this program.
* along with this program. If not, see <http://www.gnu.org/licenses/> * If not, see <http://www.gnu.org/licenses/>
******************************************************************************/ * *********************************************************************************************************************
*/
package io.github.dsheirer.map; package io.github.dsheirer.map;
import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import io.github.dsheirer.settings.Setting; import io.github.dsheirer.settings.Setting;
import io.github.dsheirer.settings.SettingType;
@JsonSubTypes.Type(value = DefaultIcon.class, name = "defaultIcon")
public class DefaultIcon extends Setting public class DefaultIcon extends Setting
{ {
public DefaultIcon( String name ) public DefaultIcon(String name)
{ {
super( name ); super(name);
} }
/**
* Don't use this constructor. This is used by JAXB to unmarshall saved
* map icons.
*/
public DefaultIcon() public DefaultIcon()
{ {
} }
@JacksonXmlProperty(isAttribute = true, localName = "type", namespace = "http://www.w3.org/2001/XMLSchema-instance")
@Override
public SettingType getType()
{
return SettingType.DEFAULT_ICON;
}
} }

View File

@@ -18,20 +18,26 @@
package io.github.dsheirer.map; package io.github.dsheirer.map;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import io.github.dsheirer.settings.Setting; import io.github.dsheirer.settings.Setting;
import io.github.dsheirer.settings.SettingType;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@JsonSubTypes.Type(value = MapIcon.class, name = "mapIcon")
public class MapIcon extends Setting implements Comparable<MapIcon> public class MapIcon extends Setting implements Comparable<MapIcon>
{ {
private static final int sMAX_IMAGE_DIMENSION = 48; private static final int sMAX_IMAGE_DIMENSION = 48;
private String mPath; private String mPath;
private ImageIcon mImageIcon; private ImageIcon mImageIcon;
@JacksonXmlProperty(isAttribute = true, localName = "type", namespace = "http://www.w3.org/2001/XMLSchema-instance")
@Override
public SettingType getType()
{
return SettingType.MAP_ICON;
}
/** /**
* Only map icons created at runtime can be marked as non-editable, and * Only map icons created at runtime can be marked as non-editable, and
* therefore this property is transient. * therefore this property is transient.
@@ -91,6 +97,7 @@ public class MapIcon extends Setting implements Comparable<MapIcon>
mDefaultIcon = isDefault; mDefaultIcon = isDefault;
} }
@JsonIgnore
public ImageIcon getImageIcon() public ImageIcon getImageIcon()
{ {
if(mImageIcon == null) if(mImageIcon == null)

View File

@@ -106,7 +106,7 @@ public class SystemProperties
} }
catch (Exception e) catch (Exception e)
{ {
mLog.error("Couldn't load jar manifest - probably not running from a jar release"); mLog.error("Unable to load jar manifest - we're probably not running from a release jar");
} }
return null; return null;

View File

@@ -17,17 +17,13 @@
******************************************************************************/ ******************************************************************************/
package io.github.dsheirer.record.config; package io.github.dsheirer.record.config;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import io.github.dsheirer.controller.config.Configuration; import io.github.dsheirer.controller.config.Configuration;
import io.github.dsheirer.record.RecorderType; import io.github.dsheirer.record.RecorderType;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@JsonSubTypes.Type(value = RecordConfiguration.class, name = "recordConfiguration")
@JacksonXmlRootElement(localName = "record_configuration")
public class RecordConfiguration extends Configuration public class RecordConfiguration extends Configuration
{ {
private List<RecorderType> mRecorders = new ArrayList<>(); private List<RecorderType> mRecorders = new ArrayList<>();

View File

@@ -18,12 +18,10 @@
package io.github.dsheirer.settings; package io.github.dsheirer.settings;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import java.awt.*; import java.awt.*;
@JsonSubTypes.Type(value = ColorSetting.class, name = "colorSetting")
public class ColorSetting extends Setting public class ColorSetting extends Setting
{ {
private static final int NO_TRANSLUCENCY = 255; private static final int NO_TRANSLUCENCY = 255;
@@ -45,6 +43,13 @@ public class ColorSetting extends Setting
setColorSettingName(name); setColorSettingName(name);
} }
@JacksonXmlProperty(isAttribute = true, localName = "type", namespace = "http://www.w3.org/2001/XMLSchema-instance")
@Override
public SettingType getType()
{
return SettingType.COLOR_SETTING;
}
@JacksonXmlProperty(isAttribute = true, localName = "colorSettingName") @JacksonXmlProperty(isAttribute = true, localName = "colorSettingName")
public ColorSettingName getColorSettingName() public ColorSettingName getColorSettingName()
{ {

View File

@@ -1,28 +1,26 @@
/******************************************************************************* /*
* SDR Trunk * *********************************************************************************************************************
* Copyright (C) 2014 Dennis Sheirer * sdrtrunk
* Copyright (C) 2014-2017 Dennis Sheirer
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* it under the terms of the GNU General Public License as published by * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* the Free Software Foundation, either version 3 of the License, or * later version.
* (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* but WITHOUT ANY WARRANTY; without even the implied warranty of * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* 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 * You should have received a copy of the GNU General Public License along with this program.
* along with this program. If not, see <http://www.gnu.org/licenses/> * If not, see <http://www.gnu.org/licenses/>
******************************************************************************/ * *********************************************************************************************************************
*/
package io.github.dsheirer.settings; package io.github.dsheirer.settings;
import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import java.io.File; import java.io.File;
@JsonSubTypes.Type(value = FileSetting.class, name = "fileSetting")
public class FileSetting extends Setting public class FileSetting extends Setting
{ {
private String mPath; private String mPath;
@@ -38,6 +36,14 @@ public class FileSetting extends Setting
setPath(path); setPath(path);
} }
@JacksonXmlProperty(isAttribute = true, localName = "type", namespace = "http://www.w3.org/2001/XMLSchema-instance")
@Override
public SettingType getType()
{
return SettingType.FILE_SETTING;
}
@JacksonXmlProperty(isAttribute = true, localName = "path")
public String getPath() public String getPath()
{ {
return mPath; return mPath;
@@ -48,6 +54,7 @@ public class FileSetting extends Setting
mPath = value; mPath = value;
} }
@JsonIgnore
public File getFile() public File getFile()
{ {
return new File(mPath); return new File(mPath);

View File

@@ -1,3 +1,20 @@
/*
* *********************************************************************************************************************
* sdrtrunk
* Copyright (C) 2014-2017 Dennis Sheirer
*
* 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 3 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, see <http://www.gnu.org/licenses/>
* *********************************************************************************************************************
*/
package io.github.dsheirer.settings; package io.github.dsheirer.settings;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
@@ -33,6 +50,13 @@ public class MapViewSetting extends Setting
mZoom = zoom; mZoom = zoom;
} }
@JacksonXmlProperty(isAttribute = true, localName = "type", namespace = "http://www.w3.org/2001/XMLSchema-instance")
@Override
public SettingType getType()
{
return SettingType.MAP_VIEW_SETTING;
}
@JacksonXmlProperty(isAttribute = true, localName = "latitude") @JacksonXmlProperty(isAttribute = true, localName = "latitude")
public double getLatitude() public double getLatitude()
{ {

View File

@@ -1,27 +1,39 @@
/******************************************************************************* /*
* SDR Trunk * *********************************************************************************************************************
* Copyright (C) 2014 Dennis Sheirer * sdrtrunk
* Copyright (C) 2014-2017 Dennis Sheirer
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* it under the terms of the GNU General Public License as published by * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* the Free Software Foundation, either version 3 of the License, or * later version.
* (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* but WITHOUT ANY WARRANTY; without even the implied warranty of * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* 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 * You should have received a copy of the GNU General Public License along with this program.
* along with this program. If not, see <http://www.gnu.org/licenses/> * If not, see <http://www.gnu.org/licenses/>
******************************************************************************/ * *********************************************************************************************************************
*/
package io.github.dsheirer.settings; package io.github.dsheirer.settings;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import io.github.dsheirer.map.DefaultIcon;
import io.github.dsheirer.map.MapIcon;
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "xsi:type") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include= JsonTypeInfo.As.PROPERTY, property="type")
public class Setting @JsonSubTypes({
@JsonSubTypes.Type(value=ColorSetting.class, name="colorSetting"),
@JsonSubTypes.Type(value=DefaultIcon.class, name="defaultIcon"),
@JsonSubTypes.Type(value=FileSetting.class, name="fileSetting"),
@JsonSubTypes.Type(value=MapIcon.class, name="mapIcon"),
@JsonSubTypes.Type(value=MapViewSetting.class, name="mapViewSetting"),
})
@JacksonXmlRootElement( localName = "setting" )
public abstract class Setting
{ {
protected String mName; protected String mName;
@@ -44,4 +56,7 @@ public class Setting
{ {
mName = name; mName = name;
} }
@JsonIgnore
public abstract SettingType getType();
} }

View File

@@ -0,0 +1,28 @@
/*
* *********************************************************************************************************************
* sdrtrunk
* Copyright (C) 2014-2017 Dennis Sheirer
*
* 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 3 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, see <http://www.gnu.org/licenses/>
* *********************************************************************************************************************
*/
package io.github.dsheirer.settings;
public enum SettingType
{
COLOR_SETTING,
DEFAULT_ICON,
FILE_SETTING,
MAP_ICON,
MAP_VIEW_SETTING,
UNKNOWN;
}

View File

@@ -1,22 +1,22 @@
/******************************************************************************* /*
* SDR Trunk * *********************************************************************************************************************
* Copyright (C) 2014-2016 Dennis Sheirer * sdrtrunk
* Copyright (C) 2014-2017 Dennis Sheirer
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* it under the terms of the GNU General Public License as published by * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* the Free Software Foundation, either version 3 of the License, or * later version.
* (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* but WITHOUT ANY WARRANTY; without even the implied warranty of * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* 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 * You should have received a copy of the GNU General Public License along with this program.
* along with this program. If not, see <http://www.gnu.org/licenses/> * If not, see <http://www.gnu.org/licenses/>
******************************************************************************/ * *********************************************************************************************************************
*/
package io.github.dsheirer.settings; package io.github.dsheirer.settings;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import io.github.dsheirer.map.DefaultIcon; import io.github.dsheirer.map.DefaultIcon;
@@ -28,16 +28,14 @@ import io.github.dsheirer.source.tuner.configuration.TunerConfiguration;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@JacksonXmlRootElement( localName = "SDRTrunk_settings" ) @JacksonXmlRootElement(localName = "SDRTrunk_settings")
public class Settings public class Settings
{ {
private List<Setting> mSettings = new ArrayList<Setting>(); private List<Setting> mSettings = new ArrayList<Setting>();
private List<TunerConfiguration> mTunerConfiguration = private List<TunerConfiguration> mTunerConfiguration = new ArrayList<TunerConfiguration>();
new ArrayList<TunerConfiguration>();
private List<RecordingConfiguration> mRecordingConfigurations = private List<RecordingConfiguration> mRecordingConfigurations = new ArrayList<RecordingConfiguration>();
new ArrayList<RecordingConfiguration>();
public Settings() public Settings()
{ {
@@ -49,19 +47,19 @@ public class Settings
return mRecordingConfigurations; return mRecordingConfigurations;
} }
public void setRecordingConfigurations( ArrayList<RecordingConfiguration> configs ) public void setRecordingConfigurations(ArrayList<RecordingConfiguration> configs)
{ {
mRecordingConfigurations = configs; mRecordingConfigurations = configs;
} }
public void addRecordingConfiguration( RecordingConfiguration config ) public void addRecordingConfiguration(RecordingConfiguration config)
{ {
mRecordingConfigurations.add( config ); mRecordingConfigurations.add(config);
} }
public void removeRecordingConfiguration( RecordingConfiguration config ) public void removeRecordingConfiguration(RecordingConfiguration config)
{ {
mRecordingConfigurations.remove( config ); mRecordingConfigurations.remove(config);
} }
@JacksonXmlProperty(isAttribute = false, localName = "tuner_configuration") @JacksonXmlProperty(isAttribute = false, localName = "tuner_configuration")
@@ -70,7 +68,7 @@ public class Settings
return mTunerConfiguration; return mTunerConfiguration;
} }
public void setTunerConfigurations( List<TunerConfiguration> configs ) public void setTunerConfigurations(List<TunerConfiguration> configs)
{ {
mTunerConfiguration = configs; mTunerConfiguration = configs;
} }
@@ -81,16 +79,16 @@ public class Settings
return mSettings; return mSettings;
} }
public void setSettings( ArrayList<Setting> settings ) public void setSettings(ArrayList<Setting> settings)
{ {
mSettings = settings; mSettings = settings;
} }
public Setting getSetting( String name ) public Setting getSetting(String name)
{ {
for( Setting setting: mSettings ) for(Setting setting : mSettings)
{ {
if( setting.getName().contentEquals( name ) ) if(setting.getName().contentEquals(name))
{ {
return setting; return setting;
} }
@@ -99,21 +97,22 @@ public class Settings
return null; return null;
} }
public void addSetting( Setting setting ) public void addSetting(Setting setting)
{ {
mSettings.add( setting ); mSettings.add(setting);
} }
public void removeSetting( Setting setting ) public void removeSetting(Setting setting)
{ {
mSettings.remove( setting ); mSettings.remove(setting);
} }
@JsonIgnore
public DefaultIcon getDefaultIcon() public DefaultIcon getDefaultIcon()
{ {
for( Setting setting: mSettings ) for(Setting setting : mSettings)
{ {
if( setting instanceof DefaultIcon ) if(setting instanceof DefaultIcon)
{ {
return (DefaultIcon)setting; return (DefaultIcon)setting;
} }
@@ -122,12 +121,12 @@ public class Settings
return null; return null;
} }
public ColorSetting getColorSetting( ColorSettingName name ) public ColorSetting getColorSetting(ColorSettingName name)
{ {
for( Setting setting: mSettings ) for(Setting setting : mSettings)
{ {
if( setting instanceof ColorSetting && if(setting instanceof ColorSetting &&
((ColorSetting)setting).getColorSettingName() == name ) ((ColorSetting)setting).getColorSettingName() == name)
{ {
return (ColorSetting)setting; return (ColorSetting)setting;
} }
@@ -136,27 +135,28 @@ public class Settings
return null; return null;
} }
@JsonIgnore
public List<ColorSetting> getColorSettings() public List<ColorSetting> getColorSettings()
{ {
ArrayList<ColorSetting> colors = new ArrayList<ColorSetting>(); ArrayList<ColorSetting> colors = new ArrayList<ColorSetting>();
for( Setting setting: mSettings ) for(Setting setting : mSettings)
{ {
if( setting instanceof ColorSetting ) if(setting instanceof ColorSetting)
{ {
colors.add( (ColorSetting)setting ); colors.add((ColorSetting)setting);
} }
} }
return colors; return colors;
} }
public FileSetting getFileSetting( String name ) public FileSetting getFileSetting(String name)
{ {
for( Setting setting: mSettings ) for(Setting setting : mSettings)
{ {
if( setting instanceof FileSetting && if(setting instanceof FileSetting &&
setting.getName().contentEquals( name ) ) setting.getName().contentEquals(name))
{ {
return (FileSetting)setting; return (FileSetting)setting;
} }
@@ -165,12 +165,12 @@ public class Settings
return null; return null;
} }
public MapIcon getMapIcon( String name ) public MapIcon getMapIcon(String name)
{ {
for( Setting setting: mSettings ) for(Setting setting : mSettings)
{ {
if( setting instanceof MapIcon && if(setting instanceof MapIcon &&
setting.getName().contentEquals( name ) ) setting.getName().contentEquals(name))
{ {
return (MapIcon)setting; return (MapIcon)setting;
} }
@@ -183,23 +183,23 @@ public class Settings
{ {
ArrayList<MapIcon> icons = new ArrayList<MapIcon>(); ArrayList<MapIcon> icons = new ArrayList<MapIcon>();
for( Setting setting: mSettings ) for(Setting setting : mSettings)
{ {
if( setting instanceof MapIcon ) if(setting instanceof MapIcon)
{ {
icons.add( (MapIcon)setting ); icons.add((MapIcon)setting);
} }
} }
return icons; return icons;
} }
public MapViewSetting getMapViewSetting( String name ) public MapViewSetting getMapViewSetting(String name)
{ {
for( Setting setting: mSettings ) for(Setting setting : mSettings)
{ {
if( setting instanceof MapViewSetting && if(setting instanceof MapViewSetting &&
setting.getName().contentEquals( name ) ) setting.getName().contentEquals(name))
{ {
return (MapViewSetting)setting; return (MapViewSetting)setting;
} }

View File

@@ -1,22 +1,25 @@
/******************************************************************************* /*
* SDR Trunk * *********************************************************************************************************************
* Copyright (C) 2014-2016 Dennis Sheirer * sdrtrunk
* Copyright (C) 2014-2017 Dennis Sheirer
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* it under the terms of the GNU General Public License as published by * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* the Free Software Foundation, either version 3 of the License, or * later version.
* (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* but WITHOUT ANY WARRANTY; without even the implied warranty of * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* 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 * You should have received a copy of the GNU General Public License along with this program.
* along with this program. If not, see <http://www.gnu.org/licenses/> * If not, see <http://www.gnu.org/licenses/>
******************************************************************************/ * *********************************************************************************************************************
*/
package io.github.dsheirer.settings; package io.github.dsheirer.settings;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import io.github.dsheirer.properties.SystemProperties; import io.github.dsheirer.properties.SystemProperties;
import io.github.dsheirer.sample.Listener; import io.github.dsheirer.sample.Listener;
import io.github.dsheirer.source.recording.RecordingConfiguration; import io.github.dsheirer.source.recording.RecordingConfiguration;
@@ -27,14 +30,7 @@ import org.jdesktop.swingx.mapviewer.GeoPosition;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import java.awt.*; import java.awt.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@@ -256,11 +252,9 @@ public class SettingsManager implements Listener<TunerConfigurationEvent>
{ {
saveTunerConfigurationModel(); saveTunerConfigurationModel();
JAXBContext context = null;
SystemProperties props = SystemProperties.getInstance(); SystemProperties props = SystemProperties.getInstance();
Path settingsPath = props.getApplicationFolder("settings"); Path settingsFolder = props.getApplicationFolder("settings");
String settingsDefault = props.get("settings.defaultFilename", String settingsDefault = props.get("settings.defaultFilename",
"settings.xml"); "settings.xml");
@@ -268,63 +262,24 @@ public class SettingsManager implements Listener<TunerConfigurationEvent>
String settingsCurrent = props.get("settings.currentFilename", String settingsCurrent = props.get("settings.currentFilename",
settingsDefault); settingsDefault);
Path filePath = settingsPath.resolve(settingsCurrent); Path settingsPath = settingsFolder.resolve(settingsCurrent);
File outputFile = new File(filePath.toString()); try(OutputStream out = Files.newOutputStream(settingsPath))
try
{ {
if(!outputFile.exists()) JacksonXmlModule xmlModule = new JacksonXmlModule();
{ xmlModule.setDefaultUseWrapper(false);
outputFile.createNewFile(); ObjectMapper objectMapper = new XmlMapper(xmlModule);
objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
objectMapper.writeValue(out, mSettings);
out.flush();
} }
catch(IOException ioe)
{
mLog.error("IO error while writing the settings to a file [" + settingsPath + "]", ioe);
} }
catch(Exception e) catch(Exception e)
{ {
mLog.error("SettingsManager - couldn't create file to save " mLog.error("Error while saving settings file [" + settingsPath + "]", e);
+ "settings [" + filePath.toString() + "]", e);
}
OutputStream out = null;
try
{
out = new FileOutputStream(outputFile);
try
{
context = JAXBContext.newInstance(Settings.class);
Marshaller m = context.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
m.marshal(mSettings, out);
}
catch(JAXBException e)
{
mLog.error("SettingsManager - jaxb exception while saving " +
"settings", e);
}
}
catch(Exception e)
{
mLog.error("SettingsManager - couldn't open output stream to " +
"save settings [" + filePath.toString() + "]");
}
finally
{
if(out != null)
{
try
{
out.close();
}
catch(IOException e)
{
e.printStackTrace();
}
}
} }
} }
@@ -340,47 +295,17 @@ public class SettingsManager implements Listener<TunerConfigurationEvent>
{ {
mLog.info("SettingsManager - loading settings file [" + settingsPath.toString() + "]"); mLog.info("SettingsManager - loading settings file [" + settingsPath.toString() + "]");
JAXBContext context = null; JacksonXmlModule xmlModule = new JacksonXmlModule();
xmlModule.setDefaultUseWrapper(false);
ObjectMapper objectMapper = new XmlMapper(xmlModule);
InputStream in = null; try(InputStream in = Files.newInputStream(settingsPath))
try
{ {
in = new FileInputStream(settingsPath.toString()); mSettings = objectMapper.readValue(in, Settings.class);
try
{
context = JAXBContext.newInstance(Settings.class);
Unmarshaller m = context.createUnmarshaller();
mSettings = (Settings) m.unmarshal(in);
} }
catch(JAXBException e) catch(IOException ioe)
{ {
mLog.error("SettingsManager - jaxb exception while loading " + mLog.error("IO error while reading settings file", ioe);
"settings", e);
}
}
catch(Exception e)
{
mLog.error("SettingsManager - coulcn't open inputstream to " +
"load settings [" + settingsPath.toString() + "]", e);
}
finally
{
if(in != null)
{
try
{
in.close();
}
catch(IOException e)
{
mLog.error("SettingsManager - exception while closing " +
"the settings file inputstream reader", e);
}
}
} }
} }
else else

View File

@@ -1,12 +1,12 @@
package io.github.dsheirer.source.recording; package io.github.dsheirer.source.recording;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import java.io.File; import java.io.File;
@JsonSubTypes.Type(value = RecordingConfiguration.class, name = "recordingConfiguration") @JacksonXmlRootElement(localName = "recording_configuration")
public class RecordingConfiguration public class RecordingConfiguration
{ {
private File mRecording; private File mRecording;

View File

@@ -1,29 +1,26 @@
/******************************************************************************* /*
* SDR Trunk * *********************************************************************************************************************
* Copyright (C) 2015 Dennis Sheirer * sdrtrunk
* Copyright (C) 2014-2017 Dennis Sheirer
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* it under the terms of the GNU General Public License as published by * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* the Free Software Foundation, either version 3 of the License, or * later version.
* (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* but WITHOUT ANY WARRANTY; without even the implied warranty of * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* 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 * You should have received a copy of the GNU General Public License along with this program.
* along with this program. If not, see <http://www.gnu.org/licenses/> * If not, see <http://www.gnu.org/licenses/>
******************************************************************************/ * *********************************************************************************************************************
*/
package io.github.dsheirer.source.tuner.airspy; package io.github.dsheirer.source.tuner.airspy;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import io.github.dsheirer.source.tuner.TunerType; import io.github.dsheirer.source.tuner.TunerType;
import io.github.dsheirer.source.tuner.airspy.AirspyTunerController.Gain; import io.github.dsheirer.source.tuner.airspy.AirspyTunerController.Gain;
import io.github.dsheirer.source.tuner.configuration.TunerConfiguration; import io.github.dsheirer.source.tuner.configuration.TunerConfiguration;
@JsonSubTypes.Type(value = AirspyTunerConfiguration.class, name = "airspyTunerConfiguration")
public class AirspyTunerConfiguration extends TunerConfiguration public class AirspyTunerConfiguration extends TunerConfiguration
{ {
private int mSampleRate = AirspyTunerController.DEFAULT_SAMPLE_RATE.getRate(); private int mSampleRate = AirspyTunerController.DEFAULT_SAMPLE_RATE.getRate();
@@ -49,6 +46,7 @@ public class AirspyTunerConfiguration extends TunerConfiguration
} }
@Override @Override
@JacksonXmlProperty(isAttribute = true, localName = "type", namespace = "http://www.w3.org/2001/XMLSchema-instance")
public TunerType getTunerType() public TunerType getTunerType()
{ {
return TunerType.AIRSPY_R820T; return TunerType.AIRSPY_R820T;
@@ -141,5 +139,4 @@ public class AirspyTunerConfiguration extends TunerConfiguration
{ {
mFrequencyCorrection = value; mFrequencyCorrection = value;
} }
} }

View File

@@ -1,32 +1,47 @@
/******************************************************************************* /*
* SDR Trunk * *********************************************************************************************************************
* Copyright (C) 2014 Dennis Sheirer * sdrtrunk
* Copyright (C) 2014-2017 Dennis Sheirer
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* it under the terms of the GNU General Public License as published by * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* the Free Software Foundation, either version 3 of the License, or * later version.
* (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* but WITHOUT ANY WARRANTY; without even the implied warranty of * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* 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 * You should have received a copy of the GNU General Public License along with this program.
* along with this program. If not, see <http://www.gnu.org/licenses/> * If not, see <http://www.gnu.org/licenses/>
******************************************************************************/ * *********************************************************************************************************************
*/
package io.github.dsheirer.source.tuner.configuration; package io.github.dsheirer.source.tuner.configuration;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import io.github.dsheirer.source.tuner.TunerType; import io.github.dsheirer.source.tuner.TunerType;
import io.github.dsheirer.source.tuner.airspy.AirspyTunerConfiguration;
import io.github.dsheirer.source.tuner.fcd.proV1.FCD1TunerConfiguration;
import io.github.dsheirer.source.tuner.fcd.proplusV2.FCD2TunerConfiguration;
import io.github.dsheirer.source.tuner.hackrf.HackRFTunerConfiguration;
import io.github.dsheirer.source.tuner.rtl.e4k.E4KTunerConfiguration;
import io.github.dsheirer.source.tuner.rtl.r820t.R820TTunerConfiguration;
/** /**
* Abstract class to hold a named configuration for a specific type of tuner * Abstract class to hold a named configuration for a specific type of tuner
*/ */
@JacksonXmlRootElement(localName = "tuner_configuration") @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include= JsonTypeInfo.As.PROPERTY, property="type")
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "xsi:type") @JsonSubTypes({
@JsonSubTypes.Type(value=AirspyTunerConfiguration.class, name="airspyTunerConfiguration"),
@JsonSubTypes.Type(value=E4KTunerConfiguration.class, name="e4KTunerConfiguration"),
@JsonSubTypes.Type(value=FCD1TunerConfiguration.class, name="fcd1TunerConfiguration"),
@JsonSubTypes.Type(value=FCD2TunerConfiguration.class, name="fcd2TunerConfiguration"),
@JsonSubTypes.Type(value=HackRFTunerConfiguration.class, name="hackRFTunerConfiguration"),
@JsonSubTypes.Type(value=R820TTunerConfiguration.class, name="r820TTunerConfiguration"),
})
@JacksonXmlRootElement( localName = "tuner_configuration" )
public abstract class TunerConfiguration public abstract class TunerConfiguration
{ {
protected String mName; protected String mName;
@@ -100,6 +115,12 @@ public abstract class TunerConfiguration
mFrequency = frequency; mFrequency = frequency;
} }
@JacksonXmlProperty(isAttribute = true, localName = "tuner_type") @JsonIgnore
public abstract TunerType getTunerType(); public abstract TunerType getTunerType();
//Below is maintained for compatibility with javax.xml.bind serialization of the settings file.
//This can be removed if/once there is a new version of the settings.
@JacksonXmlProperty(isAttribute = true, localName = "tuner_type")
public String getLegacyAttribute(){ return null; }
public void setLegacyAttribute(String bonkers) { }
} }

View File

@@ -17,7 +17,6 @@
******************************************************************************/ ******************************************************************************/
package io.github.dsheirer.source.tuner.fcd.proV1; package io.github.dsheirer.source.tuner.fcd.proV1;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import io.github.dsheirer.source.tuner.TunerType; import io.github.dsheirer.source.tuner.TunerType;
import io.github.dsheirer.source.tuner.configuration.TunerConfiguration; import io.github.dsheirer.source.tuner.configuration.TunerConfiguration;
@@ -25,7 +24,6 @@ import io.github.dsheirer.source.tuner.fcd.proV1.FCD1TunerController.LNAEnhance;
import io.github.dsheirer.source.tuner.fcd.proV1.FCD1TunerController.LNAGain; import io.github.dsheirer.source.tuner.fcd.proV1.FCD1TunerController.LNAGain;
import io.github.dsheirer.source.tuner.fcd.proV1.FCD1TunerController.MixerGain; import io.github.dsheirer.source.tuner.fcd.proV1.FCD1TunerController.MixerGain;
@JsonSubTypes.Type(value = FCD1TunerConfiguration.class, name = "fcd1TunerConfiguration")
public class FCD1TunerConfiguration extends TunerConfiguration public class FCD1TunerConfiguration extends TunerConfiguration
{ {
private double mFrequencyCorrection = 22.0d; private double mFrequencyCorrection = 22.0d;
@@ -50,6 +48,7 @@ public class FCD1TunerConfiguration extends TunerConfiguration
super(uniqueID, name); super(uniqueID, name);
} }
@JacksonXmlProperty(isAttribute = true, localName = "type", namespace = "http://www.w3.org/2001/XMLSchema-instance")
@Override @Override
public TunerType getTunerType() public TunerType getTunerType()
{ {

View File

@@ -17,12 +17,10 @@
******************************************************************************/ ******************************************************************************/
package io.github.dsheirer.source.tuner.fcd.proplusV2; package io.github.dsheirer.source.tuner.fcd.proplusV2;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import io.github.dsheirer.source.tuner.TunerType; import io.github.dsheirer.source.tuner.TunerType;
import io.github.dsheirer.source.tuner.configuration.TunerConfiguration; import io.github.dsheirer.source.tuner.configuration.TunerConfiguration;
@JsonSubTypes.Type(value = FCD2TunerConfiguration.class, name = "fcd2TunerConfiguration")
public class FCD2TunerConfiguration extends TunerConfiguration public class FCD2TunerConfiguration extends TunerConfiguration
{ {
private boolean mGainLNA = true; private boolean mGainLNA = true;
@@ -41,6 +39,7 @@ public class FCD2TunerConfiguration extends TunerConfiguration
super(uniqueID, name); super(uniqueID, name);
} }
@JacksonXmlProperty(isAttribute = true, localName = "type", namespace = "http://www.w3.org/2001/XMLSchema-instance")
@Override @Override
public TunerType getTunerType() public TunerType getTunerType()
{ {

View File

@@ -18,7 +18,6 @@
package io.github.dsheirer.source.tuner.hackrf; package io.github.dsheirer.source.tuner.hackrf;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import io.github.dsheirer.source.tuner.TunerType; import io.github.dsheirer.source.tuner.TunerType;
import io.github.dsheirer.source.tuner.configuration.TunerConfiguration; import io.github.dsheirer.source.tuner.configuration.TunerConfiguration;
@@ -26,7 +25,6 @@ import io.github.dsheirer.source.tuner.hackrf.HackRFTunerController.HackRFLNAGai
import io.github.dsheirer.source.tuner.hackrf.HackRFTunerController.HackRFSampleRate; import io.github.dsheirer.source.tuner.hackrf.HackRFTunerController.HackRFSampleRate;
import io.github.dsheirer.source.tuner.hackrf.HackRFTunerController.HackRFVGAGain; import io.github.dsheirer.source.tuner.hackrf.HackRFTunerController.HackRFVGAGain;
@JsonSubTypes.Type(value = HackRFTunerConfiguration.class, name = "hackRFTunerConfiguration")
public class HackRFTunerConfiguration extends TunerConfiguration public class HackRFTunerConfiguration extends TunerConfiguration
{ {
private HackRFSampleRate mSampleRate = HackRFSampleRate.RATE2_016MHZ; private HackRFSampleRate mSampleRate = HackRFSampleRate.RATE2_016MHZ;
@@ -47,6 +45,7 @@ public class HackRFTunerConfiguration extends TunerConfiguration
super(uniqueID, name); super(uniqueID, name);
} }
@JacksonXmlProperty(isAttribute = true, localName = "type", namespace = "http://www.w3.org/2001/XMLSchema-instance")
@Override @Override
public TunerType getTunerType() public TunerType getTunerType()
{ {

View File

@@ -17,10 +17,8 @@
******************************************************************************/ ******************************************************************************/
package io.github.dsheirer.source.tuner.rtl.e4k; package io.github.dsheirer.source.tuner.rtl.e4k;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import io.github.dsheirer.source.tuner.TunerType; import io.github.dsheirer.source.tuner.TunerType;
import io.github.dsheirer.source.tuner.airspy.AirspyTunerConfiguration;
import io.github.dsheirer.source.tuner.configuration.TunerConfiguration; import io.github.dsheirer.source.tuner.configuration.TunerConfiguration;
import io.github.dsheirer.source.tuner.rtl.RTL2832TunerController; import io.github.dsheirer.source.tuner.rtl.RTL2832TunerController;
import io.github.dsheirer.source.tuner.rtl.e4k.E4KTunerController.E4KEnhanceGain; import io.github.dsheirer.source.tuner.rtl.e4k.E4KTunerController.E4KEnhanceGain;
@@ -28,7 +26,6 @@ import io.github.dsheirer.source.tuner.rtl.e4k.E4KTunerController.E4KGain;
import io.github.dsheirer.source.tuner.rtl.e4k.E4KTunerController.E4KLNAGain; import io.github.dsheirer.source.tuner.rtl.e4k.E4KTunerController.E4KLNAGain;
import io.github.dsheirer.source.tuner.rtl.e4k.E4KTunerController.E4KMixerGain; import io.github.dsheirer.source.tuner.rtl.e4k.E4KTunerController.E4KMixerGain;
@JsonSubTypes.Type(value = AirspyTunerConfiguration.class, name = "e4KTunerConfiguration")
public class E4KTunerConfiguration extends TunerConfiguration public class E4KTunerConfiguration extends TunerConfiguration
{ {
private E4KGain mMasterGain = E4KGain.MANUAL; private E4KGain mMasterGain = E4KGain.MANUAL;
@@ -50,6 +47,7 @@ public class E4KTunerConfiguration extends TunerConfiguration
super(uniqueID, name); super(uniqueID, name);
} }
@JacksonXmlProperty(isAttribute = true, localName = "type", namespace = "http://www.w3.org/2001/XMLSchema-instance")
@Override @Override
public TunerType getTunerType() public TunerType getTunerType()
{ {

View File

@@ -17,13 +17,11 @@
******************************************************************************/ ******************************************************************************/
package io.github.dsheirer.source.tuner.rtl.r820t; package io.github.dsheirer.source.tuner.rtl.r820t;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import io.github.dsheirer.source.tuner.TunerType; import io.github.dsheirer.source.tuner.TunerType;
import io.github.dsheirer.source.tuner.configuration.TunerConfiguration; import io.github.dsheirer.source.tuner.configuration.TunerConfiguration;
import io.github.dsheirer.source.tuner.rtl.RTL2832TunerController; import io.github.dsheirer.source.tuner.rtl.RTL2832TunerController;
@JsonSubTypes.Type(value = R820TTunerConfiguration.class, name = "r820TTunerConfiguration")
public class R820TTunerConfiguration extends TunerConfiguration public class R820TTunerConfiguration extends TunerConfiguration
{ {
private R820TTunerController.R820TGain mMasterGain = R820TTunerController.R820TGain.GAIN_327; private R820TTunerController.R820TGain mMasterGain = R820TTunerController.R820TGain.GAIN_327;
@@ -45,6 +43,7 @@ public class R820TTunerConfiguration extends TunerConfiguration
super(uniqueID, name); super(uniqueID, name);
} }
@JacksonXmlProperty(isAttribute = true, localName = "type", namespace = "http://www.w3.org/2001/XMLSchema-instance")
@Override @Override
public TunerType getTunerType() public TunerType getTunerType()
{ {