Why the method be implemented in EntityManager.class
package javax.persistence;
public interface EntityManager
// Methods
void persist(java.lang.Object p1) { }
T merge(T p1) { }
void remove(java.lang.Object p1) { }
T find(java.lang.Class<T> p1, java.lang.Object p2) { }
T getReference(java.lang.Class<T> p1, java.lang.Object p2) { }
void flush() { }
void setFlushMode(javax.persistence.FlushModeType p1) { }
javax.persistence.FlushModeType getFlushMode() { }
void lock(java.lang.Object p1, javax.persistence.LockModeType p2) { }
void refresh(java.lang.Object p1) { }
void clear() { }
boolean contains(java.lang.Object p1) { }
javax.persistence.Query createQuery(java.lang.String p1) { }
javax.persistence.Query createNamedQuery(java.lang.String p1) { }
javax.persistence.Query createNativeQuery(java.lang.String p1) { }
javax.persistence.Query createNativeQuery(java.lang.String p1, java.lang.Class p2) { }
javax.persistence.Query createNativeQuery(java.lang.String p1, java.lang.String p2) { }
void joinTransaction() { }
java.lang.Object getDelegate() { }
void close() { }
boolean isOpen() { }
javax.persistence.EntityTransaction getTransaction() { }
}
This is the first time I saw this usage. I understood it now, but I was afraid I missed some important concepts on "interface as parameter in the constructor". Therefore, I am wondering where I can find some online document about it in order to understand the usage clearly.
For example, if there are a few method implementations of interface TreeModel in MyDataModel.java, which methods will it call after calling JTree constructor? all methods or only part of them?
Thanks
Similar Messages
-
Why the cleint will implement different sold to rather differen ship to ?
Hi Gurus
Any body has seen this from any client?
why the cleint will implement different sold to for the same customer rather than one sold to and differen ship to.
Ex:
Burger king : 1000 through out unites states.
scenario 1): 1000 different burger king sold-to
scenario 2): 1 sold -to and 1000 ship-to
I have seen both.
why? Please I want business need?
Any thoughts with explonation.
Thanks
PrasadDude...If the Company operates through Distributer model then he can have as many Ship to Parties attached to one Sold to Party....as he will not be bothered for the credit and other details of those Ship to...only the Sold To will be maintained & through Centralised Dynamic Credit check...also the Ship to Parties Can be the district/city level owners...and the Sold to Can be a Regional Party...i mean the Company must have chosen only one Sold to Party from every state...u can have hell lot of scenarios
The other scenario is a normal one...you can have end number of Sold to parties..with their Master Data...credit etc..in case of Retail chains..this model can is used
Reward Point if it helps.
Regards,
N -
Why the method can be called in this way?
Hi all,
The following is JAVA SWING TREE custom data models program. There are two files in the program: one is TestFrame.java, and the other is MyDataModel.java. I only posted the important part on the Forum.My question is how method getChild(...) in MyDataModel.java was called in the program? Why I couldn't see the statement like tree.getChild(..) in TestFrame.java? After adding PRINT statements, I know the method getChild(..) was called automatically when object tree was initialized , but I don't know why. Thank you in advance.
======
TestFrame.java
// Imports
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.tree.*;
class TestFrame extends JFrame
// Instance attributes used in this example
private JPanel topPanel;
private JTree tree;
private JScrollPane scrollPane;
// Constructor of main frame
public TestFrame()
// Create a new tree control
MyDataModel treeModel = new MyDataModel( root );
tree = new JTree(treeModel);
=========
==========
MyDataModel.java
import javax.swing.tree.*;
class MyDataModel extends DefaultTreeModel
private DefaultMutableTreeNode root;
private String rootName = "";
public MyDataModel( TreeNode root )
super( root );
DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode)root;
rootName = (String)parentNode.getUserObject();
System.out.println("rootName is: "+rootName);
public Object getChild( Object parent, int index )
DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode)parent;
String parentName = (String)parentNode.getUserObject();
System.out.println("parentName is: "+parentName);
if( parentName.equals( rootName ) )
return super.getChild( parent, index );
else
return new DefaultMutableTreeNode( cardArray[index] );
}This is the first time I saw this usage. I understood it now, but I was afraid I missed some important concepts on "interface as parameter in the constructor". Therefore, I am wondering where I can find some online document about it in order to understand the usage clearly.
For example, if there are a few method implementations of interface TreeModel in MyDataModel.java, which methods will it call after calling JTree constructor? all methods or only part of them?
Thanks -
Is the remote interface implemented by some class
Hi,
I have a simple question, googled, no help.
I am trying to udnerstand, where exactly is the remote interface implemented ?
I mean, i know that it contains all the business methods which have a body in the bean.
But is the remote interface implemented somewhere ? Is there any class which implements the Remote interface ?
thanks
SSarvananda wrote:
Hi,
I have a simple question, googled, no help.look better...
I am trying to udnerstand, where exactly is the remote interface implemented ?
I mean, i know that it contains all the business methods which have a body in the bean. so, that's what implements it :)
But is the remote interface implemented somewhere ? Is there any class which implements the Remote interface ?
the bean class :)
But the actual implementor is a class generated by the appserver that delegates to the bean class. -
How Can I Call the method in WAR project's class?
Message was edited by: JUNHA SHIN
I have one correct Web Moudule Project.
The EAR project(EmployeeCardJdoEar) added the WAR archive
(EmployeeCardJdoWar) is run correctly.
I want to add the war archive to my WD project.
because, the war project contain business logic to be reused.
so. i had enrolled in my WD project's properties ->
Web Dynpro References -> Sharing References ->
sap.com/EmployeeCardJdoEar.
but, this method in WAR(EmployeeCardJdoWar) occurs Exception.
Context ctx = new InitialContext();
pmf = (PersistenceManagerFactory)
ctx.lookup("java:comp/env/jdo/defaultPMF");
I think lookup call is not run correctly.
But, this lookup is run correctly in my EAR project. -
How to get the method names in a class
hi friends,
Could any of you tell me the report or function module to display all the method names in a given class.
thanks in advance.
regards,
kumarHi Kumar ,
Open ur class in SE24 transaction ,there is a tab for methods ..
u'll get the list of methods form there ... n in source u'll get their operative details
Regards
Renu -
Why all the methods in interface should be implemented
why all the methods in interface should be implemented
Because you'll break the contract saying "this instance features all methods defined in that interface" otherwise.
In other words, as long as an interface isn't completely implemented by an instance, it's not validly implemented at all. -
Calling public class method from the servlet dopost() implementation
Hi!
My application is a simple application where i wrote a JSP page to enter the USERNAME and PASSWORD. And this JSP will call a HttpServlet
with in which i am calling another Java class ValidateUser which will check aginst the Oracle Database table whether that Username and password combination exists and returns the user's name.
But when i am trying to call that method is throwing me an error. here is the typical code i wrote.
servlet
package isispack;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.*;
public class Login extends HttpServlet{
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException,IOException{
String userId = req.getParameter("user_id");
String password = req.getParameter("user_pass");
// if uName is null .. user is not authorized.
String uName = Validate(userId, password);
and
Validate class
package isispack;
import java.sql.*;
import java.util.*;
import java.lang.*;
public class ValidateUser
public String ValidateUser(String inputUserid, String inputPwd) throws
SQLException{
String returnString = null;
String dbUserid = "isis"; // our Database user id
String dbPassword = "isisos" ; // our Database password
Connection con = DriverManager.getConnection("jdbc:odbc:JdbcOdbcDriver","isis","osiris");
Statement stmt = con.createStatement();
String sql= "select user_id from isis_table where user_id = '" inputUserid + "' and user_pass= '" + inputPwd +"' ;" ;
ResultSet rs = stmt.executeQuery(sql);
if (rs.next())
returnString = rs.getString("user_id");
stmt.close();
con.close();
return returnString ;
The ERROR
Error(18,18): method ValidateUser(java.lang.String, java.lang.String) not found in class isispack.Login
One more thing i forgot to tell you. I am trying to run this application on JDeveloper. Please helpme out if you can . Thank you.
-SreekanthOK! I made it static method
and tried to call the method as follows
String uName = ValidateUser.ValidateUser(userId, password);
even if i create the instence and
ValidateUser Validate;
then call
String uName= Validate.ValidateUser(userId,password)
In either case is giving me the following error.Tarun, am new to Java programming, please help me out. And can you please tell me where can i find things in consise to brush up my fundamentals?.
Error(18,43): unreported exception: java.sql.SQLException; must be caught or declared to be thrown -
Purpose of declaring the method or class or static and as instance
what is the purpose of declaring a method in a class or the class itself as static.
Does it mean we cannot create a copy of that class or method if we declare it as static.
if so then why do they dont want that class to be created as a copy ?
Why do they want to declare a class as static
please provide some conceptual undersatnding regarding the static and instance class with one exampleStatic methods are often used for the implementation of utility methods. Please have a look at the class CL_ABAP_CHAR_UTILITIES for example.
You use the methods of this class in the same way as you would use a function in ABAP (like
LINES( itab )
). You use it in a static way because the functionality is always the same no matter in what context you are calling the function.
The purpose of instance methods is that their logic is in some way related to an attribute of the object instance that you use to call it.
For example, you create an instance of object PO (a purchase order) called MY_PO. Then the method
MY_PO->ADD_POSITION
would add a position to a concrete PO that has a unique number etc. But if the object has a static method DELETE_POSITION then it just deletes the current position of a PO, regardless on which concrete PO you are acting at the moment.
I hope this clarifies it for you.
Regards,
Mark -
Implements the method defined in interface
I defined a interface such as
interface IAuthorizer{
boolean checkPermission(Set<IAttribute> subj, Set<IAttribute> Permission);
In java 5, why does compiler not accept the method checkPermission signature of the following class
class Auth1 implements IAuthorizer{
boolean checkPermission(Set<IAttribute> subj, Set<IAttribute> Permission){
Iclass Auth1 implements IAuthorizer{
boolean checkPermission(Set subj, Set Permission){
nstead, the compiler only accepts<If you compile the interface and the class in the same time (eg not having the interface in a jar file against which to compile the class), the compiler should accept your code.>
The interface and class is even in the same package. The compiler does not accept method signature as
boolean checkPermission(Set<IAttribute> subj, Set<IAttribute> perms)
<If your interface is part of a library jar file, could it be that
- the library is obfuscated using an obfuscater that doesn't know about generics?
- the class is written against JDK 1.4 API (in which Set is not generic)?
- the class is compiled using java 1.4 compiler?
>
no library is involved in the issue.
class is written in JDK 1.5 API and use JDK 1.5 compiler. -
Constrructor method in implementation class
Can we write the method constructor for a BADI implementation class?
Hi
*DATA: g_report TYPE REF TO ZCL_IM_IMPL_ENG_CHG.
CREATE OBJECT g_report
EXPORTING
if_repid = sy-repid .
I don't know the class ZCL_IM_IMPL_ENG_CHG, and I don't know which interface is the base for that class.
Anyway if some data is transfered while the object is being created, it means the class of the object has to have a constructor method.
Now the question is why you create the object by the following code?
CREATE OBJECT g_report
EXPORTING
if_repid = sy-repid .
Max -
Where can we find the methods of the classes in OLE Interface
Hi All,
I am developing the code to download the file into multiple sheets of excel file.
got many links and sample codes from this forum.
but my doubt is where can we find the methods in applications.
Example:
add, cells, range etc are the methods in the object excel.application.
I want to find all other methods in this same object.
Please help me.
thanks in adv.
EswarHE,
see this demo program which is in DWDM
*& Report DEMOEXCELINTEGRATION *
INCLUDE rdemoexcelintegrationtop.
DATA: control TYPE REF TO i_oi_ole_container_control.
DATA: container TYPE REF TO cl_gui_custom_container.
DATA: link_server TYPE REF TO i_oi_link_server.
DATA: table_coll TYPE REF TO i_oi_table_collection.
DATA: retcode TYPE t_oi_ret_string,
document_type TYPE soi_document_type
VALUE soi_doctype_excel_chart,
document_format TYPE soi_document_type.
DATA: doc_url TYPE t_url.
DATA: usa_sales TYPE i VALUE 1000,
europe_sales TYPE i VALUE 2000,
japan_sales TYPE i VALUE 1000,
asia_sales TYPE i VALUE 100,
america_sales TYPE i VALUE 100,
africa_sales TYPE i VALUE 100.
DATA: total_sales TYPE i VALUE 0.
DATA: BEGIN OF test_line, region(50), sales TYPE i, END OF test_line.
DATA: test_table LIKE TABLE OF test_line.
DATA: wa_test_table LIKE test_line.
CLASS c_excel_document DEFINITION
CLASS c_excel_document DEFINITION.
PUBLIC SECTION.
DATA: proxy TYPE REF TO i_oi_document_proxy.
DATA: document_type TYPE soi_document_type.
DATA: data_table TYPE sbdst_content,
data_size TYPE i,
doc_url TYPE t_url.
METHODS: constructor
IMPORTING control TYPE REF TO i_oi_ole_container_control
document_type TYPE soi_document_type.
METHODS: on_close_document
FOR EVENT on_close_document OF i_oi_document_proxy
IMPORTING document_proxy has_changed.
METHODS: on_custom_event
FOR EVENT on_custom_event OF i_oi_document_proxy
IMPORTING document_proxy event_name param_count
param1 param2 param3.
METHODS: create_document
IMPORTING open_inplace TYPE c DEFAULT ' '
EXPORTING retcode TYPE t_oi_ret_string.
METHODS: open_document
IMPORTING open_inplace TYPE c DEFAULT ' '
open_readonly TYPE c DEFAULT ' '
EXPORTING retcode TYPE t_oi_ret_string.
METHODS: open_document_url
IMPORTING open_inplace TYPE c DEFAULT ' '
open_readonly TYPE c DEFAULT ' '
doc_url TYPE t_url DEFAULT ' '
EXPORTING retcode TYPE t_oi_ret_string.
METHODS: retrieve_document
IMPORTING documents TYPE document_list
EXPORTING document_format TYPE soi_document_type
doc_url TYPE t_url.
METHODS: close_document
IMPORTING do_save TYPE c DEFAULT ' '
RETURNING value(retcode) TYPE t_oi_ret_string.
PRIVATE SECTION.
DATA: control TYPE REF TO i_oi_ole_container_control.
ENDCLASS.
DATA: l_fcode LIKE fcode.
DATA: document TYPE REF TO c_excel_document.
DATA: bds_instance TYPE REF TO cl_bds_document_set.
*& Module STATUS_0100 OUTPUT
MODULE status_0100 OUTPUT.
SET PF-STATUS 'MAIN0100'.
SET TITLEBAR '001'.
retcode = c_oi_errors=>ret_ok.
IF control IS INITIAL.
DATA: b_has_activex.
CALL FUNCTION 'GUI_HAS_ACTIVEX'
IMPORTING
return = b_has_activex.
IF b_has_activex IS INITIAL. MESSAGE e007. ENDIF.
CALL METHOD c_oi_ole_control_creator=>get_ole_container_control
IMPORTING control = control
retcode = retcode.
CALL METHOD c_oi_errors=>show_message
EXPORTING type = 'E'.
CREATE OBJECT container
EXPORTING container_name = 'CONTAINER'.
CALL METHOD control->init_control
EXPORTING r3_application_name =
'Demo' "#EC NOTEXT
inplace_enabled = 'X'
inplace_scroll_documents = 'X'
parent = container
register_on_close_event = 'X'
register_on_custom_event = 'X'
IMPORTING retcode = retcode.
CALL METHOD c_oi_errors=>show_message
EXPORTING type = 'E'.
CALL METHOD control->get_link_server
IMPORTING link_server = link_server
retcode = retcode.
CALL METHOD c_oi_errors=>show_message
EXPORTING type = 'E'.
CALL METHOD link_server->start_link_server
IMPORTING retcode = retcode.
CALL METHOD c_oi_errors=>show_message
EXPORTING type = 'E'.
CALL METHOD control->get_table_collection
IMPORTING table_collection = table_coll
retcode = retcode.
PERFORM refresh_sales.
CREATE OBJECT document
EXPORTING control = control
document_type = document_type.
CALL METHOD table_coll->add_table
EXPORTING table_name = 'SALES_IN'
table_type = table_coll->table_type_input
IMPORTING retcode = retcode
CHANGING data_table = test_table.
ENDIF.
IF bds_instance IS INITIAL.
CREATE OBJECT bds_instance.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
MODULE user_command_0100 INPUT.
l_fcode = fcode.
CLEAR fcode.
CALL METHOD cl_gui_cfw=>dispatch.
CASE l_fcode.
WHEN 'EXIT'. "Zurück
IF NOT document IS INITIAL.
CALL METHOD document->close_document.
FREE document.
ENDIF.
IF NOT link_server IS INITIAL.
CALL METHOD link_server->stop_link_server
IMPORTING retcode = retcode.
FREE link_server.
ENDIF.
IF NOT table_coll IS INITIAL.
FREE table_coll.
ENDIF.
IF NOT control IS INITIAL.
CALL METHOD control->destroy_control
IMPORTING retcode = retcode.
FREE control.
ENDIF.
IF NOT bds_instance IS INITIAL.
FREE bds_instance.
ENDIF.
LEAVE TO SCREEN 0.
WHEN 'CREATE'.
IF NOT control IS INITIAL.
document->data_size = 0.
CLEAR document->data_table.
CALL METHOD document->create_document.
CALL METHOD c_oi_errors=>show_message EXPORTING type = 'E'.
ENDIF.
WHEN 'SELECT'.
IF NOT control IS INITIAL.
DATA: documents TYPE document_list.
DATA: descr TYPE document_descr.
CLEAR documents.
descr-document_name = 'Car Sales Chart'(do1).
descr-document_id = 'DEMOEXCELCHART1'.
APPEND descr TO documents.
descr-document_name = 'Car Sales Chart 2'(do3).
descr-document_id = 'DEMOEXCELCHART2'.
APPEND descr TO documents.
descr-document_name = 'Car Sales Sheet'(do2).
descr-document_id = 'DEMOEXCELSHEET1'.
APPEND descr TO documents.
CLEAR doc_url.
CALL METHOD document->retrieve_document
EXPORTING documents = documents
IMPORTING document_format = document_format
doc_url = doc_url.
IF NOT doc_url IS INITIAL.
CALL METHOD document->close_document.
CALL METHOD document->open_document_url
EXPORTING open_inplace = 'X'
doc_url = doc_url
IMPORTING retcode = retcode.
CALL METHOD c_oi_errors=>show_message EXPORTING type = 'E'.
ELSE.
MESSAGE e010.
ENDIF.
ENDIF.
WHEN 'OPEN'.
IF document->data_size NE 0.
IF NOT control IS INITIAL.
CALL METHOD document->open_document
IMPORTING retcode = retcode.
CALL METHOD c_oi_errors=>show_message EXPORTING type = 'E'.
ENDIF.
ELSE.
MESSAGE e005.
ENDIF.
WHEN 'INPLACE'.
IF document->data_size NE 0.
IF NOT control IS INITIAL.
CALL METHOD document->open_document
EXPORTING open_inplace = 'X'
open_readonly = 'X'
IMPORTING retcode = retcode.
CALL METHOD c_oi_errors=>show_message EXPORTING type = 'E'.
ENDIF.
ELSE.
MESSAGE e005.
ENDIF.
WHEN 'SAVEAS'.
IF NOT document IS INITIAL AND NOT document->proxy IS INITIAL.
CALL METHOD document->proxy->save_as
EXPORTING prompt_user = 'X'
IMPORTING retcode = retcode.
CALL METHOD c_oi_errors=>show_message EXPORTING type = 'E'.
ELSE.
MESSAGE e000.
ENDIF.
WHEN 'CLOSE'.
IF NOT document IS INITIAL.
CALL METHOD document->close_document
EXPORTING do_save = 'X'.
CALL METHOD c_oi_errors=>show_message EXPORTING type = 'E'.
ELSE.
MESSAGE e000.
ENDIF.
WHEN 'COPYLINK'.
IF NOT link_server IS INITIAL.
PERFORM refresh_sales.
CALL METHOD link_server->execute_copy_link_dialog
IMPORTING retcode = retcode.
CALL METHOD c_oi_errors=>show_message EXPORTING type = 'E'.
ELSE.
MESSAGE e004.
ENDIF.
WHEN 'REFRESH'.
IF NOT link_server IS INITIAL.
PERFORM refresh_sales.
ELSE.
MESSAGE e004.
ENDIF.
IF NOT document IS INITIAL AND NOT document->proxy IS INITIAL.
CALL METHOD document->proxy->execute_macro
EXPORTING macro_string = 'R3StartupMacro'
param_count = 1
param1 = 10
IMPORTING retcode = retcode.
CHANGING retvalue = usa_sales.
CALL METHOD c_oi_errors=>show_message EXPORTING type = 'E'.
ELSE.
MESSAGE e000.
ENDIF.
WHEN 'PRINT'.
IF NOT document IS INITIAL AND NOT document->proxy IS INITIAL.
CALL METHOD document->proxy->print_document
EXPORTING prompt_user = 'X'
IMPORTING retcode = retcode.
CALL METHOD c_oi_errors=>show_message EXPORTING type = 'E'.
ELSE.
MESSAGE e000.
ENDIF.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
CLASS c_excel_document IMPLEMENTATION.
CLASS c_excel_document IMPLEMENTATION.
METHOD: constructor.
IMPORTING control TYPE REF TO i_oi_ole_container_control
document_type TYPE soi_document_type
me->control = control.
me->document_type = document_type.
ENDMETHOD.
METHOD create_document.
IMPORTING open_inplace TYPE c DEFAULT ' '
RETURNING value(retcode) TYPE t_oi_ret_string.
IF NOT proxy IS INITIAL.
CALL METHOD me->close_document.
ENDIF.
CALL METHOD control->get_document_proxy
EXPORTING document_type = document_type
IMPORTING document_proxy = proxy
retcode = retcode.
IF retcode NE c_oi_errors=>ret_ok.
EXIT.
ENDIF.
CALL METHOD proxy->create_document
EXPORTING create_view_data = 'X'
open_inplace = open_inplace
IMPORTING retcode = retcode.
IF retcode NE c_oi_errors=>ret_ok.
EXIT.
ENDIF.
SET HANDLER me->on_close_document FOR proxy.
SET HANDLER me->on_custom_event FOR proxy.
ENDMETHOD.
METHOD open_document.
IMPORTING open_inplace TYPE c DEFAULT ' '
open_readonly TYPE c DEFAULT ' '
RETURNING value(retcode) TYPE t_oi_ret_string.
IF NOT proxy IS INITIAL.
CALL METHOD me->close_document.
ENDIF.
CALL METHOD control->get_document_proxy
EXPORTING document_type = document_type
IMPORTING document_proxy = proxy
retcode = retcode.
IF retcode NE c_oi_errors=>ret_ok.
EXIT.
ENDIF.
CALL METHOD proxy->open_document_from_table
EXPORTING document_table = data_table
document_size = data_size
open_inplace = open_inplace
open_readonly = open_readonly
IMPORTING retcode = retcode.
IF retcode NE c_oi_errors=>ret_ok.
EXIT.
ENDIF.
SET HANDLER me->on_close_document FOR proxy.
SET HANDLER me->on_custom_event FOR proxy.
CALL METHOD proxy->update_document_links
EXPORTING update_manual_links = 'X'
IMPORTING retcode = retcode.
ENDMETHOD.
METHOD close_document.
IMPORTING do_save TYPE c DEFAULT ' '
RETURNING value(retcode) TYPE t_oi_ret_string.
DATA: is_closed TYPE i, has_changed TYPE i.
DATA: doc_url(256).
IF NOT proxy IS INITIAL.
CALL METHOD proxy->is_destroyed IMPORTING ret_value = is_closed.
IF is_closed IS INITIAL.
CALL METHOD proxy->close_document
EXPORTING do_save = do_save
IMPORTING has_changed = has_changed
retcode = retcode.
IF retcode NE c_oi_errors=>ret_ok.
EXIT.
ENDIF.
ENDIF.
IF NOT has_changed IS INITIAL.
CALL METHOD proxy->save_document_to_table
IMPORTING retcode = retcode
CHANGING document_table = data_table
document_size = data_size.
IF retcode NE c_oi_errors=>ret_ok.
EXIT.
ENDIF.
ENDIF.
CALL METHOD proxy->release_document
IMPORTING retcode = retcode.
SET HANDLER me->on_close_document FOR proxy ACTIVATION ' '.
SET HANDLER me->on_custom_event FOR proxy ACTIVATION ' '.
ELSE.
retcode = c_oi_errors=>ret_document_not_open.
ENDIF.
ENDMETHOD.
METHOD open_document_url.
IMPORTING open_inplace TYPE c DEFAULT ' '
open_readonly TYPE c DEFAULT ' '
doc_url TYPE t_url DEFAULT ' '
RETURNING value(retcode) TYPE t_oi_ret_string.
IF NOT proxy IS INITIAL.
CALL METHOD me->close_document.
ENDIF.
CALL METHOD control->get_document_proxy
EXPORTING document_type = document_type
IMPORTING document_proxy = proxy
retcode = retcode.
IF retcode NE c_oi_errors=>ret_ok.
EXIT.
ENDIF.
me->doc_url = doc_url.
CALL METHOD proxy->open_document
EXPORTING document_url = doc_url
open_inplace = open_inplace
open_readonly = open_readonly
IMPORTING retcode = retcode.
IF retcode NE c_oi_errors=>ret_ok.
EXIT.
ENDIF.
Document shall also be available in ITAB for respective operations:
CALL METHOD proxy->save_document_to_table
IMPORTING retcode = retcode
CHANGING document_table = data_table
document_size = data_size.
IF retcode NE c_oi_errors=>ret_ok.
EXIT.
ENDIF.
SET HANDLER me->on_close_document FOR proxy.
SET HANDLER me->on_custom_event FOR proxy.
CALL METHOD proxy->update_document_links
EXPORTING update_manual_links = 'X'
IMPORTING retcode = retcode.
ENDMETHOD.
METHOD retrieve_document.
importing documents type document_list
exporting document_format type soi_document_format
doc_url type t_url.
*----BDS-Data-Structures:--
Tables and WAs:
DATA: doc_signature TYPE sbdst_signature,
wa_doc_signature LIKE LINE OF doc_signature,
doc_components TYPE sbdst_components,
wa_doc_components LIKE LINE OF doc_components,
doc_properties TYPE sbdst_properties,
wa_doc_properties LIKE LINE OF doc_properties,
doc_uris TYPE sbdst_uri,
wa_doc_uris LIKE LINE OF doc_uris.
ID's:
DATA: doc_classname TYPE sbdst_classname VALUE 'SOFFICEINTEGRATION',
doc_classtype TYPE sbdst_classtype VALUE 'OT',
doc_object_key TYPE sbdst_object_key VALUE 'SOFFICEINTEGRATION',
doc_mimetype TYPE bapicompon-mimetype.
DATA: field_desc TYPE TABLE OF rsvbfidesc.
DATA: wa_field_desc TYPE rsvbfidesc.
DATA: l_nr LIKE sy-tabix.
CLEAR: field_desc, wa_field_desc.
wa_field_desc-fieldnum = 1.
wa_field_desc-display = 'X'.
APPEND wa_field_desc TO field_desc.
l_nr = 0.
CALL FUNCTION 'RS_VALUES_BOX'
EXPORTING
left_upper_col = 5
left_upper_row = 5
pagesize = 10
title = 'Select document'(sdc)
IMPORTING
linenumber = l_nr
TABLES
field_desc = field_desc
value_tab = documents
EXCEPTIONS
OTHERS = 1.
IF sy-subrc EQ 0 AND l_nr NE 0.
READ TABLE documents INDEX l_nr INTO descr.
IF sy-subrc EQ 0.
CLEAR: wa_doc_signature, wa_doc_components, wa_doc_uris.
CLEAR: doc_signature, doc_components, doc_uris.
wa_doc_signature-prop_name = 'DESCRIPTION'.
wa_doc_signature-prop_value = descr-document_id.
APPEND wa_doc_signature TO doc_signature.
CALL METHOD bds_instance->get_info
EXPORTING classname = doc_classname
classtype = doc_classtype
object_key = doc_object_key
CHANGING components = doc_components
signature = doc_signature
EXCEPTIONS nothing_found = 1
error_kpro = 2
internal_error = 3
parameter_error = 4
not_authorized = 5
not_allowed = 6.
IF sy-subrc NE 0 AND sy-subrc NE 1.
MESSAGE e016.
ENDIF.
IF sy-subrc = 1.
MESSAGE e017.
ENDIF.
CALL METHOD bds_instance->get_with_url
EXPORTING classname = doc_classname
classtype = doc_classtype
object_key = doc_object_key
CHANGING uris = doc_uris
signature = doc_signature
EXCEPTIONS nothing_found = 1
error_kpro = 2
internal_error = 3
parameter_error = 4
not_authorized = 5
not_allowed = 6.
IF sy-subrc NE 0 AND sy-subrc NE 1.
MESSAGE e016.
ENDIF.
IF sy-subrc = 1.
MESSAGE e017.
ENDIF.
READ TABLE doc_components INTO wa_doc_components INDEX 1.
READ TABLE doc_uris INTO wa_doc_uris INDEX 1.
doc_mimetype = wa_doc_components-mimetype.
doc_url = wa_doc_uris-uri.
CASE doc_mimetype.
WHEN 'application/x-rtf' OR 'text/rtf'.
document_format = soi_docformat_rtf.
WHEN 'application/x-oleobject'.
document_format = soi_docformat_compound.
WHEN 'text/plain'.
document_format = soi_docformat_text.
WHEN OTHERS.
document_format = soi_docformat_native.
ENDCASE.
ENDIF.
ENDIF.
ENDMETHOD.
METHOD on_close_document.
FOR EVENT on_close_document OF c_oi_ole_container_control
IMPORTING document_proxy has_changed.
DATA: answer, do_save.
IF has_changed EQ 1.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar = 'Office Integration Demo'(oid)
text_question = 'Save Document?'(sav)
display_cancel_button = ' '
IMPORTING
answer = answer.
IF answer EQ '1'.
do_save = 'X'.
ELSE.
do_save = ' '.
ENDIF.
CALL METHOD me->close_document
EXPORTING do_save = do_save.
CALL METHOD c_oi_errors=>show_message
EXPORTING type = 'E'.
ENDIF.
ENDMETHOD.
METHOD on_custom_event.
FOR EVENT on_custom_event OF i_oi_document_proxy
IMPORTING document_proxy event_name param_count
param1 param2 param3.
IF event_name EQ 'ON_SERIES_CHANGE'.
CALL METHOD table_coll->get_table
EXPORTING table_name = 'SALES_IN'
IMPORTING retcode = retcode
CHANGING data_table = test_table.
CALL METHOD c_oi_errors=>show_message
EXPORTING type = 'E'.
CLEAR wa_test_table.
READ TABLE test_table INTO wa_test_table INDEX 1.
usa_sales = wa_test_table-sales.
CLEAR wa_test_table.
READ TABLE test_table INTO wa_test_table INDEX 2.
europe_sales = wa_test_table-sales.
CLEAR wa_test_table.
READ TABLE test_table INTO wa_test_table INDEX 3.
japan_sales = wa_test_table-sales.
CLEAR wa_test_table.
READ TABLE test_table INTO wa_test_table INDEX 4.
asia_sales = wa_test_table-sales.
CLEAR wa_test_table.
READ TABLE test_table INTO wa_test_table INDEX 5.
america_sales = wa_test_table-sales.
CLEAR wa_test_table.
READ TABLE test_table INTO wa_test_table INDEX 6.
africa_sales = wa_test_table-sales.
CLEAR wa_test_table.
ENDIF.
CALL METHOD control->set_focus.
ENDMETHOD.
ENDCLASS.
FORM refresh_sales.
FORM refresh_sales.
DATA: BEGIN OF item_line,
region(60),
sales TYPE i,
date TYPE d,
time TYPE t,
weight TYPE f,
amount TYPE p DECIMALS 3,
id(10) TYPE n,
END OF item_line.
DATA: sales_table LIKE TABLE OF item_line.
DATA: wa_sales_table LIKE item_line.
DATA: fields_table TYPE TABLE OF rfc_fields.
DATA: wa_fields_table TYPE rfc_fields.
DATA: ind TYPE i.
CALL FUNCTION 'DP_GET_FIELDS_FROM_TABLE'
TABLES
data = sales_table
fields = fields_table.
READ TABLE fields_table INDEX 1 INTO wa_fields_table.
wa_fields_table-fieldname = 'Region'."#EC NOTEXT
MODIFY fields_table FROM wa_fields_table INDEX 1.
CLEAR wa_fields_table.
READ TABLE fields_table INDEX 2 INTO wa_fields_table.
wa_fields_table-fieldname = 'Sales'. "#EC NOTEXT
MODIFY fields_table FROM wa_fields_table INDEX 2.
CLEAR: sales_table, wa_sales_table.
wa_sales_table-region = 'USA'(usa).
wa_sales_table-sales = usa_sales.
APPEND wa_sales_table TO sales_table.
CLEAR wa_sales_table.
wa_sales_table-region = 'Europe'(eur).
wa_sales_table-sales = europe_sales.
APPEND wa_sales_table TO sales_table.
CLEAR wa_sales_table.
wa_sales_table-region = 'Japan'(jap).
wa_sales_table-sales = japan_sales.
APPEND wa_sales_table TO sales_table.
CLEAR wa_sales_table.
wa_sales_table-region = 'Asia'(asi).
wa_sales_table-sales = asia_sales.
APPEND wa_sales_table TO sales_table.
CLEAR wa_sales_table.
wa_sales_table-region = 'America'(ame).
wa_sales_table-sales = america_sales.
APPEND wa_sales_table TO sales_table.
CLEAR wa_sales_table.
wa_sales_table-region = 'Africa'(afr).
wa_sales_table-sales = africa_sales.
APPEND wa_sales_table TO sales_table.
CLEAR wa_sales_table.
LOOP AT sales_table INTO wa_sales_table.
ind = sy-tabix.
wa_sales_table-date = sy-datum + ind.
wa_sales_table-time = sy-uzeit + ind.
wa_sales_table-weight = 100000 * ind.
wa_sales_table-amount = 11111 * ind.
wa_sales_table-id = ind.
MODIFY sales_table FROM wa_sales_table INDEX ind.
ENDLOOP.
CALL METHOD table_coll->add_table
EXPORTING table_name = 'SALES_OUT'
table_type = table_coll->table_type_output
IMPORTING retcode = retcode
CHANGING data_table = sales_table
fields_table = fields_table.
CALL METHOD link_server->add_table_item2
EXPORTING item_name = 'Sales' "#EC NOTEXT
item_title = 'Car Sales Figures'(sal)
IMPORTING retcode = retcode
CHANGING data_table = sales_table
fields_table = fields_table.
CALL METHOD link_server->add_string_item
EXPORTING item_name = 'ChartTitle'
item_title = 'Chart Title'(ti0)
item_value = 'Car Sales by Region'(ti1)
no_flush = 'X'
IMPORTING retcode = retcode.
CALL METHOD link_server->add_string_item
EXPORTING item_name = 'ColumnTitle1'
item_title = 'Column Title 1'(ti2)
item_value = 'Region'(ti3)
no_flush = 'X'
IMPORTING retcode = retcode.
CALL METHOD link_server->add_string_item
EXPORTING item_name = 'ColumnTitle2'
item_title = 'Column Title 2'(ti4)
item_value = 'Sold Cars'(ti5)
no_flush = ' '
IMPORTING retcode = retcode.
ENDFORM. -
How do I alter the bytes of a Class file to add calls to the methods?
If i had the bytes of a class file, and I wanted to alter the bytes that constitute each method for the class so that it included a call to the security manager, how would i do it?
1. How would I know which bytes were the opening of a method?
2. how would I know what the name of the method is?
3. How would I create bytes for something like:
SecurityManager sm = System.getSecurityManager().checkPermission(thismeth, subject);
4. I assume that if by some miracle I can do the above, then all I have to do is call defineClass(...) in ClassLoader and send it the new bytes, right?
Thanks to all!OK, if it will help anyone get me the answers here, I found a class on the internet that can read a class file and tell you where in the bytes a method occurs and what its name is, and how long it is. What I need now is how to convert a call into the correct manner of bytes.
For example, so I could add the bytes that would do:
System.out.println("Added!");
The class that reads a class file:
/* Inspector.java by Mark D. LaDue */
/* June 24, 1997 */
/* Copyright (c) 1997 Mark D. LaDue
You may study, use, modify, and distribute this example for any purpose.
This example is provided WITHOUT WARRANTY either expressed or implied. */
/* This Java application analyzes the entries in the constant pool and locates
the code arrays in a Java class file. Each entry in the constant pool
yields the following information:
Index Tag Reference(s)/Value(s)
where "Index" is its position within the class file's constant pool,
"Tag" is the official tag number for that type of entry, and
"Reference(s)/Value(s)" contains the constant pool information
according to the entry's type. (See Lindholm and Yellin's "The Java
Virtual Machine Specification" for details.) For each code array in
the class file, its starting byte, its total length, and the name of
the method in which it occurs are given. Combining this information
with the information yielded by the humble "javap" utility gives one
sufficient information to hack the code arrays in Java class files. */
import java.io.*;
class Inspector {
public static void main(String[] argv) {
int fpointer = 8; // Where are we in the class file?
int cp_entries = 1; // How big is the constant pool?
int Code_entry = 1; // Where is the entry that denotes "Code"?
int num_interfaces = 0; // How many interfaces does it use?
int num_fields = 0; // How many fields are there?
int num_f_attributes = 0; // How many attributes does a field have?
int num_methods = 0; // How many methods are there?
int num_m_attributes = 0; // How many attributes does a method have?
int[] tags; // Tags for the constant pool entries
int[] read_ints1; // References for some constant pool entries
int[] read_ints2; // References for some constant pool entries
long[] read_longs; // Values for some constant pool entries
float[] read_floats; // Values for some constant pool entries
double[] read_doubles; // Values for some constant pool entries
StringBuffer[] read_strings; // Strings in some constant pool entries
int[] method_index;
long[] code_start;
long[] code_length;
// How on earth do I use this thing?
if (argv.length != 1) {
System.out.println("Try \"java Inspector class_file.class\"");
System.exit(1);
// Start by opening the file for reading
try {
RandomAccessFile victim = new RandomAccessFile(argv[0], "r");
// Skip the magic number and versions and start looking at the class file
victim.seek(fpointer);
// Determine how many entries there are in the constant pool
cp_entries = victim.readUnsignedShort();
fpointer += 2;
// Set up the arrays of useful information about the constant pool entries
tags = new int[cp_entries];
read_ints1 = new int[cp_entries];
read_ints2 = new int[cp_entries];
read_longs = new long[cp_entries];
read_floats = new float[cp_entries];
read_doubles = new double[cp_entries];
read_strings = new StringBuffer[cp_entries];
//Initialize these arrays
for (int cnt = 0; cnt < cp_entries; cnt++) {
tags[cnt] = -1;
read_ints1[cnt] = -1;
read_ints2[cnt] = -1;
read_longs[cnt] = -1;
read_floats[cnt] = -1;
read_doubles[cnt] = -1;
read_strings[cnt] = new StringBuffer();
// Look at each entry in the constant pool and save the information in it
for (int i = 1; i < cp_entries; i++) {
tags[i] = victim.readUnsignedByte();
fpointer++;
int skipper = 0;
int start = 0;
int test_int = 0;
switch (tags) {
case 3: read_ints1[i] = victim.readInt();
fpointer += 4;
break;
case 4: read_floats[i] = victim.readFloat();
fpointer += 4;
break;
case 5: read_longs[i] = victim.readLong();
fpointer += 8;
i++;
break;
case 6: read_doubles[i] = victim.readDouble();
fpointer += 8;
i++;
break;
case 7:
case 8: read_ints1[i] = victim.readUnsignedShort();
fpointer += 2;
break;
case 9:
case 10:
case 11:
case 12: read_ints1[i] = victim.readUnsignedShort();
fpointer += 2;
victim.seek(fpointer);
read_ints2[i] = victim.readUnsignedShort();
fpointer += 2;
break;
// This is the critical case - determine an entry in the constant pool where
// the string "Code" is found so we can later identify the code attributes
// for the class's methods
case 1: skipper = victim.readUnsignedShort();
start = fpointer;
fpointer += 2;
victim.seek(fpointer);
for (int cnt = 0; cnt < skipper; cnt++) {
int next = victim.readUnsignedByte();
switch (next) {
case 9: read_strings[i].append("\\" + "t");
break;
case 10: read_strings[i].append("\\" + "n");
break;
case 11: read_strings[i].append("\\" + "v");
break;
case 13: read_strings[i].append("\\" + "r");
break;
default: read_strings[i].append((char)next);
break;
victim.seek(++fpointer);
victim.seek(start);
if (skipper == 4) {
fpointer = start + 2;
victim.seek(fpointer);
test_int = victim.readInt();
if (test_int == 1131373669) {Code_entry = i;}
fpointer = fpointer + skipper;
else {fpointer = start + skipper + 2;}
break;
victim.seek(fpointer);
// Skip ahead and see how many interfaces the class implements
fpointer += 6;
victim.seek(fpointer);
num_interfaces = victim.readUnsignedShort();
// Bypass the interface information
fpointer = fpointer + 2*(num_interfaces) + 2;
victim.seek(fpointer);
// Determine the number of fields
num_fields = victim.readUnsignedShort();
// Bypass the field information
fpointer += 2;
victim.seek(fpointer);
for (int j=0; j<num_fields; j++) {
fpointer += 6;
victim.seek(fpointer);
num_f_attributes = victim.readUnsignedShort();
fpointer = fpointer + 8*(num_f_attributes) + 2;
victim.seek(fpointer);
// Determine the number of methods
num_methods = victim.readUnsignedShort();
fpointer += 2;
// Set up the arrays of information about the class's methods
method_index = new int[num_methods];
code_start = new long[num_methods];
code_length = new long[num_methods];
//Initialize these arrays
for (int cnt = 0; cnt < num_methods; cnt++) {
method_index[cnt] = -1;
code_start[cnt] = -1;
code_length[cnt] = -1;
// For each method determine the index of its name and locate its code array
for (int k=0; k<num_methods; k++) {
fpointer += 2;
victim.seek(fpointer);
method_index[k] = victim.readUnsignedShort();
fpointer += 4;
victim.seek(fpointer);
// Determine the number of attributes for the method
num_m_attributes = victim.readUnsignedShort();
fpointer += 2;
// Test each attribute to see if it's code
for (int m=0; m<num_m_attributes; m++) {
int Code_test = victim.readUnsignedShort();
fpointer += 2;
// If it is, record the location and length of the code array
if (Code_test == Code_entry){
int att_length = victim.readInt();
int next_method = fpointer + att_length + 4;
fpointer += 8;
victim.seek(fpointer);
code_length[k] = victim.readInt();
code_start[k] = fpointer + 5;
fpointer = next_method;
victim.seek(fpointer);
// Otherwise just skip it and go on to the next method
else {
fpointer = fpointer + victim.readInt() + 4;
victim.seek(fpointer);
// Print the information about the Constant Pool
System.out.println("There are " + (cp_entries - 1) + " + 1 entries in the Constant Pool:\n");
System.out.println("Index\t" + "Tag\t" + "Reference(s)/Value(s)\t");
System.out.println("-----\t" + "---\t" + "---------------------\t");
for (int i = 0; i < cp_entries; i++) {
switch (tags[i]) {
case 1: System.out.println(i + "\t" + tags[i] + "\t" + read_strings[i].toString());
break;
case 3: System.out.println(i + "\t" + tags[i] + "\t" + read_ints1[i]);
break;
case 4: System.out.println(i + "\t" + tags[i] + "\t" + read_floats[i]);
break;
case 5: System.out.println(i + "\t" + tags[i] + "\t" + read_longs[i]);
break;
case 6: System.out.println(i + "\t" + tags[i] + "\t" + read_doubles[i]);
break;
case 7:
case 8: System.out.println(i + "\t" + tags[i] + "\t" + read_ints1[i]);
break;
case 9:
case 10:
case 11:
case 12: System.out.println(i + "\t" + tags[i] + "\t" + read_ints1[i] + " " + read_ints2[i]);
break;
System.out.println();
// Print the information about the methods
System.out.println("There are " + num_methods + " methods:\n");
for (int j = 0; j < num_methods; j++) {
System.out.println("Code array in method " + read_strings[method_index[j]].toString() + " of length " + code_length[j] + " starting at byte " + code_start[j] + ".");
System.out.println();
// All the changes are made, so close the file and move along
victim.close();
} catch (IOException ioe) {} -
Hi!
Why can't I compile this snip of code?
I get:
Error: (19) method listFiles() not found in class java.io.File.
Here is the code:
package stream;
import java.io.*;
import java.util.*;
public class myStream {
public static void main(String[] args) {
File myFile = new File("D:/myjava");
File[] str = myFile.listFiles();
Thanks in advance
HenningThere is no method "listFiles()" in "File" class. (JDK 1.1.8)
You can try to use " list() " method which
Returns a list of the files in the directory specified by this File object.
raghu
null -
Implementing the IF_WORKFLOW interface into a custom class
In workflow tasks you can use ABAP Classes and their methods to implement functionality instead of always using BOR objects. I created a class with a static method and got it to work outside of my task. As soon as I put the class and method into my task it says I must Interface implementation IF_WORKFLOW does not exist.
Does anyone know how to do this?Yep, my biggest mistake was looking in the help of my own version. Look in NW2004s:
http://help.sap.com/saphelp_nw04s/helpdata/en/02/527b42303e0e53e10000000a155106/frameset.htm
It applies all the way back to 620. Put IF_WORKFLOW into your interface and then define all the shiny new methods in your class. As long as you're only working with statics you don't even need to bother with all the LPOR stuff - just make sure to at least create all the methods (even if empty) to prevent dumps if WF tries to do anything with it.
Have fun,
Mike
Maybe you are looking for
-
What format for my external drive allows use with Mac and Windows?
I got an external hard disk (1 tr) and i want to used it for my windows and mac, i read i can have two partitions one for mac and one for windows, but i dont really want to have two parts, and I read i can format it by fat32 and i can write and read
-
Cuando inicio el Photoshop CS 2 (9) recivo el siguiente error: "could not initialize Photoshop because the file could not be found" Lo mismo me pasa con el CS (version 8 ). el ImageReady funciona perfectamente, pero no puedo trabajar con Phtoshop. de
-
Hi all, Do I need a plug in to open an FLV file in Flash Professional 8? If so, can you tell me where to find it? Also, is it the same process to convert an FLV to SWF as it is with FLA?
-
Hi all, I am beginner to J2EE technology. But I have a few experience in java programming and JSP. Now, I got a problem when I develop a very tiny bean. I can compile java files and I can make new application via deployment tool. But I cannot create
-
Byte to long conversion.
Hello. If you run this code, the result is "-13". Why this if "ó" value is 243? Thanks. public class prueba3 public static void main(String args[]) byte[] b="óxxfd".getBytes(); long b64=0; b64=(long)b[0]; System.out.println(b64); }