Package com.basho.riak.protobuf.RiakKvPB.RpbContent

Examples of com.basho.riak.protobuf.RiakKvPB.RpbContent.Builder


    public ByteString getValue(){
        return value;
    }

  RpbContent buildContent() {
    Builder b =
      RpbContent.newBuilder()
        .setValue(value);
   
    if (contentType != null) {
      b.setContentType(ByteString.copyFromUtf8(contentType));
    }
       
    if (charset != null) {
      b.setCharset(ByteString.copyFromUtf8(charset));
    }
       
    if (contentEncoding != null) {
      b.setContentEncoding(ByteString.copyFromUtf8(contentEncoding));
    }

    if (vtag != null) {
      b.setVtag(ByteString.copyFromUtf8(vtag));
    }
   
        if (links.size() != 0) {
            RiakLink[] localLinks = null;
            synchronized (links) {
                localLinks = links.toArray(new RiakLink[links.size()]);
            }
            for (RiakLink l : localLinks) {
                b.addLinks(l.build());
            }
        }
   
    if (lastModified != null) {
      b.setLastMod(lastModified);
    }
   
    if (lastModifiedUsec != null) {
      b.setLastModUsecs(lastModifiedUsec);
    }
   
    final Map<String, String> tmpUserMetaData = new LinkedHashMap<String, String>();

    synchronized (userMetaDataLock) {
        tmpUserMetaData.putAll(userMetaData);
        }

    if (tmpUserMetaData != null && !tmpUserMetaData.isEmpty()) {
      for (Map.Entry<String, String> ent : tmpUserMetaData.entrySet()) {
        ByteString key = ByteString.copyFromUtf8(ent.getKey());
        com.basho.riak.protobuf.RiakPB.RpbPair.Builder pb =
                    com.basho.riak.protobuf.RiakPB.RpbPair.newBuilder().setKey(key);
        if (ent.getValue() != null) {
          pb.setValue(ByteString.copyFromUtf8(ent.getValue()));
        }
        b.addUsermeta(pb);
      }
    }

        synchronized (indexLock) {
            for (@SuppressWarnings("rawtypes") RiakIndex i : indexes) {
                b.addIndexes(RpbPair.newBuilder()
                             .setKey(ByteString.copyFromUtf8(i.getName()))
                             .setValue(ByteString.copyFromUtf8(i.getValue().toString()))
                             .build());
            }
        }

    return b.build();
  }
View Full Code Here


    public ByteString getValue(){
        return value;
    }

  RpbContent buildContent() {
    Builder b =
      RpbContent.newBuilder()
        .setValue(value);
   
    if (contentType != null) {
      b.setContentType(ByteString.copyFromUtf8(contentType));
    }
       
    if (charset != null) {
      b.setCharset(ByteString.copyFromUtf8(charset));
    }
       
    if (contentEncoding != null) {
      b.setContentEncoding(ByteString.copyFromUtf8(contentEncoding));
    }

    if (vtag != null) {
      b.setVtag(ByteString.copyFromUtf8(vtag));
    }
   
        if (links.size() != 0) {
            RiakLink[] localLinks = null;
            synchronized (links) {
                localLinks = links.toArray(new RiakLink[links.size()]);
            }
            for (RiakLink l : localLinks) {
                b.addLinks(l.build());
            }
        }
   
    if (lastModified != null) {
      b.setLastMod(lastModified);
    }
   
    if (lastModifiedUsec != null) {
      b.setLastModUsecs(lastModifiedUsec);
    }
   
    final Map<String, String> tmpUserMetaData = new LinkedHashMap<String, String>();

    synchronized (userMetaDataLock) {
        tmpUserMetaData.putAll(userMetaData);
        }

    if (tmpUserMetaData != null && !tmpUserMetaData.isEmpty()) {
      for (Map.Entry<String, String> ent : tmpUserMetaData.entrySet()) {
        ByteString key = ByteString.copyFromUtf8(ent.getKey());
        com.basho.riak.protobuf.RiakPB.RpbPair.Builder pb =
                    com.basho.riak.protobuf.RiakPB.RpbPair.newBuilder().setKey(key);
        if (ent.getValue() != null) {
          pb.setValue(ByteString.copyFromUtf8(ent.getValue()));
        }
        b.addUsermeta(pb);
      }
    }

        synchronized (indexLock) {
            for (@SuppressWarnings("rawtypes") RiakIndex i : indexes) {
                b.addIndexes(RpbPair.newBuilder()
                             .setKey(ByteString.copyFromUtf8(i.getName()))
                             .setValue(ByteString.copyFromUtf8(i.getValue().toString()))
                             .build());
            }
        }

    return b.build();
  }
View Full Code Here

    public ByteString getValue(){
        return value;
    }

  RpbContent buildContent() {
    Builder b =
      RpbContent.newBuilder()
        .setValue(value);
   
    if (contentType != null) {
      b.setContentType(ByteString.copyFromUtf8(contentType));
    }
       
    if (charset != null) {
      b.setCharset(ByteString.copyFromUtf8(charset));
    }
       
    if (contentEncoding != null) {
      b.setContentEncoding(ByteString.copyFromUtf8(contentEncoding));
    }

    if (vtag != null) {
      b.setVtag(ByteString.copyFromUtf8(vtag));
    }
   
        if (links.size() != 0) {
            RiakLink[] localLinks = null;
            synchronized (links) {
                localLinks = links.toArray(new RiakLink[links.size()]);
            }
            for (RiakLink l : localLinks) {
                b.addLinks(l.build());
            }
        }
   
    if (lastModified != null) {
      b.setLastMod(lastModified);
    }
   
    if (lastModifiedUsec != null) {
      b.setLastModUsecs(lastModifiedUsec);
    }
   
    final Map<String, String> tmpUserMetaData = new LinkedHashMap<String, String>();

    synchronized (userMetaDataLock) {
        tmpUserMetaData.putAll(userMetaData);
        }

    if (tmpUserMetaData != null && !tmpUserMetaData.isEmpty()) {
      for (Map.Entry<String, String> ent : tmpUserMetaData.entrySet()) {
        ByteString key = ByteString.copyFromUtf8(ent.getKey());
        com.basho.riak.protobuf.RiakPB.RpbPair.Builder pb =
                    com.basho.riak.protobuf.RiakPB.RpbPair.newBuilder().setKey(key);
        if (ent.getValue() != null) {
          pb.setValue(ByteString.copyFromUtf8(ent.getValue()));
        }
        b.addUsermeta(pb);
      }
    }

        synchronized (indexLock) {
            for (@SuppressWarnings("rawtypes") RiakIndex i : indexes) {
                b.addIndexes(RpbPair.newBuilder()
                             .setKey(ByteString.copyFromUtf8(i.getName()))
                             .setValue(ByteString.copyFromUtf8(i.getValue().toString()))
                             .build());
            }
        }

    return b.build();
  }
View Full Code Here

TOP

Related Classes of com.basho.riak.protobuf.RiakKvPB.RpbContent.Builder

Copyright © 2018 www.massapicom. 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.