Class SettingsSetter

Object
com.zebra.sdk.printer.SettingsSetter

public class SettingsSetter extends Object
A utility class used to wrap with a map and send settings commands to a connection. Settings commands are accepted by Link-OS printers, version 1.0 and higher.

package test.zebra.sdk.printer.examples;
 
 import java.util.LinkedHashMap;
 import java.util.Map;
 
 import com.zebra.sdk.comm.ConnectionException;
 import com.zebra.sdk.printer.SettingsSetter;
 import com.zebra.sdk.settings.SettingsException;
 
 public class SettingsSetterExample {
 
     public static void main(String[] args) {
         String ipAddress = "192.168.1.100";
         Map<String, String> settingsToSendToThePrinter = new LinkedHashMap<String, String>();
 
         // Pass in a null as the second parameter to retrieve the setting
         settingsToSendToThePrinter.put("device.friendly_name", null);
 
         // Pass in a value as the second parameter to set the setting
         settingsToSendToThePrinter.put("comm.baud", "14400");
 
         // The map containing the results to each settings command
         Map<String, String> results = null;
 
         try {
             results = SettingsSetter.process(ipAddress, settingsToSendToThePrinter);
         } catch (ConnectionException e) {
             e.printStackTrace();
         } catch (SettingsException e) {
             e.printStackTrace();
         }
 
         for (Map.Entry<String, String> entry : results.entrySet()) {
             System.out.println("The setting " + entry.getKey() + " returned " + entry.getValue() + ".");
         }
     }
 }
 
  • Method Details

    • process

      public static Map<String,String> process(String destinationDevice, Map<String,String> settingsToSet) throws ConnectionException, SettingsException
      Sends the settingsToSet to the destinationDevice and then returns the updated setting values.

      Note: Due to the setting verification and validation, additional time and data traffic will be needed for each SettingsSetter process call. It is recommended to bundle all changing settings into one map and one method call to reduce this overhead.

      Parameters:
      destinationDevice - The connection string.
      settingsToSet - The settings map to send to the printer.
      Returns:
      The settings' values after the map has been sent to the printer.
      Throws:
      ConnectionException - if there is an error communicating with the printer.
      SettingsException - if the setting could not be set or retrieved.