/*
* Class: org_iotivity_base_OcRepresentation
+* Method: getHost
+* Signature: ()Ljava/lang/String;
+*/
+JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcRepresentation_getHost
+(JNIEnv *env, jobject thiz)
+{
+ LOGD("OcRepresentation_getHost");
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return nullptr;
+
+ std::string uri(rep->getHost());
+ return env->NewStringUTF(uri.c_str());
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
* Method: setUri
* Signature: (Ljava/lang/String;)V
*/
/*
* Class: org_iotivity_base_OcRepresentation
+ * Method: getHost
+ * Signature: ()Ljava/lang/String;
+ */
+ JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcRepresentation_getHost
+ (JNIEnv *, jobject);
+
+ /*
+ * Class: org_iotivity_base_OcRepresentation
* Method: setUri
* Signature: (Ljava/lang/String;)V
*/
public native String getUri();
+ public native String getHost();
+
public native void setUri(String uri);
/**
virtual ~OCRepresentation(){}
+ void setDevAddr(const OCDevAddr addr);
+
+ const std::string getHost() const;
+
OCRepPayload* getPayload() const;
void addChild(const OCRepresentation&);
bool isNULL(const std::string& str) const;
+ private:
+ std::string m_host;
+
// STL Container stuff
public:
class iterator;
// first one is considered the root, everything else is considered a child of this one.
OCRepresentation root = *it;
+ root.setDevAddr(clientResponse->devAddr);
++it;
std::for_each(it, oc.representations().end(),
namespace OC
{
+ static const char COAP[] = "coap://";
+ static const char COAPS[] = "coaps://";
void MessageContainer::setPayload(const OCPayload* rep)
{
{
m_children = children;
}
+
+ void OCRepresentation::setDevAddr(const OCDevAddr m_devAddr)
+ {
+ std::ostringstream ss;
+ if (m_devAddr.flags & OC_SECURE)
+ {
+ ss << COAPS;
+ }
+ #ifdef TCP_ADAPTER
+ else if (m_devAddr.adapter & OC_ADAPTER_TCP)
+ {
+ ss << COAP_TCP;
+ }
+ #endif
+ else
+ {
+ ss << COAP;
+ }
+ if (m_devAddr.flags & OC_IP_USE_V6)
+ {
+ ss << '[' << m_devAddr.addr << ']';
+ }
+ else
+ {
+ ss << m_devAddr.addr;
+ }
+ if (m_devAddr.port)
+ {
+ ss << ':' << m_devAddr.port;
+ }
+ m_host = ss.str();
+ }
+
+ const std::string OCRepresentation::getHost() const
+ {
+ return m_host;
+ }
+
void OCRepresentation::setUri(const char* uri)
{
m_uri = uri ? uri : "";