16 package net.squiz.matrix.core;
21 import java.awt.Component;
22 import java.io.UnsupportedEncodingException;
46 public static String
rawUrlEncode(String url,
boolean encodeSpaces) {
48 url = URLEncoder.encode(url,
"UTF-8");
49 }
catch (UnsupportedEncodingException uee) {
50 System.err.println(
"Could not encode url");
51 uee.printStackTrace();
54 url = url.replace(
'+',
' ');
66 url = URLDecoder.decode(url,
"UTF-8");
67 }
catch (UnsupportedEncodingException uee) {
68 System.err.println(
"Could not decode url");
69 uee.printStackTrace();
83 public static String
implode(String delimiter, List elements) {
84 StringBuffer buff =
new StringBuffer();
85 Iterator iterator = elements.iterator();
86 while (iterator.hasNext()) {
87 Object element = iterator.next();
88 if (element instanceof Integer)
89 buff.append(((Integer) element).toString());
91 buff.append((String) element);
92 buff.append(delimiter);
94 return buff.toString();
97 public static void addAssetToXML(StringBuffer xml,
Asset asset,
int start,
int limit) {
98 addAssetToXML(xml, asset.
getId(),
"0", start, limit);
107 public static void addAssetToXML(StringBuffer xml, String assetid, String linkid,
int start,
int limit) {
108 if (assetid.equals(
"1")) {
113 String limitstr =
"start=\""+start+
"\" limit=\""+limit+
"\"";
115 xml.append(
"<asset assetid=\"").append(
116 rawUrlEncode(assetid,
false)).append(
"\" "+limitstr).append(
" linkid=\"").append(
rawUrlEncode(linkid,
false)).append(
"\" />");