Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.javaswift.joss.swift;
  
 
 import java.util.*;
 
 public class SwiftStoredObject implements ListSubjectDirectoryOrObject {
 
     private String name;
 
     private byte[] content;
 
     private Etag etag;
 
     private ObjectContentType contentType;
 
     private Date lastModified;
 
     private ObjectManifest objectManifest;
 
     private HeaderStore headers = new HeaderStore();
 
     private DeleteAt deleteAt;
 
     public SwiftStoredObject(String name) {
         this. = name;
     }
 
     public long getBytesUsed() {
         return .;
     }
 
     public Etag getEtag() {
         return this.;
     }
 
     public ObjectContentType getContentType() {
         return this.;
     }
 
     public Date getLastModified() {
         return this.;
     }
 
     @Override
     public String getName() {
         return this.;
     }
 
     @Override
     public void metadataSetFromHeaders() { /* not used */ }
 
     public ObjectInformation getInfo() {
         ObjectInformation objectInformation = new ObjectInformation();
         objectInformation.setMetadata(.getMetadata());
         objectInformation.setContentLength(new ObjectContentLength(Long.toString(.)));
         objectInformation.setContentType();
         objectInformation.setEtag();
         objectInformation.setLastModified(new ObjectLastModified());
         objectInformation.setDeleteAt();
         return objectInformation;
     }
 
     public SwiftResult<ObjectuploadObject(UploadInstructions uploadInstructions) {
         try {
             this. = LocalTime.currentDate();
             this. = IOUtils.toByteArray(uploadInstructions.getEntity().getContent());
             this. = uploadInstructions.getObjectManifest();
             this. = new Etag(uploadInstructions.getMd5() != null ?
                         uploadInstructions.getMd5() :
                         DigestUtils.md5Hex());
             this. =
                     uploadInstructions.getContentType() != null ?
                         uploadInstructions.getContentType() :
                         new ObjectContentType(new MimetypesFileTypeMap().getContentType(getName()));
             return new SwiftResult<Object>(.);
         } catch (IOException err) {
             return new SwiftResult<Object>(.);
         }
     }
 
     public SwiftResult<ObjectcopyFrom(SwiftStoredObject sourceObject) {
         UploadInstructions uploadInstructions = new UploadInstructions(sourceObject.getContent().clone());
         uploadInstructions.setContentType(sourceObject.getContentType().getHeaderValue());
         uploadObject(uploadInstructions);
         return new SwiftResult<Object>(.);
     }
 
    public SwiftResult<byte[]> downloadObject(DownloadInstructions downloadInstructions) {
        byte[] object = this.;
        if (downloadInstructions.getRange() != null) {
            return new SwiftResult<byte[]>(downloadInstructions.getRange().copy(object), .);
        }
        if (downloadInstructions.getMatchConditional() != null) {
            downloadInstructions.getMatchConditional().matchAgainst(.getHeaderValue());
        }
        if (downloadInstructions.getSinceConditional() != null) {
            downloadInstructions.getSinceConditional().sinceAgainst();
        }
        return new SwiftResult<byte[]>(object.);
    }
    public SwiftResult<ObjectsaveMetadata(Collection<? extends Headerheaders) {
        this..saveMetadata(headers);
        return new SwiftResult<Object>(.);
    }
    public byte[] getContent() {
        return this.;
    }
    public ObjectManifest getObjectManifest() {
        return this.;
    }
    public void setDeleteAt(DeleteAt deleteAt) {
        this. = deleteAt;
    }
                                                                     String prefixCharacter delimiter) {
        Set<DirectoryOrObjectfiles = new TreeSet<DirectoryOrObject>();
        for (SwiftStoredObject sourceObject : objects) {
            if (prefix != null && !sourceObject.getName().startsWith(prefix)) {
                continue;
            }
            int searchDirectoryDepth = prefix == null ? 0 : prefix.length() - prefix.replace(delimiter.toString(), "").length();
            StringTokenizer tokenizer = new StringTokenizer(sourceObject.getName(), delimiter.toString());
            StringBuilder path = new StringBuilder();
            int currentDepth = 0;
            while (tokenizer.hasMoreTokens()) {
                if (currentDepth > 0) {
                    path.append(delimiter);
                    if (currentDepth == searchDirectoryDepth + 1) {
                        files.add(new Directory(path.toString(), delimiter));
                    }
                }
                String token = tokenizer.nextToken();
                path.append(token);
                currentDepth++;
            }
            if (currentDepth == searchDirectoryDepth + 1) {
                files.add(sourceObject.copyToStoredObject(container.getObject(sourceObject.getName())));
            }
        }
        return files;
    }
    protected StoredObject copyToStoredObject(StoredObject targetObject) {
        targetObject.setContentLength(getBytesUsed());
        targetObject.setEtag(getEtag().getHeaderValue());
        targetObject.setLastModified(getLastModified());
        targetObject.metadataSetFromHeaders();
        return targetObject;
    }
    @Override
    public boolean isObject() {
        return true;
    }
    @Override
    public boolean isDirectory() {
        return false;
    }
    @Override
    public Directory getAsDirectory() {
        return null;
    }
    @Override
    public StoredObject getAsObject() {
        return null;
    }
    @Override
    public String getBareName() {
        return null;
    }
New to GrepCode? Check out our FAQ X