Examples of StateVariableValue


Examples of org.teleal.cling.model.state.StateVariableValue

  }

  public String getTransportState() {
    if(stateMap != null && isConfigured()) {
      StateVariableValue status = stateMap.get("TransportState");
      if(status != null) {
        return status.getValue().toString();
      }
    }

    return null;
View Full Code Here

Examples of org.teleal.cling.model.state.StateVariableValue

  }

  public String getCurrentURI(){
    updateMediaInfo();
    if(stateMap != null && isConfigured()) {
      StateVariableValue status = stateMap.get("CurrentURI");
      if(status != null) {
        return status.getValue().toString();
      }
    }
    return null;

  }
View Full Code Here

Examples of org.teleal.cling.model.state.StateVariableValue

    if(stateMap != null && isConfigured()) {

      updatePosition();
      if(stateMap != null) {
        StateVariableValue variable = stateMap.get("Track");
        if(variable != null) {
          return ((UnsignedIntegerFourBytes)variable.getValue()).getValue();
        }
      } 
    }
    return (long) -1;
  }
View Full Code Here

Examples of org.teleal.cling.model.state.StateVariableValue

          //TODO: Get partner ID for openhab.org

          String stationID = StringUtils.substringBetween(currentURI, ":s", "?sid");

          StateVariable newVariable = new StateVariable("StationID",new StateVariableTypeDetails(Datatype.Builtin.STRING.getDatatype()));
          StateVariableValue newValue = new StateVariableValue(newVariable, stationID);

          if(this.isUpdatedValue("StationID", newValue) || lastOPMLQuery ==null || lastOPMLQuery.plusMinutes(1).isBeforeNow()) {

            processStateVariableValue(newVariable.getName(),newValue)

            String url = "http://opml.radiotime.com/Describe.ashx?c=nowplaying&id=" + stationID + "&partnerId=IAeIhU42&serial=" + getMACAddress();

            String response = HttpUtil.executeUrl("GET", url, SO_TIMEOUT);
            //logger.debug("RadioTime Response: {}",response);

            lastOPMLQuery = DateTime.now();

            List<String> fields = null;
            try {
              fields = SonosXMLParser.getRadioTimeFromXML(response);
            } catch (SAXException e) {
              logger.error("Could not parse RadioTime from String {}",response);
            }

            resultString = new String();

            if(fields != null && fields.size()>1) {

              artist = fields.get(0);
              title = fields.get(1);
             
              Iterator<String> listIterator = fields.listIterator();
              while(listIterator.hasNext()){
                String field = listIterator.next();
                resultString = resultString + field;
                if(listIterator.hasNext()) {
                  resultString = resultString + " - ";
                }
              }
            }
          } else {
            resultString = stateMap.get("CurrentURIFormatted").getValue().toString();
            title = stateMap.get("CurrentTitle").getValue().toString();
            artist = stateMap.get("CurrentArtist").getValue().toString();
          }


        } else {
          if(currentTrack != null) {
            if(currentTrack.getResource().contains("x-rincon-stream")) {
              title = currentTrack.getTitle();
              album = " ";
              artist = " ";
              resultString = title;
            } else if(!currentTrack.getResource().contains("x-sonosapi-stream")) {
              if (currentTrack.getAlbumArtist().equals("")) {
                resultString = currentTrack.getCreator() + " - " + currentTrack.getAlbum() + " - " + currentTrack.getTitle();
                artist = currentTrack.getCreator();
              } else {
                resultString = currentTrack.getAlbumArtist() + " - " + currentTrack.getAlbum() + " - " + currentTrack.getTitle();
                artist = currentTrack.getAlbumArtist();
              }

              album = currentTrack.getAlbum();
              title = currentTrack.getTitle();
             
              if(album.equals("")) {
                album= " ";
              }

              if(artist.equals("")) {
                artist= " ";
              }
            }
          } else {
            title=" ";
            album = " ";
            artist = " ";
            resultString = " ";
          }
        }

        StateVariable newVariable = new StateVariable("CurrentURIFormatted",new StateVariableTypeDetails(Datatype.Builtin.STRING.getDatatype()));
        StateVariableValue newValue = new StateVariableValue(newVariable, resultString);
        processStateVariableValue(newVariable.getName(),newValue);   

        // update individual variables
        newVariable = new StateVariable("CurrentArtist",new StateVariableTypeDetails(Datatype.Builtin.STRING.getDatatype()));

        if (artist != null) {
          newValue = new StateVariableValue(newVariable, artist);
        } else {
          newValue = new StateVariableValue(newVariable, " ");
        }
        processStateVariableValue(newVariable.getName(), newValue);   

        newVariable = new StateVariable("CurrentTitle",new StateVariableTypeDetails(Datatype.Builtin.STRING.getDatatype()));
        if (title != null) {
          newValue = new StateVariableValue(newVariable, title);
        } else {
          newValue = new StateVariableValue(newVariable, " ");
        }
        processStateVariableValue(newVariable.getName(), newValue);   

        newVariable = new StateVariable("CurrentAlbum",new StateVariableTypeDetails(Datatype.Builtin.STRING.getDatatype()));
        if (album != null) {
          newValue = new StateVariableValue(newVariable, album);
        } else {
          newValue = new StateVariableValue(newVariable, " ");
        }
        processStateVariableValue(newVariable.getName(), newValue);   

        return true;
