All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.yangcentral.yangkit.model.impl.codec.InstanceIdentifierStringValueCodecImpl Maven / Gradle / Ivy

There is a newer version: 1.4.5
Show newest version
package org.yangcentral.yangkit.model.impl.codec;

import org.yangcentral.yangkit.model.api.codec.InstanceIdentifierStringValueCodec;
import org.yangcentral.yangkit.model.api.codec.YangCodecException;
import org.yangcentral.yangkit.model.api.restriction.Restriction;
import org.yangcentral.yangkit.model.api.stmt.TypedDataNode;
import org.yangcentral.yangkit.xpath.YangAbsoluteLocationPath;
import org.yangcentral.yangkit.xpath.YangXPath;
import org.yangcentral.yangkit.xpath.impl.YangXPathImpl;
import org.jaxen.JaxenException;

public class InstanceIdentifierStringValueCodecImpl extends ComplexStringValueCodecImpl implements InstanceIdentifierStringValueCodec {
   public InstanceIdentifierStringValueCodecImpl(TypedDataNode schemaNode) {
      super(schemaNode);
   }

   public YangAbsoluteLocationPath deserialize(Restriction restriction, String input) throws YangCodecException {
      try {
         YangXPath yangXPath = new YangXPathImpl(input);
         if (yangXPath.getRootExpr() instanceof YangAbsoluteLocationPath) {
            return (YangAbsoluteLocationPath)yangXPath.getRootExpr();
         } else {
            throw new YangCodecException("the value:" + input + " is invalid instance-identifier.");
         }
      } catch (JaxenException e) {
         throw new YangCodecException(e.getMessage());
      }
   }

   public String serialize(Restriction restriction, YangAbsoluteLocationPath output) throws YangCodecException {
      return output.getText();
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy