Package nl.siegmann.epublib.domain

Examples of nl.siegmann.epublib.domain.MediaType


   * @param filename
   * @return the MediaType based on the file extension.
   */
  public static MediaType determineMediaType(String filename) {
    for(int i = 0; i < mediatypes.length; i++) {
      MediaType mediatype = mediatypes[i];
      for(String extension: mediatype.getExtensions()) {
        if(StringUtil.endsWithIgnoreCase(filename, extension)) {
          return mediatype;
        }
      }
    }
View Full Code Here


 
  public static Resource createResource(File file) throws IOException {
    if (file == null) {
      return null;
    }
    MediaType mediaType = MediatypeService.determineMediaType(file.getName());
    byte[] data = IOUtil.toByteArray(new FileInputStream(file));
    Resource result = new Resource(data, mediaType);
    return result;
  }
View Full Code Here

   */
  private static boolean shouldLoadLazy(String href, Collection<MediaType> lazilyLoadedMediaTypes) {
    if (CollectionUtil.isEmpty(lazilyLoadedMediaTypes)) {
      return false;
    }
    MediaType mediaType = MediatypeService.determineMediaType(href);
    return lazilyLoadedMediaTypes.contains(mediaType);
  }
View Full Code Here

      if(resource == null) {
        log.error("resource with href '" + href + "' not found");
        continue;
      }
      resource.setId(id);
      MediaType mediaType = MediatypeService.getMediaTypeByName(mediaTypeName);
      if(mediaType != null) {
        resource.setMediaType(mediaType);
      }
      result.add(resource);
      idMapping.put(id, resource.getId());
View Full Code Here

    for(int i = 0; i < allFiles.length; i++) {
      FileObject file = allFiles[i];
      if (file.getType() == FileType.FOLDER) {
        continue;
      }
      MediaType mediaType = MediatypeService.determineMediaType(file.getName().getBaseName());
      if(mediaType == null) {
        continue;
      }
      String href = file.getName().toString().substring(rootDir.getName().toString().length() + 1);
      byte[] resourceData = IOUtils.toByteArray(file.getContent().getInputStream());
View Full Code Here

public class VFSUtil {
 
  private static final Logger log = LoggerFactory.getLogger(VFSUtil.class);

  public static Resource createResource(FileObject rootDir, FileObject file, String inputEncoding) throws IOException {
    MediaType mediaType = MediatypeService.determineMediaType(file.getName().getBaseName());
    if(mediaType == null) {
      return null;
    }
    String href = calculateHref(rootDir, file);
    Resource result = new Resource(null, IOUtils.toByteArray(file.getContent().getInputStream()), href, mediaType);
View Full Code Here

TOP

Related Classes of nl.siegmann.epublib.domain.MediaType

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.