All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jboss.resteasy.util.HeaderHelper Maven / Gradle / Ivy

The newest version!
package org.jboss.resteasy.util;

import javax.ws.rs.core.MultivaluedMap;
import java.util.Set;

/**
 * @author Bill Burke
 * @version $Revision: 1 $
 */
public class HeaderHelper
{
   @SuppressWarnings(value = "unchecked")
   public static void setAllow(MultivaluedMap headers, String[] methods)
   {
      if (methods == null)
      {
         headers.remove("Allow");
         return;
      }
      StringBuilder builder = new StringBuilder();
      boolean isFirst = true;
      for (String l : methods)
      {
         if (isFirst)
         {
            isFirst = false;
         }
         else
         {
            builder.append(", ");
         }
         builder.append(l);
      }
      headers.putSingle("Allow", builder.toString());
   }

   @SuppressWarnings(value = "unchecked")
   public static void setAllow(MultivaluedMap headers, Set methods)
   {
      if (methods == null)
      {
         headers.remove("Allow");
         return;
      }
      StringBuilder builder = new StringBuilder();
      boolean isFirst = true;
      for (String l : methods)
      {
         if (isFirst)
         {
            isFirst = false;
         }
         else
         {
            builder.append(", ");
         }
         builder.append(l);
      }
      headers.putSingle("Allow", builder.toString());
   }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy