Strings issues
I need to write a simple code for something like this:
Write a program that analyzes a string as follows:
a. indicate if it ends with the three letters ing string compare = stringname.getChars(iend, 3);
b.
c. Print out the length of the string int count = stringname.length();
d. Print out the first character in the string string fdsdfs = stringname.getChars(istart, 1);
e. Print out the the second, through ninth character in the string
f. Print out the string in all lowercase letters
You should look at the methods defined for the String class in both your textbook and in the API to see if there are any that will make the analysis of this string easier.
Output: (given that the string was ?I love to program in Java.?)
ing ending: no
length: 26
first char: I
chars 2-9: love to
lowercase: i love to program in java.
Create this program procedurally ? with the main method
Any one?
you are so nice Melanie, lol. I did not know what I am getting myself into. Anyway I needed a technical class for my degree and I chose this one cause I thought it will be easy, but the teacher I have just from the first class gave us 7 quick labs to write like I am a fu*ing programmer. I do not like programing and I just need to pass the class. I am reading the book but it does not make sense. For you people that have some knowledge about programming I am sure it is easy, and yes I would love for someone to do the homework for me as I do not actually need to learn programming. Like I said it is Java1 and for a person that does not have any knowledge about programming to start writing 7 labs it is not easy, so please stop being sarcastic and say I do not wanna do it or help me. I did this with someone help and with what I could find on the net, but I still do not understand much. You guys if you wanna help you could tell me go here or there and give me some examples of similar code, that is how it is helpful not being sarcastic.
Ya and here is the code that I did but not with your guys sarcastic answers. I need help not sarcastic answers. If I post something it is because I do not know how to start, where to start.
* Strings.java
import javax.swing.JOptionPane;
public class Strings {
public static void main(String [] args) {
String s = (String)JOptionPane.showInputDialog("Type a string:\n");
JOptionPane.showMessageDialog(null,
"ing ending:"+( (s.endsWith("ing")) ? "yes" : "no" )+
"\nlength:"+s.length()+
"\nfirst char:"+s.charAt(0)+
"\nchars 2-9:"+s.substring(2,9)+
"\nlowercase:"+s.toLowerCase()
}
Similar Messages
-
Jabber for Windows v9.1 FCS - Dial String Issue
I thought the capability to cut and past phone numbers that started with a "(" was fixed in the newere version of J4W.
I just tried a copy/paste of a number pulled from the internet, but Jabber doesn't recognize it as a phone number.
A number that is entered in this format of (202) 762 1401 is not recognized as a dialable string. If I delete the first "(" then it is recognized and can be dialed. I can even put the "(" back and the number is still recognized as a dialable string.
Please let me know if this is still an outstanding issue, bug, or what.
Thanks,
ArrasHi Arras,
Thanks for reporting this problem. I have created a defect for tracking.
CSCud05630: Jabber doesn't recognize number format starting with (xxx)
This will be prioritized in due course for a future release.
Thanks,
Maqsood -
Newbie request.getParameter(String) issue
I'm having an issue setting a boolean value in a bean based off a string from request.getParameter(). I've created a small example to illustrate what I want to happen:
testForm.jsp:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
<title>testForm</title>
</head>
<body><form method="POST" action="testWork.jsp">
<input type="hidden" name="hiddenTest" value="1"/>
<input type="submit" name="submitTest" value="Submit"/>
</form></body>
</html>testWork.jsp:
<jsp:useBean id="test" scope="session"
class="thistestapp.testClass"/>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
<title>testWork</title>
</head>
<body>
<%
out.print("<p>" + request.getParameter("hiddenTest") + "</p>" );
// Great it's sending "1"
test.setTestB(request.getParameter("hiddenTest"));
//So when I set this in the bean I should get true
out.print("<p>" + test.getTestB() + "</p>" );
//False? Not nice!!
test.setTestB("1");
//Alright there must be an issue with my code in the bean, so hardcode a
//"1" in. I should still get false.
out.print("<p>" + test.getTestB() + "</p>" );
//True?? I hate you.
%>
</body>
</html>testClass.java:
package thistestapp;
public class testClass {
private Boolean testB;
public void setTestB(String testB) {
if ( testB == "1"){
this.testB = true;
else{
this.testB = false;
public Boolean getTestB() {
return testB;
}So, I want when the bean is sent a "1" from the form to set the bean value to true. I however can't get that to happen. I'm sure there's something I'm missing.
TIA.
Joe? if ( testB == "1"){
Standard beginner's error. If you want to test if two strings contain the same text, use the equals() method. Like this:if ( testB.equals("1")){Your code tests whether the two sides of the == operator refer to the same object. It's possible and likely for two different strings to contain the same value, which is what you are really interested in. -
Function Module GUI_DOWNLOAD: Type String Issue
I am working in 4.6C. I have used this Function Module many times in the past without issue, but not at this site. It abends and gives me the error message:
The call to the function module "GUI_DOWNLOAD" is incorrect:
The function module interface allows you to specify only fields
of a particular type under "FILENAME". The field "FNAME" specified here
has a different field type.
Here is the field declaration in the code:
PARAMETER: fname type rlgrap-filename DEFAULT 'C:/New_PO_Format.xls'.
The import parameter in GUI_DOWNLOAD for FILENAME is type STRING. When I double click on STRING in the FM I get "Unable to find a tool to process request". And, TYPE STRING does not exist in the system? I started making a Z version of GUI_DOWNLOAD, but it started giving me headaches because I had to start copying other SAP function modules.
Am I missing something? Or, is there a new and improved version of GUI_DOWNLOAD to use?data : v_file type string.
PARAMETER: fname type rlgrap-filename DEFAULT 'C:/New_PO_Format.xls'.
start-of-selection.
v_file = fname.
use v_file in gui_download parameter.
Thanks
Seshu -
Big string issue...
Hi BI & BW Gurus... I have an issue with the source system data... Its length is >260 chars.. And this is a comment data... I want to capture this comment & display as a text.. But when loading there;s some probs from SS.. What happened is just like that you can't be able to add 260+ chars right... Texts (:Long) is only 60chars; Med is 40 & short is 20! So, is there some method I can capture full 260 char string as a 'text'? Please do reply with your suggestions. on this issue...
Please go through the blog by Eugene Khusainov
/people/sap.user72/blog/2006/05/27/long-texts-in-sap-bw-modeling
/people/sap.user72/blog/2006/06/05/long-texts-in-sap-bw-displaying-in-bex-analyzer-introduction-to-excel-workbooks-formatting-part-i
/people/sap.user72/blog/2006/06/05/long-texts-in-sap-bw-displaying-in-bex-analyzer-introduction-to-excel-workbooks-formatting-part-ii
rgds, Ghuru -
Upon compiling, I am receiving the following errors:
TeamRosterApp.java:153: cannot find symbol
symbol : class ButtonPanel
location: class TeamRosterPanel
ButtonPanel buttonPanel;
^
TeamRosterApp.java:166: cannot find symbol
symbol : class ButtonPanel
location: class TeamRosterPanel
buttonPanel = new ButtonPanel();
^
2 errors
I've included the code below, but I having difficulty understanding why it cannot find the ButtonPanel class when that class is specified in the code (Line 364).
Thanks in advance for your help!
//Modified by Doe, John 20OCT2007
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.JTextComponent;
import java.util.ArrayList;
import java.text.*;
import java.lang.*;
import java.util.*;
public class TeamRosterApp
public static void main(String[] args)
TeamIO.getTeam();
JFrame frame = new TeamRosterFrame();
frame.setVisible(true);
class Player
String lname;
String fname;
int number;
public Player()
lname = "";
fname = "";
number = 0;
public Player(String lname, String fname, int number)
this.lname = lname;
this.fname = fname;
this.number = number;
public void setLastName(String lname)
this.lname = lname;
public String getLastName()
return lname;
public void setFirstName(String fname)
this.fname = fname;
public String getFirstName()
return fname;
public void setNumber(int number)
this.number = number;
public int getNumber()
return number;
class TeamIO
private static final ArrayList<Player> team = new ArrayList<Player>();
public static ArrayList<Player> getTeam()
team.add(new Player("Doe", "John", 69));
team.add(new Player("Berg", "Laura", 44));
team.add(new Player("Bustos", "Crystl", 6));
team.add(new Player("Clark", "Jamie", 24));
team.add(new Player("Fernandez", "Lisa", 16));
team.add(new Player("Finch", "Jennie", 27));
team.add(new Player("Flowers", "Tairia", 11));
team.add(new Player("Freed", "Amanda", 7));
team.add(new Player("Giordano", "Nicole", 4));
team.add(new Player("Harrigan", "Lori", 21));
team.add(new Player("Jung", "Lovieanne", 3));
team.add(new Player("Kretchman", "Kelly", 12));
team.add(new Player("Lappin", "Lauren", 37));
team.add(new Player("Mendoza", "Jessica", 2));
team.add(new Player("O'Brien-Amico", "Lisa", 20));
team.add(new Player("Nuveman", "Stacy", 33));
team.add(new Player("Osterman", "Catherine", 8));
team.add(new Player("Topping", "Jennie", 31));
team.add(new Player("Watley", "Natasha", 29));
System.out.println("\nOpening team list" + "\n\n" + "****************************************");
for(int i = 0; i < team.size(); i++)
Player p = (Player)team.get(i);
System.out.print(p.getNumber() + "\t" + p.getLastName() + "," + p.getFirstName() + "\n");
System.out.println("****************************************");
return new ArrayList<Player>(team);
public static ArrayList<Player> saveTeam()
System.out.println("\nOpening team list" + "\n\n" + "****************************************");
for(int i = 0; i < team.size(); i++)
Player p = (Player)team.get(i);
System.out.print(p.getNumber() + "\t" + p.getLastName() + "," + p.getFirstName() + "\n");
System.out.println("****************************************");
return new ArrayList<Player>(team);
class TeamRosterFrame extends JFrame
public TeamRosterFrame()
String me = "Campbell, Corey";
String date;
Date now = new Date();
DateFormat longDate = DateFormat.getDateInstance(DateFormat.LONG);
date = longDate.format(now);
setTitle("Team Roster "+me+" "+date);
setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.add(new TeamRosterPanel());
this.pack();
centerWindow(this);
private void centerWindow(Window w)
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension d = tk.getScreenSize();
setLocation((d.width-w.getWidth())/2, (d.height-w.getHeight())/2);
class TeamRosterPanel extends JPanel
ArrayList<Player>team;
Player newPlayer = null;
teamSelectorPanel selectorPanel;
PlayerDisplayPanel playerPanel;
ButtonPanel buttonPanel;
public TeamRosterPanel()
// fill the team ArrayList
team = TeamIO.getTeam();
// add the panels
setLayout(new GridBagLayout());
selectorPanel = new teamSelectorPanel();
add(selectorPanel, getConstraints(0,0,1,1, GridBagConstraints.WEST));
playerPanel = new PlayerDisplayPanel();
add(playerPanel, getConstraints(0,1,1,1, GridBagConstraints.EAST));
buttonPanel = new ButtonPanel();
add(buttonPanel, getConstraints(0,2,1,1, GridBagConstraints.EAST));
// set the initial player to be displayed
playerPanel.showPlayer(team.get(0));
selectorPanel.selectPlayer(team.get(0));
// a method for setting grid bag constraints
private GridBagConstraints getConstraints(int gridx, int gridy,
int gridwidth, int gridheight, int anchor)
GridBagConstraints c = new GridBagConstraints();
c.insets = new Insets(5, 5, 5, 5);
c.ipadx = 0;
c.ipady = 0;
c.gridx = gridx;
c.gridy = gridy;
c.gridwidth = gridwidth;
c.gridheight = gridheight;
c.anchor = anchor;
return c;
class teamSelectorPanel extends JPanel implements ActionListener
public JComboBox playerComboBox;
private JLabel playerLabel;
boolean filling = false; // used to indicate the combo box is being filled
public teamSelectorPanel()
// set panel layout
setLayout(new FlowLayout(FlowLayout.LEFT));
// Player label
playerLabel = new JLabel("Select Player:");
add(playerLabel);
// Player combo box
playerComboBox = new JComboBox();
fillComboBox(team);
playerComboBox.addActionListener(this);
add(playerComboBox);
public void actionPerformed(ActionEvent e)
if (!filling)
Player p = (Player)playerComboBox.getSelectedItem();
playerPanel.showPlayer(p);
public void fillComboBox(ArrayList<Player> team)
filling = true;
playerComboBox.removeAllItems();
for (Player p : team)
playerComboBox.addItem(p);
filling = false;
public void selectPlayer(Player p)
playerComboBox.setSelectedItem(p);
public Player getCurrentPlayer()
return (Player) playerComboBox.getSelectedItem();
class PlayerDisplayPanel extends JPanel
public JTextField lastNameTextField,
firstNameTextField,
numberTextField;
private JLabel lastNameLabel,
firstNameLabel,
numberLabel;
public PlayerDisplayPanel()
// set panel layout
setLayout(new GridBagLayout());
// last name label
lastNameLabel = new JLabel("Last name:");
add(lastNameLabel, getConstraints(0,0,1,1, GridBagConstraints.EAST));
// last name text field
lastNameTextField = new JTextField(10);
lastNameTextField.setEditable(false);
lastNameTextField.setFocusable(false);
lastNameTextField.addFocusListener(new AutoSelect());
add(lastNameTextField, getConstraints(1,0,1,1, GridBagConstraints.WEST));
// first name label
firstNameLabel = new JLabel("First name:");
add(firstNameLabel, getConstraints(0,1,1,1, GridBagConstraints.EAST));
// first name text field
firstNameTextField = new JTextField(30);
firstNameTextField.setEditable(false);
firstNameTextField.setFocusable(false);
firstNameTextField.addFocusListener(new AutoSelect());
add(firstNameTextField, getConstraints(1,1,1,1, GridBagConstraints.WEST));
// number label
numberLabel = new JLabel("Number:");
add(numberLabel, getConstraints(0,2,1,1, GridBagConstraints.EAST));
// number text field
numberTextField = new JTextField(10);
numberTextField.setEditable(false);
numberTextField.setFocusable(false);
numberTextField.addFocusListener(new AutoSelect());
numberTextField.addKeyListener(new IntFilter());
add(numberTextField, getConstraints(1,2,1,1, GridBagConstraints.WEST));
public void showPlayer(Player p)
lastNameTextField.setText(p.getLastName());
firstNameTextField.setText(p.getFirstName());
numberTextField.setText(String.valueOf(p.getNumber()));
public void clearFields()
lastNameTextField.setText("");
firstNameTextField.setText("");
numberTextField.setText("");
// return a new Player object with the data in the text fields
public Player getPlayer()
Player p = new Player();
p.setLastName(lastNameTextField.getText());
p.setFirstName(firstNameTextField.getText());
int n = Integer.parseInt(numberTextField.getText());
p.setNumber(n);
return p;
public void setAddEditMode(boolean e)
lastNameTextField.setEditable(e);
lastNameTextField.setFocusable(e);
lastNameTextField.requestFocusInWindow();
firstNameTextField.setEditable(e);
firstNameTextField.setFocusable(e);
numberTextField.setEditable(e);
numberTextField.setFocusable(e);
class AutoSelect implements FocusListener
public void focusGained(FocusEvent e)
if(e.getComponent() instanceof JTextField)
JTextField t = (JTextField) e.getComponent();
t.selectAll();
public void focusLost(FocusEvent e){}
class IntFilter implements KeyListener
public void keyTyped(KeyEvent e)
char c = e.getKeyChar();
if ( c !='0' && c !='1' && c !='2' && c !='3' && c !='4' && c !='5'
&& c !='6' && c !='7' && c !='8' && c !='9')
e.consume();
public void keyPressed(KeyEvent e){}
public void keyReleased(KeyEvent e){}
class ButtonPanel extends JPanel
public JButton addButton,
editButton,
deleteButton,
acceptButton,
cancelButton,
exitButton;
public ButtonPanel()
// create maintenance button panel
JPanel maintPanel = new JPanel();
maintPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
// add button
addButton = new JButton("Add");
addButton.addActionListener(new AddListener());
maintPanel.add(addButton);
// edit button
editButton = new JButton("Edit");
editButton.addActionListener(new EditListener());
maintPanel.add(editButton);
// delete button
deleteButton = new JButton("Delete");
deleteButton.addActionListener(new DeleteListener());
maintPanel.add(deleteButton);
// accept button
acceptButton = new JButton("Accept");
acceptButton.setEnabled(false);
acceptButton.addActionListener(new AcceptListener());
maintPanel.add(acceptButton);
// cancel button
cancelButton = new JButton("Cancel");
cancelButton.setEnabled(false);
cancelButton.addActionListener(new CancelListener());
maintPanel.add(cancelButton);
// create exit button panel
JPanel exitPanel = new JPanel();
exitPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
// exit button
exitButton = new JButton("Exit");
exitButton.addActionListener(new ExitListener());
exitPanel.add(exitButton);
// add panels to the ButtonPanel
setLayout(new BorderLayout());
add(maintPanel, BorderLayout.CENTER);
add(exitPanel, BorderLayout.SOUTH);
public void setAddEditMode(boolean e)
addButton.setEnabled(!e);
editButton.setEnabled(!e);
deleteButton.setEnabled(!e);
acceptButton.setEnabled(e);
cancelButton.setEnabled(e);
class AddListener implements ActionListener
public void actionPerformed(ActionEvent e)
newPlayer = new Player();
playerPanel.clearFields();
buttonPanel.setAddEditMode(true);
playerPanel.setAddEditMode(true);
class EditListener implements ActionListener
public void actionPerformed(ActionEvent e)
buttonPanel.setAddEditMode(true);
playerPanel.setAddEditMode(true);
class DeleteListener implements ActionListener
public void actionPerformed(ActionEvent e)
Player p = selectorPanel.getCurrentPlayer();
team.remove(p);
TeamIO.saveTeam();
selectorPanel.fillComboBox(team);
selectorPanel.selectPlayer(team.get(0));
playerPanel.showPlayer(team.get(0));
selectorPanel.playerComboBox.requestFocusInWindow();
class AcceptListener implements ActionListener
public void actionPerformed(ActionEvent e)
if (isValidData())
if (newPlayer != null)
newPlayer = playerPanel.getPlayer();
team.add(newPlayer);
TeamIO.saveTeam();
selectorPanel.fillComboBox(team);
selectorPanel.selectPlayer(newPlayer);
newPlayer = null;
else
Player p = selectorPanel.getCurrentPlayer();
Player newPlayer = playerPanel.getPlayer();
p.setLastName(newPlayer.getLastName());
p.setFirstName(newPlayer.getFirstName());
p.setNumber(newPlayer.getNumber());
TeamIO.saveTeam();
selectorPanel.fillComboBox(team);
selectorPanel.selectPlayer(p);
playerPanel.showPlayer(selectorPanel.getCurrentPlayer());
playerPanel.setAddEditMode(false);
buttonPanel.setAddEditMode(false);
selectorPanel.playerComboBox.requestFocusInWindow();
public boolean isValidData()
return SwingValidator.isPresent(playerPanel.lastNameTextField, "Last Name")
&& SwingValidator.isPresent(playerPanel.firstNameTextField, "First Name")
&& SwingValidator.isPresent(playerPanel.numberTextField, "Number")
&& SwingValidator.isInteger(playerPanel.numberTextField, "Number");
class CancelListener implements ActionListener
public void actionPerformed(ActionEvent e)
if (newPlayer != null)
newPlayer = null;
playerPanel.setAddEditMode(false);
playerPanel.showPlayer(selectorPanel.getCurrentPlayer());
buttonPanel.setAddEditMode(false);
selectorPanel.playerComboBox.requestFocusInWindow();
class ExitListener implements ActionListener
public void actionPerformed(ActionEvent e)
System.exit(0);
}Swing Validator Code:
//Programmed by Doe, John 20OCT2007
import javax.swing.*;
import javax.swing.text.JTextComponent;
public class SwingValidator
public static boolean isPresent(JTextComponent c, String title)
if(c.getText().length()==0)
showMessage(c, title + " is a required field.\n" + "Please re-enter.");
c.requestFocusInWindow();
return false;
return true;
public static boolean isInteger(JTextComponent c, String title)
try
int i = Integer.parseInt(c.getText());
return true;
catch(NumberFormatException e)
showMessage(c,title+" must be an integer.\n"+"Please re-enter.");
c.requestFocusInWindow();
return false;
private static void showMessage(JTextComponent c, String message)
JOptionPane.showMessageDialog(c, message, "Invalid Entry", JOptionPane.ERROR_MESSAGE);
}Edited by: kc0poc on Oct 21, 2007 8:17 AMOk. Got it, understand it now. Corrected all 58 errors after created the top level classes. It compiles, but I'm now encountering a NullPointerException:
Exception in thread "main" java.lang.NullPointerException
at teamSelectorPanel.fillComboBox(TeamRosterAppTest.java:233)
at teamSelectorPanel.<init>(TeamRosterAppTest.java:214)
at TeamRosterPanel.<init>(TeamRosterAppTest.java:164)
at TeamRosterFrame.<init>(TeamRosterAppTest.java:135)
at TeamRosterAppTest.main(TeamRosterAppTest.java:17)
I think I am not initializing something correctly and it involved the "team" variable. Thoughts anyone?
Thank you as always!
Below is my code:
//Modified by Campbell, Corey 20OCT2007
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.JTextComponent;
import java.util.ArrayList;
import java.text.*;
import java.lang.*;
import java.util.*;
public class TeamRosterAppTest
public static void main(String[] args)
TeamIO.getTeam();
JFrame frame = new TeamRosterFrame();
frame.setVisible(true);
class Player
String lname;
String fname;
int number;
public Player()
lname = "";
fname = "";
number = 0;
public Player(String lname, String fname, int number)
this.lname = lname;
this.fname = fname;
this.number = number;
public void setLastName(String lname)
this.lname = lname;
public String getLastName()
return lname;
public void setFirstName(String fname)
this.fname = fname;
public String getFirstName()
return fname;
public void setNumber(int number)
this.number = number;
public int getNumber()
return number;
class TeamIO
private static final ArrayList<Player> team = new ArrayList<Player>();
public static ArrayList<Player> getTeam()
team.add(new Player("Campbell", "Corey", 69));
team.add(new Player("Berg", "Laura", 44));
team.add(new Player("Bustos", "Crystl", 6));
team.add(new Player("Clark", "Jamie", 24));
team.add(new Player("Fernandez", "Lisa", 16));
team.add(new Player("Finch", "Jennie", 27));
team.add(new Player("Flowers", "Tairia", 11));
team.add(new Player("Freed", "Amanda", 7));
team.add(new Player("Giordano", "Nicole", 4));
team.add(new Player("Harrigan", "Lori", 21));
team.add(new Player("Jung", "Lovieanne", 3));
team.add(new Player("Kretchman", "Kelly", 12));
team.add(new Player("Lappin", "Lauren", 37));
team.add(new Player("Mendoza", "Jessica", 2));
team.add(new Player("O'Brien-Amico", "Lisa", 20));
team.add(new Player("Nuveman", "Stacy", 33));
team.add(new Player("Osterman", "Catherine", 8));
team.add(new Player("Topping", "Jennie", 31));
team.add(new Player("Watley", "Natasha", 29));
//System.out.println("\nOpening team list" + "\n\n" + "****************************************");
//for(int i = 0; i < team.size(); i++)
// Player p = (Player)team.get(i);
// System.out.print(p.getNumber() + "\t" + p.getLastName() + "," + p.getFirstName() + "\n");
//System.out.println("****************************************");
return new ArrayList<Player>(team);
public static ArrayList<Player> saveTeam()
System.out.println("\nOpening team list" + "\n\n" + "****************************************");
for(int i = 0; i < team.size(); i++)
Player p = (Player)team.get(i);
System.out.print(p.getNumber() + "\t" + p.getLastName() + "," + p.getFirstName() + "\n");
System.out.println("****************************************");
return new ArrayList<Player>(team);
class TeamRosterFrame extends JFrame
public TeamRosterFrame()
String me = "Campbell, Corey";
String date;
Date now = new Date();
DateFormat longDate = DateFormat.getDateInstance(DateFormat.LONG);
date = longDate.format(now);
setTitle("Team Roster "+me+" "+date);
setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.add(new TeamRosterPanel());
this.pack();
centerWindow(this);
private void centerWindow(Window w)
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension d = tk.getScreenSize();
setLocation((d.width-w.getWidth())/2, (d.height-w.getHeight())/2);
class TeamRosterPanel extends JPanel
ArrayList<Player>team;
Player newPlayer = null;
teamSelectorPanel selectorPanel;
PlayerDisplayPanel playerPanel;
ButtonPanel buttonPanel;
public TeamRosterPanel()
// fill the team ArrayList
team = TeamIO.getTeam();
// add the panels
setLayout(new GridBagLayout());
selectorPanel = new teamSelectorPanel();
add(selectorPanel, getConstraints(0,0,1,1, GridBagConstraints.WEST));
playerPanel = new PlayerDisplayPanel();
add(playerPanel, getConstraints(0,1,1,1, GridBagConstraints.EAST));
buttonPanel = new ButtonPanel();
add(buttonPanel, getConstraints(0,2,1,1, GridBagConstraints.EAST));
// set the initial player to be displayed
playerPanel.showPlayer(team.get(0));
selectorPanel.selectPlayer(team.get(0));
// a method for setting grid bag constraints
private GridBagConstraints getConstraints(int gridx, int gridy,
int gridwidth, int gridheight, int anchor)
GridBagConstraints c = new GridBagConstraints();
c.insets = new Insets(5, 5, 5, 5);
c.ipadx = 0;
c.ipady = 0;
c.gridx = gridx;
c.gridy = gridy;
c.gridwidth = gridwidth;
c.gridheight = gridheight;
c.anchor = anchor;
return c;
class teamSelectorPanel extends JPanel implements ActionListener
public JComboBox playerComboBox;
private JLabel playerLabel;
boolean filling = false; // used to indicate the combo box is being filled
ArrayList<Player>team;
PlayerDisplayPanel playerPanel;
public teamSelectorPanel()
// set panel layout
setLayout(new FlowLayout(FlowLayout.LEFT));
// Player label
playerLabel = new JLabel("Select Player:");
add(playerLabel);
// Player combo box
playerComboBox = new JComboBox();
fillComboBox(team);
playerComboBox.addActionListener(this);
add(playerComboBox);
public void actionPerformed(ActionEvent e)
if (!filling)
Player p = (Player)playerComboBox.getSelectedItem();
playerPanel.showPlayer(p);
public void fillComboBox(ArrayList<Player> team)
filling = true;
playerComboBox.removeAllItems();
for (Player p : team)
playerComboBox.addItem(p);
filling = false;
public void selectPlayer(Player p)
playerComboBox.setSelectedItem(p);
public Player getCurrentPlayer()
return (Player) playerComboBox.getSelectedItem();
class PlayerDisplayPanel extends JPanel
public JTextField lastNameTextField,
firstNameTextField,
numberTextField;
private JLabel lastNameLabel,
firstNameLabel,
numberLabel;
public PlayerDisplayPanel()
// set panel layout
setLayout(new GridBagLayout());
// last name label
lastNameLabel = new JLabel("Last name:");
add(lastNameLabel, getConstraints(0,0,1,1, GridBagConstraints.EAST));
// last name text field
lastNameTextField = new JTextField(10);
lastNameTextField.setEditable(false);
lastNameTextField.setFocusable(false);
lastNameTextField.addFocusListener(new AutoSelect());
add(lastNameTextField, getConstraints(1,0,1,1, GridBagConstraints.WEST));
// first name label
firstNameLabel = new JLabel("First name:");
add(firstNameLabel, getConstraints(0,1,1,1, GridBagConstraints.EAST));
// first name text field
firstNameTextField = new JTextField(30);
firstNameTextField.setEditable(false);
firstNameTextField.setFocusable(false);
firstNameTextField.addFocusListener(new AutoSelect());
add(firstNameTextField, getConstraints(1,1,1,1, GridBagConstraints.WEST));
// number label
numberLabel = new JLabel("Number:");
add(numberLabel, getConstraints(0,2,1,1, GridBagConstraints.EAST));
// number text field
numberTextField = new JTextField(10);
numberTextField.setEditable(false);
numberTextField.setFocusable(false);
numberTextField.addFocusListener(new AutoSelect());
numberTextField.addKeyListener(new IntFilter());
add(numberTextField, getConstraints(1,2,1,1, GridBagConstraints.WEST));
public void showPlayer(Player p)
lastNameTextField.setText(p.getLastName());
firstNameTextField.setText(p.getFirstName());
numberTextField.setText(String.valueOf(p.getNumber()));
public void clearFields()
lastNameTextField.setText("");
firstNameTextField.setText("");
numberTextField.setText("");
// return a new Player object with the data in the text fields
public Player getPlayer()
Player p = new Player();
p.setLastName(lastNameTextField.getText());
p.setFirstName(firstNameTextField.getText());
int n = Integer.parseInt(numberTextField.getText());
p.setNumber(n);
return p;
public void setAddEditMode(boolean e)
lastNameTextField.setEditable(e);
lastNameTextField.setFocusable(e);
lastNameTextField.requestFocusInWindow();
firstNameTextField.setEditable(e);
firstNameTextField.setFocusable(e);
numberTextField.setEditable(e);
numberTextField.setFocusable(e);
// a method for setting grid bag constraints
private GridBagConstraints getConstraints(int gridx, int gridy,
int gridwidth, int gridheight, int anchor)
GridBagConstraints c = new GridBagConstraints();
c.insets = new Insets(5, 5, 5, 5);
c.ipadx = 0;
c.ipady = 0;
c.gridx = gridx;
c.gridy = gridy;
c.gridwidth = gridwidth;
c.gridheight = gridheight;
c.anchor = anchor;
return c;
class AutoSelect implements FocusListener
public void focusGained(FocusEvent e)
if(e.getComponent() instanceof JTextField)
JTextField t = (JTextField) e.getComponent();
t.selectAll();
public void focusLost(FocusEvent e){}
class IntFilter implements KeyListener
public void keyTyped(KeyEvent e)
char c = e.getKeyChar();
if ( c !='0' && c !='1' && c !='2' && c !='3' && c !='4' && c !='5'
&& c !='6' && c !='7' && c !='8' && c !='9')
e.consume();
public void keyPressed(KeyEvent e){}
public void keyReleased(KeyEvent e){}
class ButtonPanel extends JPanel
public JButton addButton,
editButton,
deleteButton,
acceptButton,
cancelButton,
exitButton;
public ButtonPanel()
// create maintenance button panel
JPanel maintPanel = new JPanel();
maintPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
// add button
addButton = new JButton("Add");
addButton.addActionListener(new AddListener());
maintPanel.add(addButton);
// edit button
editButton = new JButton("Edit");
editButton.addActionListener(new EditListener());
maintPanel.add(editButton);
// delete button
deleteButton = new JButton("Delete");
deleteButton.addActionListener(new DeleteListener());
maintPanel.add(deleteButton);
// accept button
acceptButton = new JButton("Accept");
acceptButton.setEnabled(false);
acceptButton.addActionListener(new AcceptListener());
maintPanel.add(acceptButton);
// cancel button
cancelButton = new JButton("Cancel");
cancelButton.setEnabled(false);
cancelButton.addActionListener(new CancelListener());
maintPanel.add(cancelButton);
// create exit button panel
JPanel exitPanel = new JPanel();
exitPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
// exit button
exitButton = new JButton("Exit");
exitButton.addActionListener(new ExitListener());
exitPanel.add(exitButton);
// add panels to the ButtonPanel
setLayout(new BorderLayout());
add(maintPanel, BorderLayout.CENTER);
add(exitPanel, BorderLayout.SOUTH);
public void setAddEditMode(boolean e)
addButton.setEnabled(!e);
editButton.setEnabled(!e);
deleteButton.setEnabled(!e);
acceptButton.setEnabled(e);
cancelButton.setEnabled(e);
class AddListener implements ActionListener
PlayerDisplayPanel playerPanel;
ButtonPanel buttonPanel;
Player newPlayer;
public void actionPerformed(ActionEvent e)
newPlayer = new Player();
playerPanel.clearFields();
buttonPanel.setAddEditMode(true);
playerPanel.setAddEditMode(true);
class EditListener implements ActionListener
ButtonPanel buttonPanel;
PlayerDisplayPanel playerPanel;
public void actionPerformed(ActionEvent e)
buttonPanel.setAddEditMode(true);
playerPanel.setAddEditMode(true);
class DeleteListener implements ActionListener
teamSelectorPanel selectorPanel;
PlayerDisplayPanel playerPanel;
ArrayList<Player>team;
public void actionPerformed(ActionEvent e)
Player p = selectorPanel.getCurrentPlayer();
team.remove(p);
TeamIO.saveTeam();
selectorPanel.fillComboBox(team);
selectorPanel.selectPlayer(team.get(0));
playerPanel.showPlayer(team.get(0));
selectorPanel.playerComboBox.requestFocusInWindow();
class AcceptListener implements ActionListener
teamSelectorPanel selectorPanel;
PlayerDisplayPanel playerPanel;
ButtonPanel buttonPanel;
ArrayList<Player>team;
Player newPlayer;
public void actionPerformed(ActionEvent e)
if (isValidData())
if (newPlayer != null)
newPlayer = playerPanel.getPlayer();
team.add(newPlayer);
TeamIO.saveTeam();
selectorPanel.fillComboBox(team);
selectorPanel.selectPlayer(newPlayer);
newPlayer = null;
else
Player p = selectorPanel.getCurrentPlayer();
Player newPlayer = playerPanel.getPlayer();
p.setLastName(newPlayer.getLastName());
p.setFirstName(newPlayer.getFirstName());
p.setNumber(newPlayer.getNumber());
TeamIO.saveTeam();
selectorPanel.fillComboBox(team);
selectorPanel.selectPlayer(p);
playerPanel.showPlayer(selectorPanel.getCurrentPlayer());
playerPanel.setAddEditMode(false);
buttonPanel.setAddEditMode(false);
selectorPanel.playerComboBox.requestFocusInWindow();
public boolean isValidData()
return SwingValidator.isPresent(playerPanel.lastNameTextField, "Last Name")
&& SwingValidator.isPresent(playerPanel.firstNameTextField, "First Name")
&& SwingValidator.isPresent(playerPanel.numberTextField, "Number")
&& SwingValidator.isInteger(playerPanel.numberTextField, "Number");
class CancelListener implements ActionListener
Player newPlayer;
PlayerDisplayPanel playerPanel;
ButtonPanel buttonPanel;
teamSelectorPanel selectorPanel;
public void actionPerformed(ActionEvent e)
if (newPlayer != null)
newPlayer = null;
playerPanel.setAddEditMode(false);
playerPanel.showPlayer(selectorPanel.getCurrentPlayer());
buttonPanel.setAddEditMode(false);
selectorPanel.playerComboBox.requestFocusInWindow();
class ExitListener implements ActionListener
public void actionPerformed(ActionEvent e)
System.exit(0);
class SwingValidator
public static boolean isPresent(JTextComponent c, String title)
if(c.getText().length()==0)
showMessage(c, title + " is a required field.\n" + "Please re-enter.");
c.requestFocusInWindow();
return false;
return true;
public static boolean isInteger(JTextComponent c, String title)
try
int i = Integer.parseInt(c.getText());
return true;
catch(NumberFormatException e)
showMessage(c,title+" must be an integer.\n"+"Please re-enter.");
c.requestFocusInWindow();
return false;
private static void showMessage(JTextComponent c, String message)
JOptionPane.showMessageDialog(c, message, "Invalid Entry", JOptionPane.ERROR_MESSAGE);
} -
Been looking at the code all day but if I can get a little help this would be great...
I have a hashtable of buttons and strings and i run a loop to see if they are true...
public static String checkCaja()
String temp="";
for(String name:checkboxes.keySet()){
// System.out.println(checkboxes.get(name).isSelected()+name);
if (checkboxes.get(name).isSelected()==true)
temp=temp+name+",";
return temp;
}the temp returns the strings with an ','. So I will get a
From one,two,three,four, five,
I would like to remove the last comma from the last word added... any ideas?
It should look like one, two,three,four,five
Thank you in advance!As long as we are tweaking code, when you're iterating over names and values, you should use the entry set:
String f(Map<String, JCheckBox> checkboxes) {
StringBuffer sb = new StringBuffer();
for(Map.Entry < String, JCheckBox > e : checkboxes.entrySet()) {
if(e.getValue().isSelected()) {
if (sb.length() > 0)
sb.append(", ");
sb.append(e.getKey());
return sb.toString();
}I would also go with adding the delimiter every time, then substringing to remove the last one, if any:
String f(Map<String, JCheckBox> checkboxes) {
String DELIM = ", ";
StringBuffer sb = new StringBuffer();
for(Map.Entry < String, JCheckBox > e : checkboxes.entrySet())
if(e.getValue().isSelected())
sb.append(e.getKey()).append(DELIM);
String s = sb.toString();
int length = s.length();
return length > 0 ? s.substring(0, length - DELIM.length()) : s;
} -
Workaround for "Unable to Assemble Book-NSPlaceholderMutable String issue
I got the problem when I was putting a book together. I tried to assemble the book and got the error "Unable to Assemble Book-NSPlaceholderMutableString initWithString: nil argument" The error seems to come up when the Title or Subtitle field is blank on the Cover of a Hardcover book.
I added a space to the empty text field (in my case the subtitle) and I was able to successfully place an order for the book.Thank you very much, Anastassios!
I was stuck with my book, ready to print and wasted a lot of time asking around for what seemed to be a system error message string.
Now I resolved, following your workaround. In my case I had to edit ALL text frames I modified (deleting the default text, for instance) adding a simple space.
Thank you again. -
Hey Team, I am looking for the proper way to do this if the way I am doing it is not correct.
I use a get digit string and play a menu prompt to a caller
Press 1
Press 2
Press 3
Etc...
But if the caller presses a 5 digit code they get a super secret special menu. All this works great. When i do the debug I see the digits being passed to the sCED variable I use. 99% of all callers are not pressing the pound key after thier key press so the get digit string timeout brance gets used.
I have fixed this in two ways. I use an if statement in the timeout to check if sCED has a value I then send it to another if statement for routing to the various menu options.
THe out way I fixed this is I just send every call which hits the time out on to be processed and evaluated.
Am I doing this correctly? It all works fine but I wanted to make sure there are no gotchas or better ways to accomplish this.
Having the caller pass both a single digit and 5 digits is why I use the get digit string instead of a menu step.
See screen shot. Thanks in advance for any feedback.
Go Butler Bulldogs!!A couple of suggestions in the form of pseudo code (all in the name of effeciency):
label main_menu_resetset counter = 0label main_menuced = get digit string(timeout 3 sec, inter-digit 1 sec, no terminating or cancel digit, no retries) successful label main_menu_success if (ced == super_secret_key) true goto super_secret_section false switch (ced) case "1" /* do menu option 1 tasks */ case N /* do menu option N tasks */ default goto main_menu_failure timeout goto main_menu_success unsuccessful label main_menu_failure play prompt (invalid) if (++counter > maximum) true goto customer_service false play prompt (try_again) goto main_menu
Questions to ask yourself about your approach and this new approach:
How many steps do I have in this solution (not counting branches)?
How many steps for best case scenario execution?
"" worst case scenario?
How easy is it to change the super secret key (and length of key)?
How easy is it to add/remove menu options (steps required to add)?
At how many points are you addressing the failures in your menu? -
TOC strings issue - VERY annoying
Hello all,
we have used the TOCStrings.ini to change the language and some other aspects of the TOC. Regretably I have found no possibily to alter this for existings projects or templates. If you create an english template, then change your TOCStrings.ini to french language and create a new project using the existing template, then the TOC is english again even though its a new project!
In our case, this is extremely annoying because we have to create new templates over and over again for each small change of the TOC strings, manually correcting all project setings each time.
Has any solution been found for this yet, or is there a better workaround that we am overlooking? I have already tried to edit the project file with a HEX editor without luck so far.Hi there,
Just to add to Lilybiri, excellet suggestion, please find below the web address to file any feature requests.
Adobe Captivate Feature Request/Bug Report Form
Best - Mark
Visit the macrofireball blog -
Weird String[][] issue
Hey all ,
Just need some help for this bidimensional Array .
I just want to do x [20][15] = "j";
But the ouput shows position x[0][0] also with "j" and not with "."
here it's the code:
public void desenhaquadro(String [][] x){
for(int i =1; i != x.length; i++){
for(int j= 1; j != x.length; j++){
if(x[i][j] == x[20][15]){
System.out.print(x[20][15] = "j");
}else System.out.print(x[i][j] = ".");
} System.out.println();
thankspublic class Tabuleiro {
public void drawboard(String[][] x) {
for (int i = 0; i != x.length; i++) {
for (int j = 0; j != x.length; j++) {
if (i == 20 && j == 15) {
x[i][j] = "L";
System.out.print(x[20][15]);
} else
System.out.print(x[i][j] = ".");
System.out.println();
public static void main(String[] xxx) {
Tabuleiro tabu = new Tabuleiro();
final int numLines = 28;
final int numColu = 48;
String[][] y = new String[numLines][numColu];
tabu.drawboard(y);
This works for me. Part of the problem is you are using == to compare strings when you do
if(x[i][j] == x[20][15])the other problem is that since you have not populated the array, every element in the array is null, so even if you do x[i][j].equals(x[20][15]) it will give you the wrong answer.
Message was edited by:
SomeoneElse
Message was edited by:
SomeoneElse -
I tried to search for this but did not come across anything in forums or MSDN.
Why this behavior? Is this correct or just a bug?
string.Format("{0:M}", DateTime.Now) -> March 12
It is supposed to give the month number? 3?
This works:
string.Format("{0:M }", DateTime.Now) -> 3
Why do I need the space? I tried this with CultureInfo.InvariantCulture and same. I mean I can add the space, but why?
noorbakhsh حميد نوربخشThis formatter giving you the number of month is:
string.Format("{0:MM}",DateTime)
However, you are missing one of the 'M's.
if you try the above code instead of yours, you will get the result of:
03 instead of 3
However, this is not the same as the above:
string.Format("{0:M}", DateTime.Now) -> March 12In this example you get Month and date together. In short, even a space is important. -
Demantra - Create New Series - Mdp_matrix - Data Type String Issue
I created a new series (MDP_matrix) that has the data type as String. The display format is BLANK.
I was able to load the data into mdp_matrix table for the series i created.
However, when i look at the series in a worksheet, it does not display the string value. It display zero. for some reason, it considers the series as numeric and not string. Any idea why that would be happening?
This is on version 7.2 using SQL server/tomcatHi
1. Have you tried giving display format i.e ###?
2. Is your server expression something like max (mdp_matrix. column_name)?
Tks
MJ -
HI All,
I have a basic query
SELECT grn_d
FROM GRN WHERE ROWNUM < 2The output of the above query is "5/15/1991 12:00:00 AM"
But when i am running the following block
DECLARE
grn_d_1 DATE;
BEGIN
SELECT grn_d INTO grn_d_1
FROM GRN WHERE ROWNUM < 2;
dbms_output.put_line(grn_d_1);
END;
The output is in 15-MAY-91 this format , how to get the result in the same format i.e. MM/DD/YYYY.This might help you to understand. Check my comments and run it.
DECLARE
v_d1 DATE;
v_d2 DATE;
v_d3 DATE;
v_cha VARCHAR2(20000);
-- v_vha VARCHAR2(20000); -- commented due to duplicate variable intialisation
str VARCHAR2(20000); -- Added new
BEGIN
v_d1:= to_date('01-JUN-15','DD-MON-YY');
v_d2 :=to_date('15-FEB-14','DD-MON-YY');
v_cha := 'SELECT least(:1, :2) FROM DUAL';
--v_vha := ''''||v_d1||''','''||v_d2||'''';
--EXECUTE IMMEDIATE v_cha INTO v_d3 USING v_vha; -- cant declare like this after USING clause a comma separated string variable
EXECUTE IMMEDIATE v_cha INTO v_d3 USING v_d1,v_d2;
dbms_output.PUT_LINE('v_d3 - 1 '||to_char(v_d3, 'dd-MON-yyyy'));
dbms_output.PUT_LINE('v_d3 - 2 '||to_char(v_d3,'MM/DD/YYYY'));
dbms_output.PUT_LINE('v_d3 - 3 '||v_d3);
dbms_output.PUT_LINE('--------------------------------');
dbms_output.PUT_LINE('-- If you not sure about no of bind variables then dont use USING clause, make it a one string to be executed dynamically --');
str := 'SELECT least(to_date('''||v_d1||'''),to_date('''||v_d2||''')) FROM DUAL'; -- Due to implicit conversion, here you have use to_date while preparing a stmt
EXECUTE IMMEDIATE str INTO v_d3; -- while executing dynamically it'll consider date as date not string due to to_date function
dbms_output.PUT_LINE('v_d3 - 1 '||to_char(v_d3, 'dd-MON-yyyy'));
dbms_output.PUT_LINE('v_d3 - 2 '||to_char(v_d3,'MM/DD/YYYY'));
dbms_output.PUT_LINE('v_d3 - 3 '||v_d3);
END;
OP :-
v_d3 - 1 15-FEB-2014
v_d3 - 2 02/15/2014
v_d3 - 3 15-FEB-14
-- If you are not sure about no of bind variables then dont use USING clause, make
it a one string to be executed dynamically --
v_d3 - 1 15-FEB-2014
v_d3 - 2 02/15/2014
v_d3 - 3 15-FEB-14
PL/SQL procedure successfully completed.Thanks! -
Gurus,
I have a table like
Talbe t1
C1 C2
4 P(DW,QA,QB,QC)
5 P(QF,QG,QH,QN)
6 P(QP,QR,QS,QT)My SQL
WITH in_parts AS
SELECT c1,
c2,
REGEXP_SUBSTR(REPLACE(c3,' '),'[^\(]*') AS outside_txt,
REGEXP_REPLACE(REPLACE(c3,' '),'.*\(([0-9,]+).*','\1') AS inside_txt
FROM t2 where t2.c1 = 'SPMALV50' and t2.c2 = 'PLAN 117592'
cntr AS
SELECT LEVEL AS n
FROM dual
CONNECT BY LEVEL <= 1 + ( SELECT MAX(LENGTH(inside_txt)-LENGTH(REPLACE(inside_txt,',')))
FROM in_parts )
SELECT c1,
c2,
outside_txt||REGEXP_SUBSTR(inside_txt,'[^,]+',1,n)
FROM in_parts
JOIN cntr ON n <= 1 + LENGTH(inside_txt) - LENGTH(REPLACE (inside_txt, ','))
order by 1,2,3;I am getting the output like
C1 C2
4 PP(DW
4 PQA
4 PQB
4 PQC)
5 PP(QF
5 PQG
5 PQH
5 PQN)
6 PP(QP
6 PQR
6 PQS
6 PQT)I need the output like
C1 C2
4 PDW
4 PQA
4 PQB
4 PQC
5 PQF
5 PQG
5 PQH
5 PQN
6 PQP
6 PQR
6 PQS
6 PQTThanks for help
007C 007 wrote:
My SQL
WITH in_parts AS
SELECT c1,
c2,
REGEXP_SUBSTR(REPLACE(c3,' '),'[^\(]*') AS outside_txt,
REGEXP_REPLACE(REPLACE(c3,' '),'.*\(([0-9,]+).*','\1') AS inside_txt
FROM t2 where t2.c1 = 'SPMALV50' and t2.c2 = 'PLAN 117592'
cntr AS
SELECT LEVEL AS n
FROM dual
CONNECT BY LEVEL <= 1 + ( SELECT MAX(LENGTH(inside_txt)-LENGTH(REPLACE(inside_txt,',')))
FROM in_parts )
SELECT c1,
c2,
outside_txt||REGEXP_SUBSTR(inside_txt,'[^,]+',1,n)
FROM in_parts
JOIN cntr ON n <= 1 + LENGTH(inside_txt) - LENGTH(REPLACE (inside_txt, ','))
order by 1,2,3;You could probably tweak your regular expressions for "OUTSIDE_TXT" and "INSIDE_TXT" a little bit and make it work.
regexp_replace(c3,'^(.*+)\(.*','\1') as outside_txt,
regexp_replace(c3,'.*+\((.*)\)','\1') as inside_txt
...Test:
test@ORA10G>
test@ORA10G> --
test@ORA10G> WITH t2 as
2 (
3 select 1 c1, 4 c2, 'P(DW,QA,QB,QC)' c3 from dual union all
4 select 2, 5, 'P(QF,QG,QH,QN)' from dual union all
5 select 3, 6, 'P(QP,QR,QS,QT)' from dual
6 ),
7 in_parts AS
8 (
9 SELECT c1,
10 c2,
11 regexp_replace(c3,'^(.*+)\(.*','\1') as outside_txt,
12 regexp_replace(c3,'.*+\((.*)\)','\1') as inside_txt
13 FROM t2 --where t2.c1 = 'SPMALV50' and t2.c2 = 'PLAN 117592'
14 ),
15 cntr AS
16 (
17 SELECT LEVEL AS n
18 FROM dual
19 CONNECT BY LEVEL <= 1 + ( SELECT MAX(LENGTH(inside_txt)-LENGTH(REPLACE(inside_txt,',')))
20 FROM in_parts )
21 )
22 SELECT c1,
23 c2,
24 outside_txt,
25 inside_txt,
26 n,
27 outside_txt||REGEXP_SUBSTR(inside_txt,'[^,)]+',1,n) as t1
28 FROM in_parts
29 JOIN cntr ON n <= 1 + LENGTH(inside_txt) - LENGTH(REPLACE (inside_txt, ','))
30 order by 1,2,3;
C1 C2 OUTSIDE_TXT INSIDE_TXT N T1
1 4 P DW,QA,QB,QC 4 PQC
1 4 P DW,QA,QB,QC 1 PDW
1 4 P DW,QA,QB,QC 2 PQA
1 4 P DW,QA,QB,QC 3 PQB
2 5 P QF,QG,QH,QN 4 PQN
2 5 P QF,QG,QH,QN 2 PQG
2 5 P QF,QG,QH,QN 1 PQF
2 5 P QF,QG,QH,QN 3 PQH
3 6 P QP,QR,QS,QT 3 PQS
3 6 P QP,QR,QS,QT 4 PQT
3 6 P QP,QR,QS,QT 1 PQP
3 6 P QP,QR,QS,QT 2 PQR
12 rows selected.
test@ORA10G>
test@ORA10G>HTH
isotope
Maybe you are looking for
-
Delete entries from internal table
Hello friends, I have a screen on which im displaying a table, now i have also provided an delete button which deletes the selected record. the record which i have written is GET CURSOR FIELD FLD LINE IND. READ
-
I've exported schema from database with CL8MSWIN1251 encoding and now I try to import it into database with AL32UTF8 character encoding. DBMS version is 10.2.0.4.0. At first, I've set nls_length_semantics to char in database. After that I've restarte
-
Hi, At present i am running EP 6 on Internet explore ver. 6. Now i want to run EP6 on IE 7. I checked and found EP 6 is not compatible with IE 7. Please any one can suggest me what i have to do. Regards, Abinash
-
Lightroom 4.4.1 odd file change problem
Hi folks, Let's see if I can accurately descibe this and perhaps get an explanation from you. I have a folder, for example, called 2004 keepers. Obviously, I have had this images since at least 2004 MANY of them are jpg's as I did not know enough to
-
Flash CS5 AS2 troubles multiple issuse
Hey I was just hoping for some quick replies/ solution i have been looking everywhere trying to find solutions to my problems, basically im making a flash game for college and its almost finished more or less and its got to be done by tomorrow so i w