Author: chris.laprun(a)jboss.com
Date: 2010-08-04 19:50:46 -0400 (Wed, 04 Aug 2010)
New Revision: 3746
Modified:
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/jsr168/api/ResourceResponseImpl.java
Log:
- Minor optimization.
Modified:
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/jsr168/api/ResourceResponseImpl.java
===================================================================
---
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/jsr168/api/ResourceResponseImpl.java 2010-08-04
23:49:32 UTC (rev 3745)
+++
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/jsr168/api/ResourceResponseImpl.java 2010-08-04
23:50:46 UTC (rev 3746)
@@ -1,39 +1,38 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
package org.gatein.pc.portlet.impl.jsr168.api;
import org.gatein.common.net.media.ContentType;
import org.gatein.common.net.media.MediaType;
import org.gatein.common.net.media.Parameter;
+import org.gatein.pc.api.cache.CacheControl;
+import org.gatein.pc.api.cache.CacheLevel;
import org.gatein.pc.api.invocation.ResourceInvocation;
import org.gatein.pc.api.invocation.response.ContentResponse;
import org.gatein.pc.api.invocation.response.ResponseProperties;
-import org.gatein.pc.api.cache.CacheLevel;
-import org.gatein.pc.api.cache.CacheControl;
-import javax.portlet.ResourceResponse;
import javax.portlet.PortletURL;
-
+import javax.portlet.ResourceResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
@@ -60,18 +59,18 @@
public void setLocale(Locale locale)
{
// TODO: setLocale should also set the character encoding according to the mapping
done in web.xml
-
+
if (locale == null)
{
throw new IllegalArgumentException("Locale cannot be null");
}
- if ("".equals(locale.getCountry()))
+ if (locale.getCountry().isEmpty())
{
- addProperty("Content-Language", locale.getLanguage());
+ addProperty("Content-Language", locale.getLanguage());
}
else
{
- addProperty("Content-Language", locale.getLanguage() + "-"
+ locale.getCountry());
+ addProperty("Content-Language", locale.getLanguage() + "-" +
locale.getCountry());
}
}
@@ -79,7 +78,7 @@
{
List<Parameter> parameters = new ArrayList<Parameter>();
MediaType mediaType = null;
-
+
String contentTypeString = getContentType();
if (contentTypeString != null)
{
@@ -99,7 +98,7 @@
mediaType = MediaType.TEXT_HTML;
}
parameters.add(new Parameter("charset", s));
-
+
setContentType(new ContentType(mediaType, parameters).getValue());
}