Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (C) 2014-2015 Philip Helger (www.helger.com) philip[at]helger[dot]com Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package com.helger.appbasics.exchange;
 
 
 
Defines common file types for import/export.

Author(s):
Philip Helger
 
 public enum EExchangeFileType implements IHasID <String>, IHasDisplayText
 {
   CSV ("csv"".csv".true.)
   {
     @Override
     @Nonnull
     public ExporterCSV createExporter ()
     {
       return new ExporterCSV ().setCharset (.).setSeparator (';');
     }
   },
   {
     @Override
     @Nonnull
     public ExporterExcel createExporter ()
     {
       return new ExporterExcel (.);
     }
   },
   {
     @Override
     @Nonnull
     public ExporterExcel createExporter ()
     {
       return new ExporterExcel (.);
     }
   },
   XML ("xml"".xml".false.)
   {
     @Override
     @Nonnull
     public ExporterXML createExporter ()
     {
       return new ExporterXML ();
     }
   },
   TXT ("txt"".txt".true.)
   {
     @Override
     @Nullable
     public IExporter createExporter ()
     {
       // No default exporter is present
       return null;
     }
   },
   JSON ("json"".json".false.)
   {
     @Override
     @Nonnull
     public ExporterJSON createExporter ()
     {
       return new ExporterJSON ();
     }
   };
  private final String m_sID;
  private final String m_sExt;
  private final IMimeType m_aMimeType;
  private final boolean m_bLineBased;
  private final EExchangeFileTypeName m_aName;
  private EExchangeFileType (@Nonnull @Nonempty final String sID,
                             @Nonnull @Nonempty final String sExt,
                             @Nonnull final IMimeType aMimeType,
                             final boolean bLineBased,
                             @Nonnull final EExchangeFileTypeName aName)
  {
     = sID;
     = sExt;
     = aMimeType;
     = bLineBased;
     = aName;
  }
  public String getID ()
  {
    return ;
  }

  

Returns:
The desired file extension including the leading dot.
  public String getFileExtension ()
  {
    return ;
  }

  

Returns:
The MIMe type for created files.
  public IMimeType getMimeType ()
  {
    return ;
  }

  

Returns:
true if this file type is line based. This is e.g. the case for CSV or Excel files.
  public boolean isLineBased ()
  {
    return ;
  }
  public String getDisplayText (@Nonnull final Locale aContentLocale)
  {
    return .getDisplayText (aContentLocale);
  }
  public String getExportAsText (@Nonnull final Locale aContentLocale)
  {
    return ..getDisplayTextWithArgs (aContentLocalegetDisplayText (aContentLocale));
  }
  public String getSaveAsText (@Nonnull final Locale aContentLocale)
  {
    return ..getDisplayTextWithArgs (aContentLocalegetDisplayText (aContentLocale));
  }
  public abstract IExporter createExporter ();
  public static EExchangeFileType getFromIDOrNull (@Nullable final String sID)
  {
    return EnumHelper.getFromIDOrNull (EExchangeFileType.classsID);
  }
  public static EExchangeFileType getFromIDOrDefault (@Nullable final String sID,
                                                      @Nullable final EExchangeFileType eDefault)
  {
    return EnumHelper.getFromIDOrDefault (EExchangeFileType.classsIDeDefault);
  }
New to GrepCode? Check out our FAQ X