Modularize the java code
Hello All,
I am working on a Java project in eclipse which has the following structure:
package
|---Trie.java
|---TrieImpl.java
|---TrieNode.javaThe main class and the operations on the Trie are methods in 'TrieImpl.java'
In short, the TrieImpl.java file is as:
import.....
public class TrieImpl<T> implements Trie<T>
public boolean delete(String key) {
public void insert(String key, T value) {
public void search(String query, int distance) {
search(root,query,distance,qPos,weight,result,found);
private void search(TrieNode<T> node, String Q, int D, int qIndex, int W, StringBuilder result, boolean found) {
while (found == false && qIndex < Q.length() && W <= D ) {
do something
search(n, Q, D, qIndex, W, result, found); // recursive search
public void static main {
TrieImpl<String> tree = new TrieImpl<String>();
......get the query and distance from the user......
tree.search(query,distance);
}I would like to use Global variables like the boolean variable found in the search function.
for e.g. here are some variables I would like to be global
boolean found
int distance
int qIndex
String Q (the original query string)
StringBuilder result
So that when I set the found to true in any on the search recursions, I can exit the search stack.
The problem right now is that since I am passing the 'found' value at every recursion, each stack has a different boolean value for found.
Some suggestions I googled instructed to create a global class and access the variables with the class identifier.
How can I do that here?
Thanks in advance.
The problem right now is that since I am passing the 'found' value at every recursion, each stack has a different boolean value for found.Why doesn't your method just return a bool to indicate the result?
Similar Messages
-
Test.jsp not able to display the output from the java code.
when i try to invoke http://localhost/papz/test.jsp
I dont see anything. The page is blank. And there are no error messages in any log files. When i click on view source in IE i get to see the entire source code, including the jave code.
<html>
<head>
<title>Test</title>
<body>
<%
out.println("Hello World");
%>
asdfasdfasdf
</body>
</html>
i added in the asdfasdf to see whehter it will be printed or not... It does print that stuff out.
when i try to invoke the login.jsp page, i get the dialog box "save this file to disk"
Any clues whats going on...?
I followed the instructions...over and over again... but it doesnt seem to help.
win nt 4.0
apache 1.3.12
jserv 1.1.1
Pls help. ThanksHi,
Have you solved your problem?
I4m trying to do the same, but I installed portal 30, then portal to go, and when I try to run test.jsp I get the following error:
Request URI:/papz/test.jsp
Exception:
java.lang.NoSuchMethodError: oracle.jsp.util.JspUtil: method
stripTarget(Ljava/lang/String;C)Ljava/lang/String; not found
Thanks
Pablo Lopera
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by NewBie:
when i try to invoke http://localhost/papz/test.jsp
I dont see anything. The page is blank. And there are no error messages in any log files. When i click on view source in IE i get to see the entire source code, including the jave code.
<html>
<head>
<title>Test</title>
<body>
<%
out.println("Hello World");
%>
asdfasdfasdf
</body>
</html>
i added in the asdfasdf to see whehter it will be printed or not... It does print that stuff out.
when i try to invoke the login.jsp page, i get the dialog box "save this file to disk"
Any clues whats going on...?
I followed the instructions...over and over again... but it doesnt seem to help.
win nt 4.0
apache 1.3.12
jserv 1.1.1
Pls help. Thanks<HR></BLOCKQUOTE>
null -
How to generate the java code of a table's data model by parsing it's FXML?
I have know how to create FXML file that describes a table. Meanwhile, according to [Oracle Tutorial|http://docs.oracle.com/javafx/2/fxml_get_started/fxml_tutorial_intermediate.htm#CACFEHBI], it is a best practice to implement a class that defines the data model and provides methods and fields to further work with the table.
However, It's rather cumbersome and time consuming to typing the code. So, is there any tools that can generate the java code of a table's data model by parsing it's FXML describe file?
Regards, Qinn
Edited by: 854675 on Oct 7, 2012 11:02 PMI have know how to create FXML file that describes a table. Meanwhile, according to [Oracle Tutorial|http://docs.oracle.com/javafx/2/fxml_get_started/fxml_tutorial_intermediate.htm#CACFEHBI], it is a best practice to implement a class that defines the data model and provides methods and fields to further work with the table.
However, It's rather cumbersome and time consuming to typing the code. So, is there any tools that can generate the java code of a table's data model by parsing it's FXML describe file?
Regards, Qinn
Edited by: 854675 on Oct 7, 2012 11:02 PM -
How to get the java code of the message mapping
how to get the java code of the message mapping,
I mean to ask how to get the background java code of the message mapping(graphical mapping).
And where to view it?Hi Satya,
The JAVA code for graphical msg mapping is in below folder:
\usr\sap\<SID>\<DVEBMGS10>\j2ee\cluster\server0\temp\classpath_resolver
Here all the mapping jars are there in this folder.
Just decompile these jars and you can see the code.
Thanks,
Rajeev Gupta
Message was edited by:
RAJEEV GUPTA -
Class Not found Exception for invoking BPEL process through the Java code
Hi.
The JDeveloper IDE raise the Exception From the invoking the BPEL process through the java code .Class Not Found Exception (Locator,ID.......).What is process of importing these classes from API.In your code (.bpel file) import the library using the bpelx:exec tag. For example the adding the following entry in your .bpel file imports the com.oracle.bpel.client.util library.
<bpelx:exec import="com.oracle.bpel.client.util.*"/> -
Provide the java code for the following scenario.
Hi Experts,
I have tried with all the combinations for this scenario. As per my understanding i require java code for the following scenario
so that it becomes easy........
I require a Message mapping for this Logic.
In the Source there are 4 fields and, the Target side, the fields should appear like this.
Source Structure- File
Record
|-> Header
Order_No
Date
|-> Item
Mat_No
Quantity
Target Structure-IDoc
IDoc
|-> Header
|-> Segment
Delivery_Order_No
Recv_Date
|-> Item
|-> Segment
Delivery_Order_No
Material_Num
Recv_Quantity.
The Logic is for every Order number an IDOC is generated.And if the Material num matches then the quantity should be added. and important note is that the material numbers are different for every order number. That means if a material number is 2 in the order number A. Then the material number can never be 2 in any of the order numbers.Here is the following with an example for the above scenario.
For example:-
we have
Source Structure- File
Order-no Date Mat_No Quantity
1 01/02/2011 A 10
1 01/02/2011 B 15
1 01/02/2011 A 10
2 01/02/2011 C 10
2 01/02/2011 C 10
3 01/02/2011 D 20
3 01/02/2011 D 10
3 01/02/2011 E 25
Target Structure-IDoc
Delivery_Order_No Recv_Date Material_Num Recv_Quantity
1 01/02/2011 A 20
1 01/02/2011 B 15
2 01/02/2011 C 20
3 01/02/2011 D 30
3 01/02/2011 E 25
So for this example total of 5-Idocs created. That means for this example if Order_No is 1 When the Mat_No is A the quantity gets added. For this Scenario 1 IDoc with four Fields 2 in Header(Delivery_Order_No, Recv_Date) and 2 in Item(Material_Num, Recv_Quantity) is generated by adding the quantity field in the Target Side. Similarly if Order_No is 1 when the Mat_No is B then separate IDoc is generated with four Fields 2 in Header(Delivery_Order_No, Recv_Date) and 2 in Item(Material_Num, Recv_Quantity) in the Target Side. Similarly, if Order_No is 2 when the Mat_No is C, an IDoc is generated with four Fields 2 in Header(Delivery_Order_No, Recv_Date) and 2 in Item(Material_Num, Recv_Quantity) by adding the quantity field in the Target Side. ike wise the process goes on upto 3.Kindly do the needy..
Kindly provide the java code.
Thanq very much in advance..what i have understood from ur example is that u want to generate an idoc for unique combination of Order-no and Mat_No
if yes then chk the below mapping..
change the context of Order_No, Date, Mat_No and Quantity to Record (right click-> context)
1)
Order-no
----------------------concat[;]---sort----splitbyvalue(valuechanged)-----collapse context---IDoc
Mat_No
2)
Order-no
--------concat[;]---sort----splitbyvalue(value changed)---collapse context---UDF1--splitbyvalue(each value)--Delivery_Order_No
Mat_No
3)
Order-no
-----------concat[;]---sortbykey----------------------- \
Mat_No / \
Date--------------- / \
----------------------------------------------------------FormatByExample-----collapsecontext---splitbyvalue(each value)----Recv_Date
Order-no /
-----------concat[;]---sort----splitbyvalue(value changed)
Mat_No
4)
Order-no
--------concat[;]---sort----splitbyvalue(value changed)---collapse context-UDF2--splitbyvalue(each value)--Material_Num
Mat_No
5)
Order-no
-----------concat[;]---sortbykey
Mat_No /
Quantity --------------- /
----------------------------------------------------------FormatByExample-----SUM(under statistic)----Recv_Quantity
Order-no
-----------concat[;]---sort----splitbyvalue(value changed)
Mat_No
UDF1:
String [] temp= a.split(";");
return temp[0];
UDF2:
String [] temp= a.split(";");
return temp[1]; -
Specifying Schema Location in XML file and not in the Java code
I have a repository of schema xsd files. When I receive my xml file, I need to validate it against the specified schema. The xml file would declare the schema location, using the following syntax:
<CERD:CERD xsi:schemaLocation = "..\CERD.xsd" xmlns:CERD = "CERD.xsd" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance">
Is it really necessary to define the schema location again in the JAVA code? Why set the schemaLocation in the xml file at all then?
Does anybody have any examples where the schema location is not set in the JAVA code? I am using Java 1.6, and at this point in time I only need to validate. Any help would be appreciated.Thank you very much for your quick reply. I have made some progress but I am still stumped.
In my code I am doing this:
SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = factory.newSchema();
Validator validator = schema.newValidator();
validator.validate(XML_SOURCE);
I find this works if my schema does not have a target namespace. I have downloaded the following simple example from the internet that uses a target namespace and it fails:
library1.xsd:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://example.org/prod"
xmlns:prod="http://example.org/prod">
<xsd:element name="product" type="prod:ProductType"/>
<xsd:complexType name="ProductType">
<xsd:sequence>
<xsd:element name="number" type="xsd:integer"/>
<xsd:element name="size" type="prod:SizeType"/>
</xsd:sequence>
<xsd:attribute name="effDate" type="xsd:date"/>
</xsd:complexType>
<xsd:simpleType name="SizeType">
<xsd:restriction base="xsd:integer">
<xsd:minInclusive value="2"/>
<xsd:maxInclusive value="18"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
<prod:product xmlns:prod="http://example.org/prod"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="library1.xsd"
effDate="2001-04-02">
<number>557</number>
<size>10</size>
</prod:product>
I get the following SAXParseException when I validate:
[line 4, col 36|
cvc-elt.1: Cannot find the declaration of element 'prod:product'.
Am I doing something wrong with the namespace declaration?
Edited by: alfredamorrissey on Oct 31, 2007 6:34 AM -
Pass the data back from the jsp page to the java code
Hi,
I have written an iView that receives an event using EPCF and extracts data from the client data bag.
I need this iView to pass the data back from the jsp page to the java code.
I am trying to do this using a hidden input field, but I cannot get the code to work.
Here is the code on the jsp page.
<%@ taglib uri="tagLib" prefix="hbj" %>
<hbj:content id="myContext" >
<hbj:page title="PageTitle">
<hbj:form id="myFormId">
<hbj:inputField id="myInputField" type="string" maxlength="100" value="" jsObjectNeeded="true">
<% myInputField.setVisible(false);%>
</hbj:inputField>
</hbj:form>
</hbj:page>
</hbj:content>
<script language=JavaScript>
EPCM.subscribeEvent("urn:com.peter", "namedata", window, "eventReceiver");
function eventReceiver(eventObj) {
var url = eventObj.dataObject;
var funcName = htmlb_formid+"_getHtmlbElementId";
func = window[funcName];
var ipField = eval(func("myInputField"));
ipField.setValue(url);
var form = document.all(htmlb_formid);
form.submit();
</script>
Here is my java code
package com.sap.training.portal;
import com.sapportals.htmlb.InputField;
import com.sapportals.htmlb.page.DynPage;
import com.sapportals.htmlb.page.PageException;
import com.sapportals.portal.htmlb.page.JSPDynPage;
import com.sapportals.portal.htmlb.page.PageProcessorComponent;
public class ListSalesOrder extends PageProcessorComponent {
public DynPage getPage(){
return new ListSalesOrderDynPage();
public static class ListSalesOrderDynPage extends JSPDynPage{
private String merong;
public void doInitialization(){
public void doProcessAfterInput() throws PageException {
InputField reportfld = (InputField) getComponentByName("myInputField");
if (reportfld != null) merong = reportfld.getValueAsDataType().toString();
public void doProcessBeforeOutput() throws PageException {
if ( merong != null ) setJspName("merong.jsp");
else setJspName("ListSalesOrder.jsp");
Here is DD
<?xml version="1.0" encoding="utf-8"?>
<application>
<application-config>
<property name="SharingReference" value="com.sap.portal.htmlb"/>
<property name="PrivateSharingReference" value="com.sap.portal.htmlb"/>
</application-config>
<components>
<component name="SearchSalesOrder">
<component-config>
<property name="ComponentType" value="jspnative"/>
<property name="JSP" value="/pagelet/SearchSalesOrder.jsp"/>
</component-config>
<component-profile>
<property name="tagLib" value="/SERVICE/htmlb/taglib/htmlb.tld"/>
</component-profile>
</component>
<component name="ListSalesOrder">
<component-config>
<property name="ClassName" value="com.sap.training.portal.ListSalesOrder"/>
</component-config>
<component-profile>
<property name="tagLib" value="/SERVICE/htmlb/taglib/htmlb.tld"/>
</component-profile>
</component>
</components>
<services/>
</application>
After receive event, then call java script function "eventReceiver" and call "form.submit()".
But .. PAI Logic in Java code doesn't called ...
Where is my problme ?
Help me ...
Regards, Arnold.Hi Arnold,
you should not do a form.submit yourself. Instead you can put a component called ExternalSubmit to your page:
ExternalSubmit exSubmit = new ExternalSubmit("EX_SUBMIT"));
exSubmit.setServerEventName("MyEvent");
This results in a java script funtion on the page which is called "_htmlb_external_submit_". If you call this function the the form gets submitted and your event handler is called.
regards,
Martin -
How to view the java code of the message mapping,
Hi Experts,
<b>how to view the java code of the message mapping,</b>
how to get the background java code of the message mapping(graphical mapping).
And where to view it?Hi sowmya,
Open any Message mapping in IR. Press <b>CtrlShift0(zero)</b> to open a new menu.
There you will find an option "Is Java Source Code Available?"
There will be an export button nearby. Use it to get the code.
Open it in a zip , you will see the hide java code.
The JAVA code for graphical msg mapping is in below folder:
\usr\sap\<SID>\<DVEBMGS10>\j2ee\cluster\server0\temp\classpath_resolver
Here all the mapping jars are there in this folder.
Just decompile these jars and you can see the code. -
How to get the java code of the standard functions
How to get the java code of the standard functions in xi
Example , hoh get the java code for a node function - removeContext.hi
Click on the Standard Function.
Hold Ctrl+Shift
right click on the standard function to view the context menu. You will see options to view the source code by exporting
regards
krishna -
How to register a dll from the java code
Hi,
We can use windows utility Regsv32.exe to register a the components. Is it possible to register the Dll from the java code. If possible please try to provide me the code for the registring the dll.
Thanks in adavance
Aswadif a try this variant it doesnt work
static {
System.loadLibrary("shellExec.dll");
but in this way it work (without .dll extension)
static {
System.loadLibrary("shellExec");
} -
Can I use "Adobe X Pro" to debug the java code in adobe forms?
HI,
Can I use "Adobe X Pro" to debug the java code in adobe forms?, if not how do i debug the java code written in the adobe form.I have the adobe acrobat x evaluation version installed, please find the print shot attached, I have pressed CTRL+J in the preview mode, but nothing came up.
Am I doing something wrong.. -
How do I get the java code from a class file ?
I want to know how to findout the java code from a .class file . Is there any utility or any way to get the java code from a .class file. If so , please let me know the step by step procedure .
Thanks
ShivaCheck out Mocha (http://www.brouhaha.com/~eric/computers/mocha.html)
It's free! -
JavaScript is not from the same origin as the Java code
When trying to log into my school website with Safari, I get the following error from the console:
sun.plugin.liveconnect.OriginNotAllowedException: JavaScript is not from the same origin as the Java code, caller=http://tychousa3.umuc.edu/WebTycho.nsf/setJVMCookie?OpenPage, callee=https://tychousa3.umuc.edu/sys/
This keeps me from logging in. In order to get it to work, I have to disable Java, log in, then reenable Java after logging in.
I am able to log in successfully with Firefox but I really prefer to use Safari.
Does anyone else experience this problem and do you know how to fix it? Any help would be very much appreciated. Thanks.
iBook 933 - PPC Mac OS X (10.4.5)I'm reposting. No answer.
-
Function calling the java code
I have a java code that returns the size of the file name. I have created a pl/sql function that calls the method in the java class.
The problem I face is , when I try to call the function using the command "CALL f_size('C:\Batch\Query.sql')into :leng " , the error comes reporting that
"No method func in class fSize ".
I have given both the java& pl/sql code. Can anyone help me out?
import java.io.*;
public class fSize {
public static long func(String s)
File file = new File(s);
long length = file.length();
return length;
create or replace function f_size(path varchar2) return number
as language java
name 'fSize.func(String) return java.lang.Long';What version of the database are you runnning?
If Oracle 9.2 or later, no need for java code. Use UTL_FILE.FGETATTR procedure.
FGETATTR Procedure
This procedure reads and returns the attributes of a disk file.
Syntax
UTL_FILE.FGETATTR(
location IN VARCHAR2,
filename IN VARCHAR2,
exists OUT BOOLEAN,
file_length OUT NUMBER,
blocksize OUT NUMBER);
Parameters
Table 95-24 FGETATTR Procedure Parameters
Parameters Description
location
Directory location of the source file, a DIRECTORY_NAME from the ALL_DIRECTORIES view (case sensitive)
filename
The name of the source file to be copied
exists
A BOOLEAN for whether or not the file exists
file_length
The length of the file in bytes. NULL if file does not exist.
blocksize
The file system block size in bytes. NULL if the file does not exist.
SQL> create or replace and compile java source named "fSize" as
2 import java.io.*;
3 public class fSize {
4 public static long func(java.lang.String s)
5 {
6 File file = new File(s);
7 long length = file.length();
8 return length;
9 }
10 };
11 /
Java created.
SQL> show errors
No errors.
SQL> create or replace function f_size(path varchar2) return number
2 as language java
3 name 'fSize.func(java.lang.String) return java.lang.Long';
4 /
Function created.
SQL>
SQL> select f_size('C:\sqlnet.log') from dual ;
F_SIZE('C:\SQLNET.LOG')
762
1 row selected.
SQL>
SQL>
SQL> disconnect
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.3.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.3.0 - Production
SQL>
Maybe you are looking for
-
SharePoint 2010 & SQL Server Report Builder 3.0 - HTTP 404 Error
Hi all, Apologies if this post is not in the correct forum. I have recently upgraded my SQL installation on my SharePoint server from Express 2008 R2 to Standard 2008 R2 so I could set up Reporting Services Integration in CA. Followed instructions
-
Brand new T530 issues. (Defective FHD panel/dead pixels)
Just received my T530 yesterday, and honestly I've got to say it's a great machine, but I have noticed a couple of minor problems with it, along with a factory defect. 1. The battery is too loose. 2. The keyboard has no caps lock indicator, yet the m
-
How can I transfer a registration to another person of a Macbook Air mid 2010?
How can I transfer a registration to another person of a Macbook Air mid 2010?
-
IDOCs Distribution Model: filter whitout Filter group
Hi guys! In my IDOCs distribution model of IDOCs with Message Type "Z", when i try to add a Filter, in the popup dialog to enter the Filter group i canot see nothing...only a line with a "Dependent on class membership: Requires classes to be defined
-
PI Migration from AS/400 to Windows platform
Dear pals, I've been assigned the task of migration of PI infrastructure of our organization,which is currently based on AS/400(IBM I-series). I've to migrate it to windows platform (Windows 2008 Ent.Edition,64-Bit). Please if someone could provide g