Help with API implementation!
Dear All,
I should be grateful if you could shed some light on the implementation of the public int read(b[], int off, int len) throws IOException method present in the ByteArrayInputStream class in java.io, since the definition, in my opinion is a bit awkward. infact it says that in order to find out the number of byte read, you have to add k, which is the length of bytes read to pos, the index + 1.
Having access to the implementations of methods in the API, would definitely make a better programmer, I think.
Thanks for you help!
Luka
The Javadoc comment for read isn't very good since it also tells you how it's implemented rather than simply what it does.
All you need to know to use it is this:
1) you tell it the number of bytes to read
2) it returns the actual number of bytes read, k
3) the bytes read will start at b[k]
The source for all the core classes is available if you really want to look at it. It's in a file called src.zip or src.jar located in the installation directory of your J2SDK.
Hope this helps.
Similar Messages
-
Our company has decided to use Business Catalyst but we need help with an activation wizard for our product. This activation is also used to create a recurring monthly billing order.
We're thinking we need to use the API, here's our basic flow:
Customer Clicks Activation Button
Prompted to Login or Register
Customer looks up unit number (Can be called via a provider API)
Unit number is placed into field
Customer fills in billing information (or can it be pulled via BC API?)
Name
Address
Phone
Email
Credit Card Info
Order is sent to BusinessCatalyst WebServices API to create recurring order
Billing Information is attached to Provider Database via API
Customer is forwarded to Subscription_thank_you page (url to be determined later)
Our team has never worked with the BC API and would like to know the best route to handle this scenario...should we embed the application in an iframe and put the iframe on a page in a secure zone or should we use the API to push user information from our BC site to an app residing on a subdomain? If anyone has experience with this type of situation or can point us to someone that has, please let me know, it would be greatly appreciated!
Thanks,
AndyOk, we have a solution in the works that includes javascript, but would like to know if we can pass custom arguments through the /FormProcessv2.aspx script.url so that we could invoke a different receipt - buy page based on url arguments. We would want to include two hidden field entries that we will be including in the form and will add them using a custom onclick event for the check out form submit button. This would allow the javascript planted on the receipt - buy page to know what path the buyer is coming from. We'll have buyers that are buying the normal route, simply adding items to their cart, but will also have people activating their device which includes purchasing a recurring product for which we will use javascript to automatically add to cart. The receipt - buy page will stay in the original form for all buyers simply adding items to their cart and purchasing, but will change when they are activating. The passed url arguments will tell our javascript which type of customer they are and will load the page accordingly. Will /FormProcessv2.aspx strip out our customer arguments and resort back to the default?
Thanks,
Andy -
Hi,
I have a school project to do about a digitial circuit simulator.
i am done most of the parts but i am having a problem with the junit.FrameWork.assert library. The following code gives me an error near assertFalse.
public void testSimpleLine() {
LineParser p = new LineParser();
p.parse("Nand inputInv outputInv");
Node n = Node.getNodeForName("inputInv");
assertFalse(n==null);
n = Node.getNodeForName("outputInv");
assertFalse(n==null);
Can anyone help me resolve the problempublic class LineParser extends Object
private Simulator simulator = Simulator.getInstance();
public void parse(String line)
char[] nodenames = new char[100];
String [] words = line.split(" ");
if (words[0].equalsIgnoreCase("nand2"))
nandoperator(words[1], words[2], words[3]);
else if (words[0].equalsIgnoreCase("inv"))
inv(words[1], words[2]);
else if (words[0].equalsIgnoreCase("set"))
//simulator.addEvent(new Event(words[1], words[2], words[3]));
else
System.out.println ("Invalid request!!");
public void simulation ()
/* Simulation loop:
* This is "boiler-plate" code; there is no need to change
* it.
Event e;
int numEvents = 0;
int maxNE = 100;
for(; (e = simulator.deleteNextEvent()) != null && numEvents < maxNE;
numEvents++) {
System.out.println("Handling event setting Node \t" + e.getNode() +
"\t to " + e.getValue() +
" at " + e.getTime());
// Inform Node
Node node = e.getNode();
node.setValue(e.getValue());
System.out.println("\nSIMULATION FINISHED");
System.out.println(numEvents + " Events handled");
if (numEvents >= maxNE)
System.out.println("Simulation stopped because " +
"max number of events met");
private void nandoperator(String inputone, String inputtwo, String output)
//make the nand2 nodes
Node one = new Node (0, inputone);
Node two = new Node (0, inputtwo);
Node onenandtwo = new Node (1, output);
//make the nand2 block
Node [] insNand2 = {one, two};
//Create an array of the input Node(s)
Block nand2 = new Nand(insNand2, onenandtwo, 10); //Create the Block
private void inv (String input, String output)
Node one = new Node (0, input);
Node notone = new Node (1, output);
Node [] insNand1 = {one}; //Create an array of the input Node(s)
Block nand1 = new Nand(insNand1, notone, 10); //Create the Block
} -
Want help with badi implementation?
Hi experts,
I m new to BADI'S.I got a requirement to get a sub-screen to the standard transaction MFBF.The subscreen will be having 2 fields personnel number and personnel name. For this the functional guy told me to activate the badi rm_hr_integration to get the sub-screen.If the badi is activated he said we get the above mentioned 2 fields as columns in the table control in the selection screen of transaction MF42N. What should i do to activate the badi?If i activate the badi will i get the require sub screen?Do i need to write any additonal code?
Please anyone suggest me the soln with some procedural steps.sloutions will be rewarded with points.
Thanks,
dp.Hi Nagaraj,
Thanks for the reply. I created the implementation for the badi and activated the badi.Then i run the transaction MFBF to see whether i got a subscreen but i there is no change.In the implementation of the badi there is a tab for subscreen.In that tab there are some fields to fill.The fields call program and screen no are filled automatically with values SAPLBARM and 800 respectively.There are 2 more fields to fill called program and screen no.What i have to fill in those fields?any suggestions?
Thanks,
dp. -
Need help with the implementation of below DLL in LabVIEW Call Lib function
Here is the list of C functions in the doc that I have but I'm not getting the exact output.
I need a help only to understand these functions and how to configure it in LabVIEW
Parameters
voltType
[in]Specifies a voltage sensor to get value from. It can be one of the flags
VCORE (1<<0)
V25 (1<<1)
V33 (1<<2)
V50 (1<<3)
V120 (1<<4)
VSB (1<<5)
VBAT (1<<6)
VN50 (1<<7)
VN120 (1<<8)
VTT (1<<9)
retval
[out]Point to a variable in which this function returns the voltage in Volt.
Typesupport
[out]
If the value is specified as a pointer (non-NULL) to a variable, it will return the types of available sensors in flags bitwise-ORed
Return Value
TRUE (1) indicates success; FALSE (0) indicates failure.
Remarks
Call the function first with a non-NULL typesupport to know the available fan sensors and a following call to get the voltage required.
=========================================
Please remember to accept a solutions and show your appreciation by giving Kudos to helpful messages...
Mangesh D.
CLAD | Project Engineer
==
VIPM, LabVIEW 8.2, 2009, 2011SP1, 2012, 2012SP1, 2013, cRIO,cDAQ, PXI, ELVIS, Multisim, Smart Camera....
Solved!
Go to Solution.ManLD wrote:
Here is the list of C functions in the doc that I have but I'm not getting the exact output.
I need a help only to understand these functions and how to configure it in LabVIEW
Parameters
voltType
[in]Specifies a voltage sensor to get value from. It can be one of the flags
VCORE (1<<0)
V25 (1<<1)
V33 (1<<2)
V50 (1<<3)
V120 (1<<4)
VSB (1<<5)
VBAT (1<<6)
VN50 (1<<7)
VN120 (1<<8)
VTT (1<<9)
retval
[out]Point to a variable in which this function returns the voltage in Volt.
Typesupport
[out]
If the value is specified as a pointer (non-NULL) to a variable, it will return the types of available sensors in flags bitwise-ORed
Return Value
TRUE (1) indicates success; FALSE (0) indicates failure.
Remarks
Call the function first with a non-NULL typesupport to know the available fan sensors and a following call to get the voltage required.
The parameter describtion you show is useless. It tells absolutely nothing about the actual data types used nor how those parameters are exactly supposed to be passed. Show us at least the function prototype too!
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions -
Need help with API and sample code for checking a user's rights on a folder
Hi All,
I am working on an UCM integration where user supplies a folderpath (ucm folders), and a file is later uploaded to this location.
Since a user can provide a folderpath where he has only Read Access or no access at all, we are trying to work out a way to pre-check his permissions on the folder.
Since we have Entity Security enabled, we have 5 security fields to rely on Account, Security Group, User Access List, Group Access List, Role Access List.
Writing custom code for this security check is second on our agenda.
Firstly, we wish to know the API and sample code that typically performs this Security Check in UCM.
We could find intradoc.shared.SecurityUtils which has methods to check security on SGroup and Account, but we couldn't find anything for:
1) Overall security check
2) ACL security check on top of sgroup and account security checkAny ideas anyone?!
I am looking forward to some pointers here. :( -
Need help with API for contract creation
Hi,
Using OKS_IBINT_PUB.IB_INTERFACE API, how do I populate the Known As (COGNOMEN) column of okc_k_headers_tl? The API does not provide any parameter for this. I can resort to a direct update to the table, but this API does not return any contract information(ID) based on which I can safely update the record.
TIA,
Alka.Hi,
You got to define the Document Types in the System Setup form of OKE at Setup --> System Setup, then you could eneter type of a Contarct.
Master Agreement is the Basic Ordering Agreement, Master Purchase Agreement or Blanket Agreement.
Item master Org and OU - pls refr user guide and implemebntation guide at http://download.oracle.com/docs/cd/B25284_01/current/html/docset.html
Thanks,
Kiran -
Want a complete migration guide to upgrade 11.1.0.7 to 11.2.0.3 database using DBUA..We are implementing R12.1.3 version and then have to migrate the default 11gR1 database to 11.2.0.3 version. Please help with some step by step docs
Upgrade to 11.2.0.3 -- Interoperability Notes Oracle EBS R12 with Oracle Database 11gR2 (11.2.0.3) (Doc ID 1585578.1)
Upgrade to 11.2.0.4 (latest 11gR2 patchset certified with R12) -- Interoperability Notes EBS 12.0 and 12.1 with Database 11gR2 (Doc ID 1058763.1)
Thanks,
Hussein -
To get list of permissions for iview/apps with the help of API (UME API?)
hello all
who can answer how to get list of permissions (list of roles or users) for iview or other application with the help of API (UME API ?)
thanx!if anybody whant to know
https://media.sdn.sap.com/html/submitted_docs/60_sp2_javadocs/ume/com/sap/security/api/acl/IAclManager.html#getAcl(java.lang.String)
https://media.sdn.sap.com/html/submitted_docs/60_sp2_javadocs/ume/com/sap/security/api/IRole.html -
Help with implementing two different programs
I need help with a couple of Java programs that I downloaded. I hope someone can help me. They work great if they're on their own, but if they are both on the same page, the 2nd one works, and the 1st one stops working. I'm pretty new to Java, so I don't know how to debug it too well.. Here's the 1st program:
Conveyor belt slideshow script-
? Dynamic Drive (www.dynamicdrive.com)
For full source code, 100's more DHTML scripts, and Terms Of Use, visit dynamicdrive.com
//Specify the slider's width (in pixels)
var sliderwidth="250px"
//Specify the slider's height
var sliderheight="19px"
//Specify the slider's slide speed (larger is faster 1-10)
var slidespeed=2
//configure background color:
slidebgcolor=""
//Specify the slider's images
var leftrightslide=new Array()
var finalslide=''
leftrightslide[0]='<img src="images/movingwords.gif">'
////NO NEED TO EDIT BELOW THIS LINE////////////
var copyspeed=slidespeed
leftrightslide='<nobr>'+leftrightslide.join(" ")+'</nobr>'
var iedom=document.all||document.getElementById
if (iedom)
//Next line edited for readability
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100px;left:-9000px">
'+leftrightslide+'</span>')
var actualwidth=''
var cross_slide, ns_slide
function fillup(){
if (iedom){
cross_slide=document.getElementById? document.getElementById("test2") : document.all.test2
cross_slide2=document.getElementById? document.getElementById("test3") : document.all.test3
cross_slide.innerHTML=cross_slide2.innerHTML=leftrightslide
actualwidth=document.all? cross_slide.offsetWidth : document.getElementById("temp").offsetWidth
cross_slide2.style.left=actualwidth+20+"px"
else if (document.layers){
ns_slide=document.ns_slidemenu.document.ns_slidemenu2
ns_slide2=document.ns_slidemenu.document.ns_slidemenu3
ns_slide.document.write(leftrightslide)
ns_slide.document.close()
actualwidth=ns_slide.document.width
ns_slide2.left=actualwidth+20
ns_slide2.document.write(leftrightslide)
ns_slide2.document.close()
lefttime=setInterval("slideleft()",30)
window.onload=fillup
function slideleft(){
if (iedom){
if (parseInt(cross_slide.style.left)>(actualwidth*(-1)+8))
cross_slide.style.left=parseInt(cross_slide.style.left)-copyspeed+"px"
else
cross_slide.style.left=parseInt(cross_slide2.style.left)+actualwidth+30+"px"
if (parseInt(cross_slide2.style.left)>(actualwidth*(-1)+8))
cross_slide2.style.left=parseInt(cross_slide2.style.left)-copyspeed+"px"
else
cross_slide2.style.left=parseInt(cross_slide.style.left)+actualwidth+30+"px"
else if (document.layers){
if (ns_slide.left>(actualwidth*(-1)+8))
ns_slide.left-=copyspeed
else
ns_slide.left=ns_slide2.left+actualwidth+30
if (ns_slide2.left>(actualwidth*(-1)+8))
ns_slide2.left-=copyspeed
else
ns_slide2.left=ns_slide.left+actualwidth+30
if (iedom||document.layers){
with (document){
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
if (iedom){
write('<div style="position:relative;width:'+sliderwidth+';height:'+sliderheight+';overflow:hidden">')
//Next line edited for readability
write('<div style="position:absolute;width:'+sliderwidth+';height:'+sliderheight+';
background-color:'+slidebgcolor+'" onMouseover="copyspeed=0" onMouseout="copyspeed=slidespeed">')
write('<div id="test2" style="position:absolute;left:0px;top:0px"></div>')
write('<div id="test3" style="position:absolute;left:-1000px;top:0px"></div>')
write('</div></div>')
else if (document.layers){
write('<ilayer width='+sliderwidth+' height='+sliderheight+' name="ns_slidemenu" bgColor='+slidebgcolor+'>')
write('<layer name="ns_slidemenu2" left=0 top=0 onMouseover="copyspeed=0" onMouseout="copyspeed=slidespeed"></layer>')
write('<layer name="ns_slidemenu3" left=0 top=0 onMouseover="copyspeed=0" onMouseout="copyspeed=slidespeed"></layer>')
write('</ilayer>')
document.write('</td></table>')
}Here's the 2nd program:
//Fade-in image slideshow- By Dynamic Drive
//For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
//This credit MUST stay intact for use
var slideshow_width='305px' //SET IMAGE WIDTH
var slideshow_height='152px' //SET IMAGE HEIGHT
var pause=5000 //SET PAUSE BETWEEN SLIDE (3000=3 seconds)
var fadeimages=new Array()
//SET IMAGE PATHS. Extend or contract array as needed
fadeimages[0]="images/Computer Retail Store.jpg"
fadeimages[1]="images/Computer S&S ad.jpg"
fadeimages[2]="images/Computer S&S ad 2.jpg"
fadeimages[3]="images/Phone S&S ad.jpg"
////NO need to edit beyond here/////////////
var preloadedimages=new Array()
for (p=0;p<fadeimages.length;p++){
preloadedimages[p]=new Image()
preloadedimages[p].src=fadeimages[p]
var ie4=document.all
var dom=document.getElementById
if (ie4||dom)
//Next line edited for readability
document.write('<div style="position:relative;width:'+slideshow_width+';height:'+slideshow_height+';overflow:hidden">
<div id="canvas0" style="position:absolute;width:'+slideshow_width+';height:'+slideshow_height+';top:0;left:0;filter:
alpha(opacity=10);-moz-opacity:10"></div><div id="canvas1" style="position:absolute;width:'+slideshow_width+';
height:'+slideshow_height+';top:0;left:0;filter:
alpha(opacity=10);-moz-opacity:10"></div></div>')
else
document.write('<img name="defaultslide" src="'+fadeimages[0]+'">')
var curpos=10
var degree=10
var curcanvas="canvas0"
var curimageindex=0
var nextimageindex=1
function fadepic(){
if (curpos<100){
curpos+=10
if (tempobj.filters)
tempobj.filters.alpha.opacity=curpos
else if (tempobj.style.MozOpacity)
tempobj.style.MozOpacity=curpos/100
else{
clearInterval(dropslide)
nextcanvas=(curcanvas=="canvas0")? "canvas0" : "canvas1"
tempobj=ie4? eval("document.all."+nextcanvas) : document.getElementById(nextcanvas)
tempobj.innerHTML='<img src="'+fadeimages[nextimageindex]+'">'
nextimageindex=(nextimageindex<fadeimages.length-1)? nextimageindex+1 : 0
setTimeout("rotateimage()",pause)
function rotateimage(){
if (ie4||dom){
resetit(curcanvas)
var crossobj=tempobj=ie4? eval("document.all."+curcanvas) : document.getElementById(curcanvas)
crossobj.style.zIndex++
var temp='setInterval("fadepic()",50)'
dropslide=eval(temp)
curcanvas=(curcanvas=="canvas0")? "canvas1" : "canvas0"
else
document.images.defaultslide.src=fadeimages[curimageindex]
curimageindex=(curimageindex<fadeimages.length-1)? curimageindex+1 : 0
function resetit(what){
curpos=10
var crossobj=ie4? eval("document.all."+what) : document.getElementById(what)
if (crossobj.filters)
crossobj.filters.alpha.opacity=curpos
else if (crossobj.style.MozOpacity)
crossobj.style.MozOpacity=curpos/100
function startit(){
var crossobj=ie4? eval("document.all."+curcanvas) : document.getElementById(curcanvas)
crossobj.innerHTML='<img src="'+fadeimages[curimageindex]+'">'
rotateimage()
if (ie4||dom)
window.onload=startit
else
setInterval("rotateimage()",pause)Like I said, if the 2nd program is put the same page with the 1st, the 1st program stops working. Any ideas? I would really like to implement both of these programs.The code you post is javascript, NOT java ! ... but either way, maybe the scripts have variables in conflict, so if you pack each piece of code in diferent functions and then you call the functions it may work.
-
PI File adapter has a processing option u2018Empty-Message Handlingu2019 to ignore or Write Empty Files. In case there is no data created after mapping on target side then this option determines whether to write an empty file or not. But there is a catch to this option when it comes to using it with File Content Conversion which is described in SAP Note u2018821267u2019. It states following:
I configure the receiver channel with File content conversion mode and I set the 'Empty Message Handling' option to ignore. Input payload to the receiver channel is generated out of mapping and it does not have any record sets. However, this payload has a root element. Why does file receiver create empty output file with zero byte size in the target directory? Example of such a payload generated from mapping is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<ns1:test xmlns:ns1="http://abcd.com/ab"></ns1:test>
solution :
If the message payload is empty (i.e., zero bytes in size), then File adapter's empty message handling feature does NOT write files into the target directory. On the other hand, if the payload is a valid XML document (as shown in example) that is generated from mapping with just a root element in it, the File Adapter does not treat it as an empty message and accordingly it writes to the target directory. To achieve your objective of not writing files (that have just a single root element) into the target directory, following could be done:
Using a Java or ABAP Mapping in order to restrict the creation of node itself during mapping. (This cannot be achieved via Message Mapping)
Using standard adapter modules to do content conversion first and then write file.
can someone help with java mapping that can be used in this case?Hi,
You have not mentioned the version of PI you are working in. In case you are working with PI 7.1 or above then here is the java mapping code you need to add after message mapping in the same interface mapping
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import com.sap.aii.mapping.api.AbstractTransformation;
import com.sap.aii.mapping.api.StreamTransformationException;
import com.sap.aii.mapping.api.TransformationInput;
import com.sap.aii.mapping.api.TransformationOutput;
public class RemoveRootNode extends AbstractTransformation{
public void execute(InputStream in, OutputStream out)
throws StreamTransformationException {
// TODO Auto-generated method stub
try
DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
DocumentBuilder builderel=factory.newDocumentBuilder();
/*input document in form of XML*/
Document docIn=builderel.parse(in);
/*document after parsing*/
Document docOut=builderel.newDocument();
TransformerFactory tf=TransformerFactory.newInstance();
Transformer transform=tf.newTransformer();
if(docIn.getDocumentElement().hasChildNodes())
docOut.appendChild(docOut.importNode(docIn.getDocumentElement(),true));
transform.transform(new DOMSource(docOut), new StreamResult(out));
else
out.write(null);
catch(Exception e)
public void setParameter(Map arg0) {
// TODO Auto-generated method stub
public static void main(String[] args) {
// TODO Auto-generated method stub
try{
RemoveRootNode genFormat=new RemoveRootNode();
FileInputStream in=new FileInputStream("C:\\apps\\sdn\\rootNode.xml");
FileOutputStream out=new FileOutputStream("C:\\apps\\sdn\\rootNode1.xml");
genFormat.execute(in,out);
catch(Exception e)
e.printStackTrace();
public void transform(TransformationInput arg0, TransformationOutput arg1)
throws StreamTransformationException {
// TODO Auto-generated method stub
this.execute(arg0.getInputPayload().getInputStream(), arg1.getOutputPayload().getOutputStream());
In case you are working in PI 7.0 you can use this code
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import com.sap.aii.mapping.api.StreamTransformation;
import com.sap.aii.mapping.api.StreamTransformationException;
public class RemoveRootNode implements StreamTransformation{
public void execute(InputStream in, OutputStream out)
throws StreamTransformationException {
// TODO Auto-generated method stub
try
DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
DocumentBuilder builderel=factory.newDocumentBuilder();
/*input document in form of XML*/
Document docIn=builderel.parse(in);
/*document after parsing*/
Document docOut=builderel.newDocument();
TransformerFactory tf=TransformerFactory.newInstance();
Transformer transform=tf.newTransformer();
if(docIn.getDocumentElement().hasChildNodes())
docOut.appendChild(docOut.importNode(docIn.getDocumentElement(),true));
transform.transform(new DOMSource(docOut), new StreamResult(out));
else
out.write(null);
catch(Exception e)
public void setParameter(Map arg0) {
// TODO Auto-generated method stub
public static void main(String[] args) {
// TODO Auto-generated method stub
try{
RemoveRootNode genFormat=new RemoveRootNode();
FileInputStream in=new FileInputStream("C:\\apps\\sdn\\rootNode.xml");
FileOutputStream out=new FileOutputStream("C:\\apps\\sdn\\rootNode1.xml");
genFormat.execute(in,out);
catch(Exception e)
e.printStackTrace();
The code for PI 7.0 should also work for PI 7.1 provided you use the right jar files for compilation, but vice-versa is not true.
Could you please let us know if this code was useful to you or not?
Regards
Anupam
Edited by: anupamsap on Dec 15, 2011 9:43 AM -
Hi all
I am developing a j2me program that need display photos on a form like a photo gallery. I use image item to hold the resized photos on a form.
What I want is to display 3 photos in a row, like this
x x x
x x x
the programm is working fine on the emulator and nokia phone, but when I try on a Windows Mobile phone (HTC the JVM is Jbed) , It only display one photo in a row, like this
X
X
X
No matter what layout option and the size of photos, it only display one photo in a row
I really need help with this
ThanksThe only way to get more consistent behavior across devices is to use the low level API -- Canvas, not Form. You cannot interfere with device-dependent implementations of the layout of a Form.
db -
Help with treemap and other stuff
hi guys..
i m new to this forum..
and this is my first post....so if i act a little naive .....please bare with me.
and if this is not the correct place to post ..i m sorry for that.
i have an assignment to submit....i m getting the whole picture ....but not sure how to go about implementing it.
here it is...
Write an Object Oriented solution to the problem in Java. The solution is to consist of:
A TableIndex class
A TableNavigator Interface
A data row class ....class that i have to create.
An application class to use and test your TableIndex class
The following UML class diagrams show the public methods of the classes. Other methods may be specified. Specify data members, inner classes and interfaces as appropriate.
TableIndex Class
The TableIndex class is an index to a collection of objects. The class is to approximate an index to a data table in memory that consists of a number of rows. To control access to the index a current row is defined that specifies the row that can be accessed. To retrieve a row from the index it must be the current row. The get() method is the only method in TableIndex class that retrieves a row from the index. The current row can be changed explicitly using the methods: previous(), next(), first(), last(), gotoBookmark and find(K); and implicitly using insert(K, V), modify(K, V) and remove().
The TableIndex class is to be implemented using the java API's TreeMap class and must use Generics. The data types K and V below are generic types for the Key and Value (row) respectively. An important aspect of the assignment is using the Java API documentation to understand the TreeMap class.
guys ....can u plz help with the starting bit ..
what should be the opening statement of the class...
public class TableIndex<K , V> .....????
and what should be the treemap declaration..??
TreeMap<K , V> indexTable = new TreeMap<K , V>();...???
i m confused....
can u plz explain to me..hi mate.....didnt quite get you..
can u plz be a bit more simple in explanation..!!!
i will post the whole question ..so that anyone reading will understand better....
Problem Description
You are to develop an index class and associated classes.
Requirements
Write an Object Oriented solution to the problem in Java. The solution is to consist of:
A TableIndex class
A TableNavigator Interface
A data row class
An application class to use and test your TableIndex class
The following UML class diagrams show the public methods of the classes. Other methods may be specified. Specify data members, inner classes and interfaces as appropriate.
TableIndex Class
The TableIndex class is an index to a collection of objects. The class is to approximate an index to a data table in memory that consists of a number of rows. To control access to the index a current row is defined that specifies the row that can be accessed. To retrieve a row from the index it must be the current row. The get() method is the only method in TableIndex class that retrieves a row from the index. The current row can be changed explicitly using the methods: previous(), next(), first(), last(), gotoBookmark and find(K); and implicitly using insert(K, V), modify(K, V) and remove().
The TableIndex class is to be implemented using the java API's TreeMap class and must use Generics. The data types K and V below are generic types for the Key and Value (row) respectively. An important aspect of the assignment is using the Java API documentation to understand the TreeMap class.
TableIndex
+TableIndex()
+TableIndex(name: String, comp: Comparator)
+getName(): String
+isEmpty(): Boolean
+size(): Integer
+hasPrevious(): Boolean
+hasNext(): Boolean
+previous()
+next()
+first()
+last()
+setBookmark(): Boolean
+clearBookmark()
+gotoBookmark(): Boolean
+contains(key: K): Boolean
+find(key: K): Boolean
+get(): V
+insert(key:K, value: V): Boolean
+modify(value: V): Boolean
+modify(key: K, value: V): Boolean
+remove(): V
+iterator(): Iterator
+equals(obj2: Object): Boolean
+toString(): String
Additional Notes:
The table index has an order defined by the compareTo method of the key's class or by the compare method specified in the class that implements the Comparator interface.
getName(): the name of the index, blank by default.
isEmpty(): returns true if there aren't any rows in the table index
size(): returns the number of rows in the table index
hasPrevious(): returns true if there is a row before the current row.
hasNext(): returns true if there is a row after the current row in sequence.
previous(): if there is a row before the current row, move to the row and make it the new current row.
next() if there is a row after the current row, move to the row and make it the new current row.
first(): if the table isn't empty, move to the first row and make it the new current row.
last(): if the table isn't empty, move to the last row and make it the new current row.
setBookmark(): sets a bookmark at the current row. If the bookmark is successfully set the method returns true. The bookmark is cleared if the TableIndex is empty or the row the bookmark was set on is deleted..
clearBookmark(): sets the bookmark to null, indicating there isn't a bookmark.
gotoBookmark(): if a bookmark has been set, go to the bookmarked row. If successful the book marked row becomes the current row and the method returns true.
contains(K): return true if a row with the key specified exists.
find(K): if a row is found with the specified key, the current row is set to the row found.
get(): returns the current row. Null is returned if there isn't a current row.
insert(K, V): inserts a row (value) with the key specified. The key must not be null and must be unique (not already in the TableIndex). The row (value) must not be null. If the row is successfully inserted true is returned, and the row becomes the current row..
modify(V): change the current row's data to the row (value) specified. The key and the current row key are to remain the same. If successful true is returned.
modify(K, V): change the current row's key and data to the key and row (value) specified. If successful the changed row becomes the new current row. If successful true is returned. Note: this is more difficult than modify(V).
remove(): remove the current row. When a row is deleted the next row (if available) becomes the current row, otherwise if there isn't a next row the previous row becomes the current row, otherwise the table is empty therefore the current row is null.
iterator(): returns an iterator to the rows (values) in the index. The rows are to be retrieved in order. The remove method does not need to be implemented (its method body can be empty)..
the equals method uses the name, and the rows (values) in order when testing for equality.
the toString method should return appropriately formatted data members and the rows (values/data) in the index.
TableNavigator Interface
«interface»
TableNavigator
+isEmpty(): Boolean
+hasPrevious(): Boolean
+hasNext(): Boolean
+previous()
+next()
+first()
+last()
+contains(key: K): Boolean
+find(key: K): Boolean
Additional Notes:
The TableIndex class implements the TableNavigator Interface.
The purpose of the above methods is outlined in the TableIndex class.
Your Data Row Class
You are to include a class of your own to represent a row of data in the TableIndex. This is not to be a class that was covered in other programming subjects. It does not need to be complex but must include a range of data types. This class will be used to test your TableIndex class. The class should have an appropriate name and deal with something of interest to you.
Your Application Class
The application class is to make use of the TableIndex class and your data row class. It is to clearly show how the TableIndex class is used, and in doing so, test it. The class should have an appropriate name. The application class should create two indexes of different key data types. One of the indexes must make use of the Comparator interface to have a key that is in descending order.
Output
Output in the test classes/programs is to go to standard out or a text file. There should be no output from the TableIndex class or your data row class. A GUI interface is NOT required. There is no need to input data from the keyboard or file. Use the Unix script command or write output to a text file (etc) to provide example runs of your test programs. -
Basic Help regarding JavaTV implementation
Hi,
I am very new to JavaTV and even to SetTopBox Domain. I want to implement the org.davic.* packages.
could anyone suggest me how shud I proceed with the implementation of API provided in this package?
Or is there any example showing the implementation of these packages are available.
Thanks & Regards
raj@tataHi
Currently, public davic implementation packege locates in the url "http://xletview.sourceforge.net/". I have never seen another site.
Xletview is mhp emulator under gnu.
All davic implementation is not ended. You check it out though http://xletview.sourceforge.net/status/status-current.html.
I hope to help you
Sincerely
YongHwan -
Need help with JTextArea and Scrolling
import java.awt.*;
import java.awt.event.*;
import java.text.DecimalFormat;
import javax.swing.*;
public class MORT_RETRY extends JFrame implements ActionListener
private JPanel keypad;
private JPanel buttons;
private JTextField lcdLoanAmt;
private JTextField lcdInterestRate;
private JTextField lcdTerm;
private JTextField lcdMonthlyPmt;
private JTextArea displayArea;
private JButton CalculateBtn;
private JButton ClrBtn;
private JButton CloseBtn;
private JButton Amortize;
private JScrollPane scroll;
private DecimalFormat calcPattern = new DecimalFormat("$###,###.00");
private String[] rateTerm = {"", "7years @ 5.35%", "15years @ 5.5%", "30years @ 5.75%"};
private JComboBox rateTermList;
double interest[] = {5.35, 5.5, 5.75};
int term[] = {7, 15, 30};
double balance, interestAmt, monthlyInterest, monthlyPayment, monPmtInt, monPmtPrin;
int termInMonths, month, termLoop, monthLoop;
public MORT_RETRY()
Container pane = getContentPane();
lcdLoanAmt = new JTextField();
lcdMonthlyPmt = new JTextField();
displayArea = new JTextArea();//DEFINE COMBOBOX AND SCROLL
rateTermList = new JComboBox(rateTerm);
scroll = new JScrollPane(displayArea);
scroll.setSize(600,170);
scroll.setLocation(150,270);//DEFINE BUTTONS
CalculateBtn = new JButton("Calculate");
ClrBtn = new JButton("Clear Fields");
CloseBtn = new JButton("Close");
Amortize = new JButton("Amortize");//DEFINE PANEL(S)
keypad = new JPanel();
buttons = new JPanel();//DEFINE KEYPAD PANEL LAYOUT
keypad.setLayout(new GridLayout( 4, 2, 5, 5));//SET CONTROLS ON KEYPAD PANEL
keypad.add(new JLabel("Loan Amount$ : "));
keypad.add(lcdLoanAmt);
keypad.add(new JLabel("Term of loan and Interest Rate: "));
keypad.add(rateTermList);
keypad.add(new JLabel("Monthly Payment : "));
keypad.add(lcdMonthlyPmt);
lcdMonthlyPmt.setEditable(false);
keypad.add(new JLabel("Amortize Table:"));
keypad.add(displayArea);
displayArea.setEditable(false);//DEFINE BUTTONS PANEL LAYOUT
buttons.setLayout(new GridLayout( 1, 3, 5, 5));//SET CONTROLS ON BUTTONS PANEL
buttons.add(CalculateBtn);
buttons.add(Amortize);
buttons.add(ClrBtn);
buttons.add(CloseBtn);//ADD ACTION LISTENER
CalculateBtn.addActionListener(this);
ClrBtn.addActionListener(this);
CloseBtn.addActionListener(this);
Amortize.addActionListener(this);
rateTermList.addActionListener(this);//ADD PANELS
pane.add(keypad, BorderLayout.NORTH);
pane.add(buttons, BorderLayout.SOUTH);
pane.add(scroll, BorderLayout.CENTER);
addWindowListener( new WindowAdapter()
public void windowClosing(WindowEvent e)
System.exit(0);
public void actionPerformed(ActionEvent e)
String arg = lcdLoanAmt.getText();
int combined = Integer.parseInt(arg);
if (e.getSource() == CalculateBtn)
try
JOptionPane.showMessageDialog(null, "Got try here", "Error", JOptionPane.ERROR_MESSAGE);
catch(NumberFormatException ev)
JOptionPane.showMessageDialog(null, "Got here", "Error", JOptionPane.ERROR_MESSAGE);
if ((e.getSource() == CalculateBtn) && (arg != null))
try{
if ((e.getSource() == CalculateBtn) && (rateTermList.getSelectedIndex() == 1))
monthlyInterest = interest[0] / (12 * 100);
termInMonths = term[0] * 12;
monthlyPayment = combined * (monthlyInterest / (1 - (Math.pow (1 + monthlyInterest, -termInMonths))));
lcdMonthlyPmt.setText(calcPattern.format(monthlyPayment));
if ((e.getSource() == CalculateBtn) && (rateTermList.getSelectedIndex() == 2))
monthlyInterest = interest[1] / (12 * 100);
termInMonths = term[1] * 12;
monthlyPayment = combined * (monthlyInterest / (1 - (Math.pow (1 + monthlyInterest, -termInMonths))));
lcdMonthlyPmt.setText(calcPattern.format(monthlyPayment));
if ((e.getSource() == CalculateBtn) && (rateTermList.getSelectedIndex() == 3))
monthlyInterest = interest[2] / (12 * 100);
termInMonths = term[2] * 12;
monthlyPayment = combined * (monthlyInterest / (1 - (Math.pow (1 + monthlyInterest, -termInMonths))));
lcdMonthlyPmt.setText(calcPattern.format(monthlyPayment));
catch(NumberFormatException ev)
JOptionPane.showMessageDialog(null, "Invalid Entry!\nPlease Try Again", "Error", JOptionPane.ERROR_MESSAGE);
} //IF STATEMENTS FOR AMORTIZATION
if ((e.getSource() == Amortize) && (rateTermList.getSelectedIndex() == 1))
loopy(7, 5.35);
if ((e.getSource() == Amortize) && (rateTermList.getSelectedIndex() == 2))
loopy(15, 5.5);
if ((e.getSource() == Amortize) && (rateTermList.getSelectedIndex() == 3))
loopy(30, 5.75);
if (e.getSource() == ClrBtn)
rateTermList.setSelectedIndex(0);
lcdLoanAmt.setText(null);
lcdMonthlyPmt.setText(null);
displayArea.setText(null);
if (e.getSource() == CloseBtn)
System.exit(0);
private void loopy(int lTerm,double lInterest)
double total, monthly, monthlyrate, monthint, monthprin, balance, lastint, paid;
int amount, months, termloop, monthloop;
String lcd2 = lcdLoanAmt.getText();
amount = Integer.parseInt(lcd2);
termloop = 1;
paid = 0.00;
monthlyrate = lInterest / (12 * 100);
months = lTerm * 12;
monthly = amount *(monthlyrate/(1-Math.pow(1+monthlyrate,-months)));
total = months * monthly;
balance = amount;
while (termloop <= lTerm)
displayArea.setCaretPosition(0);
displayArea.append("\n");
displayArea.append("Year " + termloop + " of " + lTerm + ": payments\n");
displayArea.append("\n");
displayArea.append("Month\tMonthly\tPrinciple\tInterest\tBalance\n");
monthloop = 1;
while (monthloop <= 12)
monthint = balance * monthlyrate;
monthprin = monthly - monthint;
balance -= monthprin;
paid += monthly;
displayArea.setCaretPosition(0);
displayArea.append(monthloop + "\t" + calcPattern.format(monthly) + "\t" + calcPattern.format(monthprin) + "\t");
displayArea.append(calcPattern.format(monthint) + "\t" + calcPattern.format(balance) + "\n");
monthloop ++;
termloop ++;
public static void main(String args[])
MORT_RETRY f = new MORT_RETRY();
f.setTitle("MORTGAGE PAYMENT CALCULATOR");
f.setBounds(600, 600, 500, 500);
f.setLocationRelativeTo(null);
f.setVisible(true);
}need help with displaying the textarea correctly and the scroll bar please.
Message was edited by:
new2this2020What's the problem you're having ???
PS.
Maybe you are looking for
-
ITunes movies not showing up on Apple TV
I'm having some trouble with my movies not showing up on Apple TV. The movies I am missing are not purchased from iTunes but I have converted them using Handbrake. I've double checked the format and they seem to be what's required from what I've read
-
Problem with hierarchy variable while displaying query in Portal
Hi, I came up with an problem with a query in the portal. The problem is : I have one query which is displayed in the portal. The Query has hierarchial selection criteria. I am executing the same query using analyzer. Its taking the variable from th
-
I want to get copies of the pics on my iWeb but they are not in my iphoto library anymore. Does anyone know how I can get them - easier and faster than downloading my own pics one at a time?
-
@import css support? How to include CSS files in CSS file?
Is it possible to use the @import command in CSS files? Or how to include other CSS files in a main CSS file?
-
Cuando intento ingresar al App Store, nunca carga, lo he reiniciado y nada.