How to create an interface

Sorry for the newbie question. I was provided a class, and they said that in order to use this class the interface can just construct a new SampleClass and method1() followed by method2(). I've looked over the documentation on interfaces, but I still don't get it. I was hoping someone could give me some guidance as to how to use method1() and method2() in my class.
The SampleClass starts off like this
public class SampleClass extends java.io.File {
public boolean method1 {
return true;
public void method2 {
sample.start();
} //my class
public class MyProgram {
public static void main(String args[]) {
}}Thanks in advance for the help!

Ok. Here's the actual program that was given to me. When I do AudioFile af = new AudioFile();. It says that it's unable to resolve. So when I asked the guy about this, he said that I need to use an interface.....again sorry for my confusion.
import java.io.*;
import javax.media.*;
import java.net.*;
import java.util.Vector;
import javax.media.format.AudioFormat;
import javax.media.protocol.DataSource;
import javax.media.protocol.FileTypeDescriptor;
import javax.media.datasink.*;
import javax.media.MediaLocator;
import java.text.DecimalFormat;
import javax.media.control.BufferControl;
public class AudioFile extends java.io.File
private Processor processor;
private CaptureDeviceInfo device;
private DataSink filewriter;
private String audioFormat;
private Player player;
private Time currentMediaTime;
boolean clipSaved;
public AudioFile(String fileName)
super(fileName);
processor = null;
player = null;
device = null;
filewriter = null;
clipSaved = false;
public AudioFile(String path, String name)
this(path + name);
public class StateHandler implements ControllerListener
Processor processor = null;
boolean configured = false;
boolean realized = false;
boolean failed = false;
public StateHandler(Processor p)
processor = p;
p.addControllerListener(this);
public boolean configured(int waitTime)
long startTime =
System.currentTimeMillis();
synchronized(this)
processor.configure();
while(!configured && !
failed)
try
wait
(waitTime);
catch
(InterruptedException ie)
System.out.println("Interrupted configure");
if
(System.currentTimeMillis() - startTime>waitTime)
break;
return configured;
public boolean realized(int waitTime)
long startTime =
System.currentTimeMillis();
synchronized(this)
processor.realize();
while(!realized &&!
failed)
try
wait
(waitTime);
catch
(InterruptedException ie)
System.out.println("Interrupted realize");
if
(System.currentTimeMillis()-startTime>waitTime)
break;
return realized;
public synchronized void controllerUpdate
(ControllerEvent cEvent)
if(cEvent instanceof
RealizeCompleteEvent)
realized=true;
else
if(cEvent instanceof
ConfigureCompleteEvent)
configured=true;
else
return;
notifyAll();
public boolean isClipSaved()
return clipSaved;
public class sinkEventHandler implements
DataSinkListener
DataSinkEvent dsEvent = new DataSinkEvent
(filewriter);
public void dataSinkUpdate(DataSinkEvent
dsEvent)
if(dsEvent instanceof
EndOfStreamEvent)
{ filewriter.close();
System.out.println
("Stream end");
processor.deallocate();
public boolean prepareToPlay()
try
if (player !=null) //if there was a dead player
player.close();
//change file to URL
String fileString = "file:///" +
this.getPath();
player =
Manager.createRealizedPlayer(new MediaLocator(fileString));
if (player == null)
System.out.println("No player");
return false;
else
System.out.println
("Player created");
return true;
catch(MalformedURLException e)
System.out.println("Invalid file or location");
return false;
catch (Exception e)
System.out.println("Other problem");
return false;
public void startPlaying()
player.start();
public void stopPlaying()
player.stop();
player.close();
public boolean prepareToRecord()
if (processor!=null)
processor.close();
Vector deviceList =
CaptureDeviceManager.getDeviceList(new AudioFormat
(AudioFormat.LINEAR));
CaptureDeviceInfo device = new
CaptureDeviceInfo();
if(deviceList.size()>0)
device = (CaptureDeviceInfo)
deviceList.lastElement();
System.out.println("Device found"+ device.toString());
else
System.out.println("Cannot find suitable device");
return false;
try
processor = Manager.createProcessor
(device.getLocator());
catch(IOException e)
System.out.println("IOException");
return false;
catch(NoProcessorException e)
System.out.println("No processor");
return false;
StateHandler sHandler = new StateHandler
(processor);
if(!sHandler.configured(10000))
System.out.println("Not configured");
return false;
processor.setContentDescriptor(new
FileTypeDescriptor(FileTypeDescriptor.WAVE));
//setContentDescriptor to type
if(!sHandler.realized(1000))
System.out.println("Not realized");
return false;
//Set output content type and realise processor
DataSource source =
processor.getDataOutput();
Control c = (Control)processor.getControl
("javax.media.control.BufferControl");
if (c != null)
int bufferLength = 500;
((BufferControl)c).setBufferLength
(bufferLength);
System.out.println("Buffer set at " +
bufferLength);
//create a file protocol MediaLocator with target file
String fileString = "file:///" + this.getPath();
MediaLocator target = new MediaLocator
(fileString);
//create a datasink to do writing to file and open sink
try
filewriter =
Manager.createDataSink(source,target);
System.out.println("Sink created");
filewriter.addDataSinkListener
(new sinkEventHandler());
filewriter.open();
System.out.println("filewriter open");
catch(Exception e)
System.out.println("error " + e);
return false;
try
filewriter.start();
System.out.println("filewriter started");
System.out.println("Start recording");
catch(IOException e)
System.out.println("filewriter start exception" + e);
return false;
return true;
public void startRecording()
processor.start();
public void stopRecording()
processor.stop();
processor.close();
filewriter.close();
public boolean prepareToSave()
try
if(processor != null)
processor.close();
Format formats[]=new Format[1];
formats[0] = new AudioFormat
(AudioFormat.ULAW,8000,8,1);
FileTypeDescriptor outputType =
(new FileTypeDescriptor(FileTypeDescriptor.BASIC_AUDIO));
String fileString = "file:///" +
this.getPath();
processor =
Manager.createRealizedProcessor(new ProcessorModel(new
MediaLocator(fileString),formats,outputType));
System.out.println("Processor created");
Control c = (Control)
processor.getControl("javax.media.control.BufferControl");
if (c != null)
int bufferLength = 500;
((BufferControl)c).setBufferLength
(bufferLength);
System.out.println("Buffer set at " +
bufferLength);
processor.addControllerListener(new
processorListener());
System.out.println("processor controller");
return true;
catch(IOException e)
{ System.out.println("IOException");
return false;
catch(NoProcessorException e)
{ System.out.println("No processor");
return false;
catch(CannotRealizeException e)
System.out.println
("CannotRealizeException");
return false;
catch(Exception e)
System.out.println("Error " + e);
return false;
public void setPlayerTime(Time time)
player.setMediaTime(time);
public void setPlayerStopTime(Time time)
player.setStopTime(time);
public void setProcessorTime(Time time)
processor.setMediaTime(time);
public void setProcessorStopTime(Time time)
processor.setStopTime(time);
public Time getPlayerTime()
Time time= player.getMediaTime();
return time;
public Time getProcessorTime()
Time time= processor.getMediaTime();
return time;
public boolean saveClip(String fileName)
if(!createSink(fileName))
return false;
clipSaved = false;
processor.start();
return true;
public void close()
if(player != null)
player.close();
if(processor != null)
processor.close();
if(filewriter != null)
filewriter.close();
public void deallocate()
if(player != null)
player.deallocate();
if(processor != null)
processor.deallocate();
private boolean createSink(String fileName)
//get output from processor
DataSource source = processor.getDataOutput
//create a file protocol MediaLocator with target file
MediaLocator target = new MediaLocator("file:///" + fileName);
//create a datasink to write to file and open sink
try
filewriter = Manager.createDataSink
(source,target);
filewriter.addDataSinkListener
(new sinkEventHandler());
filewriter.open();
System.out.println("Sink opened");
catch(NoDataSinkException e)
{ System.out.println("No DataSink");
return false;
catch(IOException e)
{ System.out.println("IO Exception");
return false;
catch(SecurityException e)
{ System.out.println("Security Exception");
return false;
try
{ filewriter.start();
System.out.println("Sink started");
catch(IOException e)
{ System.out.println("Filewriter start exception");
return false;
return true;
public class processorListener implements
ControllerListener
{ public void controllerUpdate(ControllerEvent
event)
{ if (event instanceof StopAtTimeEvent)
{ processor.stop();
processor.close();
System.out.println
("StopAtTimeEvent");
processor.deallocate();
System.out.println
("Processor closed");
clipSaved = true;
filewriter.close();
}

Similar Messages

  • How to create a interface with NTR from SAP XI?

    How to create a interface with NTR from SAP XI?

    Hi,
        What do you mean by NTR ?...
    What are the details you needed...Please be clear and more elaborative as far as possible..so that you will get straight forward answers...
    HTH
    Rajesh

  • How to create own interface without .cpp file?

    how to create own interface without using .cpp file ? To access the method inside the interface .
    e.g.  ILayoutTarget.
      Should not be SDKFileHelper.h because they are using SDKFileHelper.cpp file

    Rathan,
    PLz chk the below link (PDF file)
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d23cbe11-0d01-0010-5287-873a22024f79?quicklink=index&overridelayout=true
    Mutti

  • How to create web interface whose name includes _ (underscore)

    Hi Experts,
    In my project we are creating web interface. The steps are as below:
    1) Run transaction code upspm and copy the planning folder
    2) Save the planning folder as web enabled planning folder
    3) Generate web interface for step 2. Here I have to provide following details:
    Name of planning folder
    Web Application
    Package
    I have to create Web Application whose name should include _ like ztest_test
    The system is not allowing me to create web application whose name includes _
    Can you please how I can create web application whose name includes _
    I am not allowed to use the wizard or manual method to create web interface.
    Regards,

    Hi
    U can use the transaction BPS_WB to create u r web interface builder and for execute check another transaction BPS_wef (check once).
    UPSPM for planning folder not for web interface builder.
    Thanks,
    Debasish

  • How to create class interface

    Hi all,
    How shud i create class interface.
    Does this have an impact with the activation of program in sicf txn.
    basically my problem is i did not create a class interface or implement it.
    when i go into sicf txn i cant my program.
    please help me out.
    Regards,
    varun

    Vadnala,
    Go to SE24 to create your class interface and take a look at the tutorials we have spread in the SAP help and SDN. Take a quick look at BSP aplications SBSPEXT_*.
    Regards,
    Alexandre

  • How to create an interface if the class has a nested class

    I have the following class
    public class SampleImport{
    public SampleResult import (InputSource xml) {
    SampleResult sampleResult = new SampleResult();
              //do something
              return sampleResult;
    public static class SampleResult {
              public final String sampleName;
              public SampleResult (String s) {
                   sampleName = s;
    I would like to create an interface for this class for teh following method signature 'SampleResult import(InputSource(xml))', how would I create it ?
    Any help is appreciated,
    TIA,

    public interface Nameable {
        String getName();
    public interface Importable {
        Nameable importSource (InputSource xml);
    public class SampleImport implements Importable {
        @Override public SampleResult importSource (InputSource xml) {
            SampleResult sampleResult = new SampleResult("foo");
            //do something
            return sampleResult;
        public static class SampleResult implements Nameable {
            public final String sampleName;
            public SampleResult (String s) {
                sampleName = s;
            @Override public String getName() {
                return sampleName;
    }edit: er, you do know import is a keyword?

  • How to create Tagging Interface?

    Hello, Java expert around the world, pls help me on this:
    There are a few tagging interface in java's core such as java.rmi.Remote and java.io.Serialization.
    How to create customize tagging interface?

    We need it to mark a class!
    If your class implements Serializable then you are saying it is ok to be serialized.
    It's just a way to indicate that a class is capable of something, to tag it in some way.hmm...a class is capable of something....if a class implement java.io.Serializable, then what are the things that the new class capable to do?
    Where is the functionlity(method, or behaviour)? Since there is no method declared under this interface...

  • How to create tabbed interface

    Does anyone know in depth turotials how to create a tabbed
    interface without loading the whole page every time I click on
    different tab?
    here is the example from adobe website. You will see the
    second tab table where you don't see to reload the page if you
    click on another tab. That's what I want to create.
    http://www.adobe.com/products/dreamweaver/upgrade.html
    appreciate it

    In article <e5ah5e$pp1$[email protected]>,
    "Symbols" <[email protected]> wrote:
    > Does anyone know in depth turotials how to create a
    tabbed interface without
    > loading the whole page every time I click on different
    tab?
    >
    > here is the example from adobe website. You will see the
    second tab table
    > where you don't see to reload the page if you click on
    another tab. That's
    > what
    > I want to create.
    > <a target=_blank class=ftalternatingbarlinklarge
    > href="
    http://www.adobe.com/products/dreamweaver/upgrade.html
    >
    > appreciate">
    http://www.adobe.com/products/dreamweaver/upgrade.html
    >
    > appreciate</a> it
    http://projectseven.com is one
    place to check if they have the tabbed
    interface tutorial there. I had the book with Al's tutorial
    but was
    created for DW4.x. It's a lot of different layers and did get
    confusing
    for me to produce a site with them -- but each tab led to a
    different
    page!

  • [Solved]How to create ADF interface View

    Hi All,
    I have a design problem that I need some help with.
    In one of the pages in our application, we have two drop down boxes one with account type and another with account name (label) and account number (value).
    The account types are Escrow, Credit and Misc (some other types). all three types are in three different tables.
    Now the problem is, in the page when the account type is selected, the second drop down box should be filled with respective account numbers.
    So my question is Can I create an interface view and implement in all three different account type views and use it for second drop down box.
    Thanks in advance for your help.
    Thanks
    Praveen
    Message was edited by:
    bpraveen
    Message was edited by:
    bpraveen

    You might do a VO with a union of the three tables - use a custom SELECT like this:
    SELECT 'Escrow' account_type, account_number, balance, ... FROM escrow_accounts
    UNION
    SELECT 'Credit', account_number, balance, ... FROM credit_accounts
    UNION
    SELECT 'Misc.', account_number, balance, ... FROM misc_accountsUse NULL for any column in a table that does not have that column. I'm not sure if you can use Entity Objects (one EO per table) with such a VO to make the data updatable - it might have to be a read-only VO.
    Or create a database view with this SELECT and base the VO on that view instead of a table. You can even make the view updatable with INSTEAD OF triggers and base an EO on the view.

  • How to creat the interface of auto CAD file with labview

     Hi
    I have been controling  2-axis Piezo motor  with labview. Now I have to use the dwg or dxf file  to move the piezo controller axis. How I can  transform the  dwg or dxf  file into  decimal number 1, -1   to create interface with my labview.

    Hi Nusrat,
    So it sounds like you want to create a CAD drawing and then control your piezo motor via LabVIEW by moving the CAD drawing?  Is that correct?
    If that is correct - I don't know of a way to do this I'm afraid.  I don't think it's really possible.
    The only potential way to do this is to use SolidWorks as your CAD program and then convert the SolidWorks drawing into an STL file, which can then be imported into LabVIEW as a 3D picture control.  I can't think of any other way to achieve this.
    These examples might help you:
    LabVIEW Interface VIs for SolidWorks
    STL Geometry in 3D Picture Control
    The Pitch Perfect Tuner
    Develop Motion Applications with RIO and SolidWorks
    NI SoftMotion for SolidWorks
    Connect NI LabVIEW and DS SolidWorks
    I hope that helps.
    Oli
    LabVIEW Student Ambassador
    National Instruments UK

  • How to create WEBGUI interface for own-created program

    Hi experts!
    Could you please suggest me:
    Some of our end-users have to work with WEBGUI interface. In T-code VL02N we have our userexit SAPLZSDEXIT (Screen 0110). And in WEBGUI we don't see this tab in VL02N. I think I have to generate web-interface for this screen. But how I can make it? This screen was developed by our ABAP-ers in se51 t-code.

    Solved

  • How to Create Service Interface from WSDL file

    Dear Experts,
    Required your help in below scenario resolution.
    I have a WSDL file , from that WSDL file can I create a service interface.
    If yes than what are the steps for creating the same.
    Thanks & Regards,
    Rathan.

    Rathan,
    PLz chk the below link (PDF file)
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d23cbe11-0d01-0010-5287-873a22024f79?quicklink=index&overridelayout=true
    Mutti

  • How to create an interface for extractors from CRM to BI/BW

    Hi Experts,
                    My aim is to bring in data from CRM source to BI/BW target so for that we have found few extractors in CRM side which we need to use in BI. I would like to know how i can achieve this. I knw we can use web services for this, but i want to knw the procedure involved in doing this. I have mentioned few extractors which has to come from CRM system to BI/BW target system. Current we dont have these extractors in our BI/BW system. Also we dont have the connection to that particular CRM source. Please advice what has to be done for the above.
    Extractors
    1. 0CRM_FM_BPO
    2. 0CRM_FM_FND
    3. 0CRM_FM_FND_ATTR
    4. 0CRM_FM_FND_EXPENSE_TYPE_TEXT
    Thanks in advance
    Shiva

    Hi,
    First we need to create a RFC Connection between CRM To BW system. BASIS persons will create this connection.
    [Connection between Source Systems and BW|http://help.sap.com/saphelp_nw70/helpdata/en/b2/e50138fede083de10000009b38f8cf/frameset.htm]
    1.After that we can need to activate data sources in RSA5 in CRM system,
    2.post processing in RSA6 in CRM.
    3.Replicate source system in  BW system.
    those data sources will come to BW.
    Do Business content activation in BW. After you can create Info packages and load data.
    Regards,
    Madhu

  • Need information on how to create Idoc Inbound Interfaces for Business Sys

    Hi,
    I'm losing it.
    Can anyone point me to some documentation or an example of how to create inbound interfaces for Business Systems in PI 7.1.
    Here's the scenario
    I'm working on a B2B integration process which sends inbound idocs to an ECC 6.0 system.
    I've created the Business System communication component  but under the Inbound Interfaces it is blank.
    I want to have MBGMCR.MGBMCR03 as an inbound interface.
    But I forget how to get it there.
    For Business components you can just add the inbound interface.
    I've already defined the Business System in the SLD pointed it to the correct Tech System, imported the idoc definitions in the Enterprise Service Builder and set up IDX1, IDX2 to ensure the metadata exists in PI.
    But for Business systems the hep says that it's got to come from the SLD.
    Outbound/Inbound Interfaces
    For each business system, the interfaces that are installed on the business system are also entered in the SLD. These interfaces are displayed in this frame. You cannot add any other interfaces.
    I know I've done this before, but I can't remember how.
    Cheers,
    John

    Hi John ,
    Please have a look at the following links which might be of help to you
    PI 7.1 IDocs interfaces act as operations
    http://www.sdn.sap.com/irj/scn/weblogs;?blog=/pub/wlg/7933
    /people/peter.gutsche/blog/2008/10/27/what146s-new-in-sap-netweaver-pi-71
    There is a section in the following link on IDOC , have a look at the links in that section
    https://wiki.sdn.sap.com/wiki/display/XI/ImportantBlogsand+Notes
    Best Regards

  • How to create a login interface in labview PDA module?

    How to create a login interface in labview PDA module? So that it checks with a list of usernames and passwords and allow to go to another VI?
    Anu

    Anu,
    I've attached a really short example that does something like what you're talking about.  It just compares the user's username and password a pre-determined username and password and then "logs the user in" based on that comparison.  Like Greycat said, you probably want to store this username and password info in some sort of file on the PDA that's in an encrypted format for both security and flexibility of your application.
    I hope this helps,
    Justin D.
    Applications Engineer
    National Instruments
    Attachments:
    LoginVI.vi ‏17 KB

Maybe you are looking for

  • External Hard Drive no longer showing in Devices

    My external hard drive no longer shows up as a device on my MBP. It has worked fine since the day I plugged it in. The Time Machine is using the HD, and continues to do it's backups, so power and USB connection is not an issue The HD shows up in Disk

  • Save dirty file in editor

    Hi, I am writing an extension for the BEA workshop. My question is which API I should use to let the workshop save the current active file in the editor area, if the file is modified. (same behavior of trying to close a dirty java file: ask the user

  • I get no response when trying to load Targa files as an Image Sequence.  It has always worked in the past.

    I just upgraded from an earlier version of QT 7 Pro for Windows to the latest version (QT 7.6.9 Pro).  I have always had good results in QuickTime Pro importing Targa (.tga) image files rendered in Alias Maya as an Image Sequence, and then exporting

  • Forefront Protection Server Management Console

    I have an account called SUSR_computername that is created on install of FPSMC, and want to know what this account is used for, can this account password be changed? It appears to be used like IUSR_ for IIS but I can't find what/where it is being use

  • Installing 8i Personal

    I have Windows ME. The software from Prentice Hall for my class is Oracle 8i Pesonal Edition for Win 98; however, it says Win 98 or higher. Any known conflicts. I get the setup dialog box, then click install and then next and the box just leaves. Is