Home  | My Account  |  Membership
WorldDeveloper.org
Forum Details
Topics
Posts
Categories
 
577 member(s)
718,905 hit(s)
14 categories
51 topics
26 messages
0 online
Author Topics Replies Views Last Updated
hostj2me
43 topic(s)
23 post(s)
J2ME: E61 Key map file 1 4620 March 22, 2007 10:04 PM

32=
33=!
34="
35=#
38=&
39='
40=(
41=)
42=*
43=+
44=,;.
45=-
46=.:_
47=/
48=0
49=1
50=2
51=3
52=4
53=5
54=6
55=7
56=8
57=9
61==
63=?
64=@
95=_
97=a"
98=b8
99=c)
100=d+
101=e-
102=f4
103=g5
104=h6
105=i/
106=j#
107=k
108=l
109=m0
110=n9
111=o=
112=p?
113=q!
114=r1
115=s@
116=t2
117=u*
118=v7
119=w&
120=x(
121=y3
122=z'
mode=0

hostj2me
43 topic(s)
23 post(s)
BBC News | Technology | World Edition: Designing mobiles for the world 0 3520 May 29, 2007 2:45 PM

Click here to view complete article

BBC News speaks to Jan Chipchase, principal human behavioural researcher at Nokia Design.

hostj2me
43 topic(s)
23 post(s)
J2ME: How to tell if application was Push activated 1 2381 May 29, 2007 2:22 PM


private boolean isPushActivated()
{
String[] connections = PushRegistry.listConnections(true);
return ( connections != null && connections.length > 0 )
}


hostj2me
43 topic(s)
23 post(s)
J2ME: replaceAll for Strings 0 2275 May 28, 2007 8:25 PM


public static String replaceAll(String text, String old, String newString)
{
int next = text.indexOf(old);
if ( next == -1 )
{
return text;
}
else
{
StringBuffer buffer = new StringBuffer(text.substring(0,next));
buffer.append(newString);
int current = next+old.length(), stop = text.length();
for ( ; current stop && (next = text.indexOf(old,current)) != -1; )
{
buffer.append(text.substring(current, next));
buffer.append(newString);
current = next+old.length();
}

if ( current stop )
{
buffer.append(text.substring(current));
}

return buffer.toString();
}
}

hostj2me
43 topic(s)
23 post(s)
Unix: Show machine configuration 0 2179 May 09, 2007 4:41 PM

hostj2me
43 topic(s)
23 post(s)
J2ME: Split a string by character, StringTokenizer 0 2231 March 05, 2007 5:51 PM


public static Vector split(String s, char c)
{
Vector parts = new Vector();
if ( s != null )
{
int lastfound = 0;
int pos = 0;
while ( (lastfound = s.indexOf(c,pos)) != - 1 )
{
parts.addElement(s.substring(pos,lastfound));
pos = lastfound+1;
}
if ( pos < s.length() ) parts.addElement(s.substring(pos));
}

return parts;
}



edited by hostj2me 4/28/07 9:43 PM

hostj2me
43 topic(s)
23 post(s)
Venture Beat: Social capitalism 0 3793 April 09, 2007 7:12 PM

Click here to view complete article

Today is Good Friday.


Appropriate time, perhaps, to point out the latest column, by attorney Jay Parkhill, which looks at social capitalism, its two basic models, and why some companies in this area are likely to succeed while others are not.


hostj2me
43 topic(s)
23 post(s)
HostJ2ME.com Image proxy servlet source code 0 2162 April 02, 2007 4:34 AM


package com.astrientlabs.biz.web;

import java.awt.image.renderable.ParameterBlock;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

import javax.media.jai.Interpolation;
import javax.media.jai.JAI;
import javax.media.jai.RenderedOp;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.astrientlabs.files.AstrientFile;
import com.astrientlabs.logging.LogWriter;
import com.astrientlabs.lpa.CachingFileStore;
import com.astrientlabs.misc.ApiKey;
import com.astrientlabs.util.Strings;
import com.astrientlabs.web.WebServlet;
import com.astrientlabs.webstats.StatRecorder;
import com.sun.media.jai.codec.FileSeekableStream;
import com.sun.media.jai.codec.JPEGEncodeParam;

public class ImageProxyServlet extends WebServlet
{
/**
*
*/
private static final long serialVersionUID = -7462909049956679674L;

private static final CachingFileStore fileStore = new CachingFileStore("/tmp/j2me/imageproxy");
private static final long maxFileSize = 1024L * 1024L * 10;

public void _doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{

URL u = null;
HttpURLConnection con = null;

try
{
StatRecorder.record(request);

String heightString = request.getParameter("h");
String widthString = request.getParameter("w");
String url = request.getParameter("u");
String format = Strings.ifNull(request.getParameter("f"), "JPEG");
//String auth = Strings.ifNull(request.getParameter("auth"), "public");

String apiKey = request.getParameter("key");
ApiKey.testValid(apiKey);

LogWriter.system.log(ImageProxyServlet.class, apiKey + " Requested file " + url);

u = new URL(url);

con = (HttpURLConnection) u.openConnection();

String id = "F" + u.getHost().hashCode() + "." + u.getPath().hashCode();

String path = fileStore.getLocation(id, "orig");
File f = new File(path);

if (con.getContentLength() != -1 && con.getContentLength() > maxFileSize)
{
response.sendError(HttpURLConnection.HTTP_ENTITY_TOO_LARGE, "requested resource is too large");
return;
}

if ( /*!Preferences.system.getBoolean("imgproxy.caching",false) ||*/ (!f.exists() || f.lastModified() con.getLastModified() || f.length() == 0 || con.getContentLength() != f.length()) )
{
LogWriter.system.log(ImageProxyServlet.class, "downloading updated image");
fileStore.invalidate(id, "orig");
fileStore.add(id, "orig", new byte[0]);

InputStream is = u.openStream();
FileOutputStream fos = new FileOutputStream(f);
try
{
int r;
int read = 0;
byte[] buffer = new byte[4*1024];
while ((r = is.read(buffer)) != -1)
{
fos.write(buffer, 0, r);
read += r;
if (read > maxFileSize)
{
response.sendError(HttpURLConnection.HTTP_ENTITY_TOO_LARGE, "requested resource is too large");
return;
}
}
fos.flush();
}
finally
{
if (is != null)
is.close();
try
{
fos.close();
}
catch (Exception e)
{
}
}
}

String newFilePath = format.toUpperCase().hashCode() + "." + heightString + "." + widthString;

path = fileStore.getLocation(id, newFilePath);
File newFile = new File(path);

if (!newFile.exists() || newFile.lastModified() f.lastModified() || newFile.length() == 0)
{
fileStore.invalidate(id, newFilePath);

FileSeekableStream stream = new FileSeekableStream(f);
RenderedOp image = JAI.create("stream", stream);

scale(image, format, path, widthString, heightString);
image.dispose();
}

try
{
response.setContentType(AstrientFile.fileType(new FileSeekableStream(newFile)));
}
catch (Exception e)
{
LogWriter.system.log(ImageProxyServlet.class, e);
}

fileStore.writeTo(response.getOutputStream(), id, newFilePath);
}
catch (Exception e)
{
LogWriter.system.log(ImageProxyServlet.class, e);
response.sendError(HttpURLConnection.HTTP_NO_CONTENT, e.getMessage());
}
finally
{
if ( con != null )
{
try
{
con.disconnect();
}
catch (Exception ignored)
{

}
}
}
}

public void scale(RenderedOp image, String format, String location, String widthString, String heightString)
{
int width = (widthString == null) ? image.getWidth() : Integer.parseInt(widthString);
int height = (heightString == null) ? image.getHeight() : Integer.parseInt(heightString);

try
{
/*boolean landscape = (image.getWidth() > image.getHeight());
if (landscape && (height > width))
{
int tmpi = height;
height = width;
width = tmpi;
}*/

double cw = width / (1.0 * image.getWidth());
double ch = height / (1.0 * image.getHeight());

double scale;
if (cw ch)
{
scale = cw;
}
else
{
scale = ch;
}

if (scale > 1.0)
scale = 1.0;

Interpolation interp = Interpolation.getInstance(Interpolation.INTERP_BICUBIC);
ParameterBlock params = new ParameterBlock();
params.addSource(image);
params.add(new Float(scale));
params.add(new Float(scale));
params.add(0.0F);
params.add(0.0F);
params.add(interp);

RenderedOp image1 = JAI.create("scale", params);

if (format.equalsIgnoreCase("JPEG"))
{
JPEGEncodeParam param = new JPEGEncodeParam();
param.setQuality(1.2F);
RenderedOp op = JAI.create("filestore", image1, location, format, param);
op.dispose();
}
else
{
RenderedOp op = JAI.create("filestore", image1, location, format);
op.dispose();
}

}
finally
{
}
}
}

hostj2me
43 topic(s)
23 post(s)
alarm:clock: Sequoia Invests $11.5M in Micro-finance Fund 0 3403 March 31, 2007 10:58 PM

Click here to view complete article

Sequoia is getting some nice TV coverage today on MSNBC's Closing Bell for its $11.5M investment in Indian Microfinance bank SKS. SKS says it is now one of the fastest growing Microfinance institutions in the world and the first for-profit microfinance lengder. The company says it grew by 160% with a 99% on-time repayment rate last year. SKS currently provides loans to its 600K members in 7,200 villages in rural India.

SKS says that the new capital will go towards giving loans to over 5M poor families by 2010. SKS estimates that its loans have a return on equity of 23%. In fact, 23% is the standard interest rate for its loans, which seems to us like loan sharking but we understand the poverty level folks that get these loans don't have many other options.

Sequoia's investment includes an exit clause. In the next three to five years, SKS will either have an initial public offering or be acquired.

Here's an interesting quote from another SKS investor: â??Established markets never took poor people seriously. They neglected the obvious business opportunity. The larger banks and some of the larger institutions have not gone into this business systematically. This creates an...

edited by hostj2me 3/31/07 7:00 PM

hostj2me
43 topic(s)
23 post(s)
Yahoo! News: Wireless and Mobile: Wireless piggybacking case sets precedent: experts (AFP) 1 3326 March 26, 2007 4:19 PM

Click here to view complete article

>AFP - When 17-year-old Garyl Tan Jia Luo piggybacked on his neighbour's unsecured wireless Internet network to chat online, he could not have imagined that in doing so he would make Asian legal history.


>

hostj2me
43 topic(s)
23 post(s)
BBC News | Technology | World Edition: Injunction in Vonage patent row 1 3230 March 26, 2007 4:00 PM

Click here to view complete article

A US judge bans internet phone firm Vonage from using patents owned by US phone giant Verizon.

hostj2me
43 topic(s)
23 post(s)
alarm:clock: Mobile's AdMob Pours $15M From Top Shelf Investors 1 3221 March 26, 2007 3:49 PM

Click here to view complete article

Sequoia seems to be enamoured of its AdBrite investment as AdMob looks a lot like AdBrite. Like AdBrite, AdMob is an open marketplace where any publisher can sell his mobile ad inventory. When we first covered AdMob, we were taken aback by their claims of ads served. The number keeps getting bigger as it claims over 1.6B ads served in less than a year and it now says it has more than 1200 publishers. Today, San Mateo's AdMob has raised $15M in Series B funding led by Accel Partners led the deal and joined by return backer Sequoia Capital. To some extent, Admob competes with Screentonic, Medio, ThirdScreen Media as well as Google. AdMob's leadership is provided by Omar Hamoui, CEO and Founder. He previously founded Fotochatter: a mobile to mobile image sharing network that he ran for 11 months from March 2005 – January 2006. Before that he ran HerBabyShower for 2 years and GoPix for a bit over a year. CEO Omar Hamoui Bangs The Gang To Celebrate 1B ads served We have to say we are impressed with the maturity of the company's ad server. AdMob lets advertisers target by country, language, carrier, phone brand, phone...
>
>

hostj2me
43 topic(s)
23 post(s)
y!p! Source Code Available 0 2074 March 21, 2007 10:04 PM

The complete y!p! Yahoo Image Search Java ME (J2ME) example client source code is now available. You can download it and find out more details here:

http://www.hostj2me.com/appdetails.html?id=1557

There is a video walkthrough here:

http://worlddeveloper.org/files/1877/yipi.wmv

hostj2me
43 topic(s)
23 post(s)
Property File Parser and Persistent Settings Object for Midlets 2 2954 January 29, 2007 8:09 PM


/*
* Copyright (C) 2006 Astrient Labs, LLC 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.
*
* Astrient Labs, LLC
* www.astrientlabs.com
* rashid@astrientlabs.com
* Rashid Mayes 2006
*/
package com.astrientlabs.prefs;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.Hashtable;

import javax.microedition.rms.RecordEnumeration;
import javax.microedition.rms.RecordStore;
import javax.microedition.rms.RecordStoreNotFoundException;

import com.astrientlabs.log.Logger;

public class PropertyMap extends Hashtable
{
public static final char RECORD_DELIMITER = '=';

private PropertyMap parent;
private String name;

public PropertyMap(String name)
{
this.name = name;
}

public PropertyMap(PropertyMap parent, String name)
{
this.name = name;
this.parent = parent;
}

public void initialize()
{
InputStream is = null;

try
{
is = getClass().getResourceAsStream("/config/" + name + ".properties");
parse(is);
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
try
{
if (is != null)
is.close();
}
catch (Exception e)
{
}
}
}

public void parse(InputStream is) throws IOException
{
int b;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
while ((b = is.read()) != -1)
{
if (b == '\n')
{
addLine(new String(baos.toByteArray()).trim());
baos.reset();
}
else
{
if (b != '\n' && b != '\r')
baos.write(b);
}
}

if (baos.size() != 0)
{
addLine(new String(baos.toByteArray()).trim());
}
}

private void addLine(String line)
{
if (line.charAt(0) != '#')
{
int ii = line.indexOf(RECORD_DELIMITER);
if (ii != -1 && ii != (line.length() - 1))
{
put(line.substring(0, ii), line.substring(ii + 1));
}
}
}

public void delete()
{
String recordStoreName = "props-" + name;
try
{
RecordStore.deleteRecordStore(recordStoreName);
}
catch (RecordStoreNotFoundException e)
{
}
catch (Exception e)
{
Logger.instance.log("propertyMap.delete()", e);
}
}

public void read()
{
String recordStoreName = "props-" + name;
RecordStore preferenceDB = null;

try
{
preferenceDB = RecordStore.openRecordStore(recordStoreName, false);
RecordEnumeration renum = preferenceDB.enumerateRecords(null, null, false);

while (renum.hasNextElement())
{
addLine(new String(renum.nextRecord()));
}
}
catch (RecordStoreNotFoundException e)
{
}
catch (Exception e)
{
Logger.instance.log("propertyMap.read()", e);
}
finally
{
try
{
if (preferenceDB != null)
{
preferenceDB.closeRecordStore();
}
}
catch (Exception e)
{
}
}
}

public void write()
{
String recordStoreName = "props-" + name;
RecordStore recordStore = null;

try
{
delete();

if (!isEmpty())
{
recordStore = RecordStore.openRecordStore(recordStoreName, true);

Object key;
byte[] bytes;

StringBuffer buffer = new StringBuffer();
Enumeration keys = keys();
while (keys.hasMoreElements())
{
key = keys.nextElement();
buffer.append(key);
buffer.append(RECORD_DELIMITER);
buffer.append(get(key));

bytes = buffer.toString().getBytes();

recordStore.addRecord(bytes, 0, bytes.length);
buffer.setLength(0);
}
}

Logger.instance.log("propertyMap.write()", name + " saved to " + recordStoreName);
}
catch (Exception e)
{
Logger.instance.log("propertyMap.write().1", e);
}
finally
{
try
{
if (recordStore != null)
{
recordStore.closeRecordStore();
}
}
catch (Exception e)
{
Logger.instance.log("propertyMap.write().2", e);
}
}
}

//TODO: only strings
public Object put(Object arg0, Object arg1)
{
return super.put(arg0.toString(), arg1.toString());
}

public String get(String name)
{
String value = (String) super.get(name);
if (value == null)
{
return (parent == null) ? null : parent.get(name);
}
else
{
return value;
}
}

public String get(String name, String def)
{
String value = get(name);
return (value == null) ? def : String.valueOf(value);
}

public boolean getBoolean(String name, boolean def)
{
String value = get(name);
return (value == null) ? def : value.equalsIgnoreCase("true");
}

public int getInt(String name, int def)
{
String value = get(name);
if (value != null)
{
try
{
if (value.startsWith("-"))
{
return -1 * Integer.parseInt(value.substring(1));
}
else
{
return Integer.parseInt(value);
}
}
catch (Exception e)
{
}
}

return def;
}

public int getInt(String name, int def, int r)
{
String value = get(name);
if (value != null)
{
try
{
if (value.startsWith("-"))
{
return -1 * Integer.parseInt(value.substring(1), r);
}
else
{
return Integer.parseInt(value, r);
}
}
catch (Exception e)
{
}
}

return def;
}
}

hostj2me
43 topic(s)
23 post(s)
J2ME: Persistent Properties Utility 0 1924 March 16, 2007 3:53 PM


/*
* Copyright (C) 2006 Astrient Labs, LLC 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.
*
* Astrient Labs, LLC
* www.astrientlabs.com
* rashid@astrientlabs.com
* Rashid Mayes 2006
*/
package com.astrientlabs.prefs;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.Hashtable;

import javax.microedition.rms.RecordEnumeration;
import javax.microedition.rms.RecordStore;
import javax.microedition.rms.RecordStoreNotFoundException;

import com.astrientlabs.log.Logger;

public class PropertyMap extends Hashtable
{
public static final char RECORD_DELIMITER = '=';

private PropertyMap parent;
private String name;

public PropertyMap(String name)
{
this.name = name;
}

public PropertyMap(PropertyMap parent, String name)
{
this.name = name;
this.parent = parent;
}


public void initialize()
{
InputStream is = null;

try
{
is = getClass().getResourceAsStream("/config/"+name+".properties");
parse(is);
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
try
{
if (is != null)
is.close();
}
catch (Exception e)
{
}
}
}

public void parse(InputStream is) throws IOException
{
int b;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
while ((b = is.read()) != -1)
{
if (b == '\n')
{
addLine(new String(baos.toByteArray()).trim());
baos.reset();
}
else
{
if (b != '\n' && b != '\r')
baos.write(b);
}
}

if (baos.size() != 0)
{
addLine(new String(baos.toByteArray()).trim());
}
}

private void addLine(String line)
{
if (line.charAt(0) != '#')
{
int ii = line.indexOf(RECORD_DELIMITER);
if (ii != -1 && ii != (line.length() - 1))
{
put(line.substring(0, ii), line.substring(ii + 1));
}
}
}


public void delete()
{
String recordStoreName = "props-"+name;
try
{
RecordStore.deleteRecordStore(recordStoreName);
}
catch (RecordStoreNotFoundException e)
{
}
catch (Exception e)
{
Logger.instance.log("propertyMap.delete()",e);
}
}


public void read()
{
String recordStoreName = "props-"+name;
RecordStore preferenceDB = null;

try
{
preferenceDB = RecordStore.openRecordStore(recordStoreName, false);
RecordEnumeration renum = preferenceDB.enumerateRecords(null, null, false);

while (renum.hasNextElement())
{
addLine(new String(renum.nextRecord()));
}
}
catch (RecordStoreNotFoundException e)
{
}
catch (Exception e)
{
Logger.instance.log("propertyMap.read()",e);
}
finally
{
try
{
if (preferenceDB != null)
{
preferenceDB.closeRecordStore();
}
}
catch (Exception e)
{
}
}
}


public void write()
{
String recordStoreName = "props-"+name;
RecordStore recordStore = null;


try
{
delete();

if (!isEmpty())
{
recordStore = RecordStore.openRecordStore(recordStoreName, true);

Object key;
byte[] bytes;

StringBuffer buffer = new StringBuffer();
Enumeration keys = keys();
while (keys.hasMoreElements())
{
key = keys.nextElement();
buffer.append(key);
buffer.append(RECORD_DELIMITER);
buffer.append(get(key));

bytes = buffer.toString().getBytes();

recordStore.addRecord(bytes, 0, bytes.length);
buffer.setLength(0);
}
}

Logger.instance.log("propertyMap.write()",name + " saved to " + recordStoreName);
}
catch (Exception e)
{
Logger.instance.log("propertyMap.write().1",e);
}
finally
{
try
{
if (recordStore != null)
{
recordStore.closeRecordStore();
}
}
catch (Exception e)
{
Logger.instance.log("propertyMap.write().2",e);
}
}
}

//TODO: only strings
public Object put(Object arg0, Object arg1)
{
return super.put(arg0.toString(), arg1.toString());
}

public String get(String name)
{
String value = (String) super.get(name);
if ( value == null )
{
return (parent == null) ? null : parent.get(name);
}
else
{
return value;
}
}


public String get(String name, String def)
{
String value = get(name);
return (value == null) ? def : String.valueOf(value);
}

public boolean getBoolean(String name, boolean def)
{
String value = get(name);
return (value == null) ? def : value.equalsIgnoreCase("true");
}

public int getInt(String name, int def)
{
String value = get(name);
if (value != null)
{
try
{
if (value.startsWith("-"))
{
return -1 * Integer.parseInt(value.substring(1));
}
else
{
return Integer.parseInt(value);
}
}
catch (Exception e)
{
}
}

return def;
}


public int getInt(String name, int def, int r)
{
String value = get(name);
if (value != null)
{
try
{
if (value.startsWith("-"))
{
return -1 * Integer.parseInt(value.substring(1),r);
}
else
{
return Integer.parseInt(value,r);
}
}
catch (Exception e)
{
}
}

return def;
}
}

©2008 WorldDeveloper.org - PO Box 310575 Miami, FL 33231

WorldDeveloper.org is a managed social network for application developers around the world.