View Full Code Here

Examples of org.teleal.cling.model.state.StateVariableValue

  }

  public String getCurrentURIFormatted(){
    updateCurrentURIFormatted();
    if(stateMap != null && isConfigured()) {
      StateVariableValue status = stateMap.get("CurrentURIFormatted");
      if(status != null) {
        return status.getValue().toString();
      }
    }

    return null;
View Full Code Here

Examples of org.teleal.cling.model.state.StateVariableValue

  }

  public String getCurrentURIMetadataAsString() {
    if(stateMap != null && isConfigured()) {
      StateVariableValue value = stateMap.get("CurrentTrackMetaData");
      if(value != null) {
        return value.getValue().toString();
      }
    }
    return null;

  }
View Full Code Here

Examples of org.teleal.cling.model.state.StateVariableValue

  }


  public SonosMetaData getCurrentURIMetadata(){
    if(stateMap != null && isConfigured()) {
      StateVariableValue value = stateMap.get("CurrentURIMetaData");
      SonosMetaData currentTrack = null;
      if(value != null) {
        try {
          if(((String)value.getValue()).length()!=0) {
            currentTrack = SonosXMLParser.getMetaDataFromXML((String)value.getValue());
          }
        } catch (SAXException e) {
          logger.error("Could not parse MetaData from String {}",value.getValue().toString());
        }
        return currentTrack;
      } else {
        return null;
      }
View Full Code Here

Examples of org.teleal.cling.model.state.StateVariableValue

    }   
  }

  public SonosMetaData getTrackMetadata(){
    if(stateMap != null && isConfigured()) {
      StateVariableValue value = stateMap.get("CurrentTrackMetaData");
      SonosMetaData currentTrack = null;
      if(value != null) {
        try {
          if(((String)value.getValue()).length()!=0) {
            currentTrack = SonosXMLParser.getMetaDataFromXML((String)value.getValue());
          }
        } catch (SAXException e) {
          logger.error("Could not parse MetaData from String {}",value.getValue().toString());
        }
        return currentTrack;
      } else {
        return null;
      }
View Full Code Here

Examples of org.teleal.cling.model.state.StateVariableValue

    }   
  }

  public SonosMetaData getEnqueuedTransportURIMetaData(){
    if(stateMap != null && isConfigured()) {
      StateVariableValue value = stateMap.get("EnqueuedTransportURIMetaData");
      SonosMetaData currentTrack = null;
      if(value != null) {
        try {
          if(((String)value.getValue()).length()!=0) {
            currentTrack = SonosXMLParser.getMetaDataFromXML((String)value.getValue());
          }
        } catch (SAXException e) {
          logger.error("Could not parse MetaData from String {}",value.getValue().toString());
        }
        return currentTrack;
      } else {
        return null;
      }
View Full Code Here

Examples of org.teleal.cling.model.state.StateVariableValue

       * the info we need from here.
       */
      try {
        if(atts.getValue("val") != null) {
          StateVariable stateVariable = new StateVariable(localName, new StateVariableTypeDetails(new StringDatatype()));
          StateVariableValue stateVariableValue = new StateVariableValue(stateVariable, atts.getValue("val"));
          changes.put(localName, stateVariableValue);
        }
      } catch (IllegalArgumentException e) {
        // this means that localName isn't defined in EventType, which is expected for some elements
        logger.info("{} is not defined in EventType. ",localName);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.