When my program reads from the randomaccessfile it will only find the first file or the file with the lowest account number ( this is a banking program )
After that I get the IO exception with a read error
private RandomAccessFile input; // Random Aecess File input Stream
private Record data;
public static JFrame frame = new JFrame();
public CredRead() // Constructor CredRead created
{
// open the file
try {
// declare the output stream object and associate it to file
// file.dat
input = new RandomAccessFile("UnionDB.dat", "rw");
}
catch (IOException e) {
// if an error occurs display a message on the screen
System.err.println("File not opened properly\n " + e.toString());
// the program terminates due to error
System.exit(1);
}
data = new Record();
setPreferredSize(new Dimension(650, 400));
frame.setSize(getPreferredSize()); // Frame Size
frame.setLocationRelativeTo(null);
frame.setLayout(new GridLayout(7, 2)); // Grid Layout set
/* GUI Components */
frame.add(new Label("Enter Account Number and click Enter"));
account_num = new TextField();
frame.add(account_num);
account_num.addActionListener(this);
frame.add(new Label("First Name"));
first_name = new TextField(20);
first_name.setEditable(false);
frame.add(first_name);
frame.add(new Label("Last Name"));
last_name = new TextField(20);
last_name.setEditable(false);
frame.add(last_name);
frame.add(new Label("Available Funds"));
balance = new TextField(20);
balance.setEditable(false);
frame.add(balance);
frame.add(new Label("Overdraft Limit"));
overdraft = new TextField(20);
overdraft.setEditable(false);
frame.add(overdraft);
enter = new Button("Enter");
enter.addActionListener(this);
frame.add(enter);
done = new Button("Click to Exit");
done.addActionListener(this);
frame.add(done);
setVisible(true); // GUI components set as visible to the program
}
public void readRecord() {
DecimalFormat twoDigits = new DecimalFormat("0.00");
try {
do {
data.read(input);
} while (data.getAccount() == 0);
input.seek(
(long) ( data.getAccount()-1 ) * Record.size());
data.write( input );
account_num.setText(String.valueOf(data.getAccount()));
first_name.setText(data.getFirstName());
last_name.setText(data.getLastName());
balance.setText(String.valueOf(twoDigits.format(data.getBalance())));
overdraft.setText(String.valueOf(twoDigits.format(data.getOverdraft())));
}// end try
catch (EOFException eof) {
closeFile();
}
catch (IOException e) {
// if an error occurs display a message on the screen
System.err.println("Error during read from file\n " + e.toString());
// the program terminates due to error
// System.exit(1);
}
}
private void closeFile() {
try {
input.close();
// System.exit(1);
} catch (IOException e) {
// if an error occurs display a message on the screen
System.err.println("Error closing file\n " + e.toString());
// System.exit(1);
}
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == enter)
readRecord();
else if (e.getSource() == done)
frame.dispose();
else
frame.add(new TextField(" Account Not Found on Database "));
closeFile();
}
public static void main(String args[]) {
new CredRead();
}
}
My guess is that
data.getAccount() != 0
and so your loop only executes once, because you did it in a do ... while();
Try adding some debugging into your code and make sure what data.getAccount() is equal to.
Related
Using Eclipse, Mslink.jar (creates shortcuts), Java 1.8.0
The coding that fails. The JOptionPane never appears when I export this out to a .JAR
public static void main(String[] args) {
// create an empty combo box with items of type String
JComboBox<String> systems = new JComboBox<String>();
// add items to the combo box
systems.addItem("System1");
systems.addItem("System2");
systems.addItem("System5");
systems.addItem("System6");
systems.addItem("System7");
systems.addItem("System9");
systems.addItem("System10");
systems.addItem("System12");
systems.addItem("System14");
systems.addItem("System15");
systems.addItem("System16");
systems.addItem("System17");
systems.addItem("System18");
systems.addItem("System19");
systems.addItem("System20");
systems.addItem("System21");
systems.addItem("System22");
systems.addItem("System24");
systems.addItem("System30");
systems.addItem("System34");
systems.addItem("All Systems Install");
systems.setEditable(true);
JPanel steps = new JPanel();
JPanel firstStep = new JPanel();
JPanel secondStep = new JPanel();
frame.setSize(1200, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
frame.setLayout(new GridLayout(3, 1));
frame.add(steps);
frame.add(firstStep);
frame.add(secondStep);
Button go = new Button("Go");
Button go2 = new Button("Go");
Label stepInstruction = new Label(
"Please do each step in order to complete the process. First step requires you install Universal desktop for your system."
+ " Second step requires your username to find Universal desktop install");
Label instruction = new Label("Step 1: Please select a system to download from");
Label instruction2 = new Label("Step 2: Press Go when Universal Desktop is Installed");
// Steps Explained
steps.add(stepInstruction);
// First Step
firstStep.add(instruction);
firstStep.add(systems);
firstStep.add(go);
// Second Step
secondStep.add(instruction2);
secondStep.add(go2);
go.addActionListener(new ActionListener() {
#Override
public void actionPerformed(ActionEvent event) {
String selectedSystem = (String) systems.getSelectedItem();
System.out.println(selectedSystem);
try {
if (!selectedSystem.equalsIgnoreCase("All Systems Install")) {
// Open UD install page in Internet explorer
Runtime.getRuntime().exec("C:\\Program Files\\Internet Explorer\\iexplore.exe " + "https://"
+ selectedSystem
+ ".pos.infogenesisasp.com/infogenesis/install/universaldesktop/UniversalDesktop.application");
// Runtime.getRuntime().exec("C:\\Program Files\\Internet Explorer\\iexplore.exe
// "
// + "https://" + selectedSystem +
// ".pos.infogenesisasp.com/infogenesis/install/universaldesktop/");
}
} catch (Exception e) {
e.printStackTrace();
JOptionPane.showMessageDialog(frame, e);
}
frame.validate();
}
});
go2.addActionListener(new ActionListener() {
#Override
public void actionPerformed(ActionEvent event) {
String selectedSystem = (String) systems.getSelectedItem();
String Username = System.getProperty("user.name");
if (selectedSystem.equalsIgnoreCase("All Systems Install")) {
String[] systems = { "System1", "System2", "System5", "System6", "System7", "System9", "System10",
"System12", "System14", "System15", "System16", "System17", "System18", "System19",
"System20", "System21", "System22", "System24", "System30", "System34" };
for (int count = 0; count < systems.length; count++) {
try {
// Need to figure out a way to ensure the person installs UD before we can
// proceed
Runtime.getRuntime().exec("C:\\Program Files\\Internet Explorer\\iexplore.exe " + "https://"
+ systems[count]
+ ".pos.infogenesisasp.com/infogenesis/install/universaldesktop/UniversalDesktop.application");
count = systems.length;
} catch (IOException e) {
JOptionPane.showMessageDialog(frame, e);
e.printStackTrace();
}
}
} else {
// Single System installer
Installer(Username, selectedSystem);
JOptionPane.showMessageDialog(frame, "Installion Completed!");
}
}
});
}
import mslinks.ShellLink;
public static void createShortcut(String folder, String system) throws IOException
{
ShellLink.createLink(folder, system);
JOptionPane.showMessageDialog(frame, "Created Shortcut!");
}
File system:
This code works fine in Eclipse, but exporting to a JAR causes it to fail. Is there something missing preventing the Referenced Libaries Mslinks.jar from loading? I've tried everything in Eclipse's export
Basically, I click a JButton (unipedal) and it pops up with a JOptionPane with a few JTextFields. I want to take the String inputs of these JTextFields and:
Check to make sure the string values are in a HashMap I have of type (posTasks.taskType), which they should be
Then create a new UNIPEDALImpl object with those Strings as parameters
Use the Strings as keys to another HashMap of type (jLabelsHM) to hide the JLabel if the key of this HashMap returns true when used as a key in posTasks.completedTasks.
I am getting several errors and I can't figure out why.
unipedal.addActionListener(new java.awt.event.ActionListener() {
#SuppressWarnings("null")
#Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
String robotName = null;
String firstTask = null;
String secondTask = null;
String thirdTask = null;
String fourthTask = null;
String fifthTask = null;
JPanel inputBox = new JPanel();
inputBox.setLayout(new GridLayout(0, 2, 3, 4));
JTextField name = new JTextField(15);
JTextField task1 = new JTextField(15);
JTextField task2 = new JTextField(15);
JTextField task3 = new JTextField(15);
JTextField task4 = new JTextField(15);
JTextField task5 = new JTextField(15);
inputBox.add(new JLabel("Robot's Name:"));
inputBox.add(name);
inputBox.add(new JLabel("Task 1:"));
inputBox.add(task1);
inputBox.add(new JLabel("Task 2:"));
inputBox.add(task2);
inputBox.add(new JLabel("Task 3:"));
inputBox.add(task3);
inputBox.add(new JLabel("Task 4:"));
inputBox.add(task4);
inputBox.add(new JLabel("Task 5:"));
inputBox.add(task5);
int option = JOptionPane.showConfirmDialog(middle,inputBox,
"Please fill all the fields", JOptionPane.OK_CANCEL_OPTION);
if (option == JOptionPane.OK_OPTION) {
robotName.equals(name.getText());
firstTask.equals(task1.getText());
secondTask.equals(task2.getText());
thirdTask.equals(task3.getText());
fourthTask.equals(task4.getText());
fifthTask.equals(task5.getText());
if (!posTasks.taskType.containsKey(firstTask)||!posTasks.taskType.containsKey(secondTask)||!posTasks.taskType.containsKey(thirdTask)||!posTasks.taskType.containsKey(fourthTask)||!posTasks.taskType.containsKey(fifthTask)) {
throw new IllegalArgumentException("One or more of the tasks you have requested are invalid. Please choose tasks from the list provided and check your spelling!");
}
try {
UNIPEDALImpl unipedal = new UNIPEDALImpl(firstTask, secondTask, thirdTask, fourthTask,
fifthTask);
LinkedList<String>tasksList = new LinkedList <String>();
tasksList.add(firstTask);
tasksList.add(secondTask);
tasksList.add(thirdTask);
tasksList.add(fourthTask);
tasksList.add(fifthTask);
for (String task : tasksList) {
if (posTasks.completedTasks.get(task) == true) {
throw new IllegalArgumentException(task + "has already been completed. Please choose a different task or use 'refresh' if you want the task to be completed again");
}
unipedal.time += unipedal.taskTimes.get(task);
posTasks.completedTasks.put(task, true);
unipedal.tasksList.remove(task);
unipedal.taskCounter++;
}
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
for (Entry<String, JLabel> entry : jLabelsHM.entrySet()) {
if(posTasks.completedTasks.get(entry.getKey()) == true) {
jLabelsHM.get(entry.getKey()).setVisible(false);
}
}
}
}
});
First of all we don't have UNIPEDALImpl class here, so with a black-box view, I can not tell you if there is an error within that part.
About the problems in your code. first it seems that you want to fill your variable with equals method which is wrong, you need to use = sign.
equals methos is for comparing two objects not assigning variables.
robotName = name.getText();
firstTask = task1.getText();
secondTask = task2.getText();
thirdTask = task3.getText();
fourthTask = task4.getText();
fifthTask = task5.getText();
then you move from there.
I'm working on a project for my Java class, we just have to modify code. I had to add a Save and Save As dialog box to a basic text file document. When I do Save As the first time its fine, but then do save as again but hit cancel it resets the file to null. I have made it so at least the title still stays but when you hit the Save button it acts like its a null file and save as dialog box appears again. I want it so when you cancel Save As, it keeps the previous file instead of going back to null. I'm still formatting it, so its funky
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class JavaEdit extends Frame implements ActionListener {
String clipBoard;
String fileName;
TextArea text;
MenuItem newMI, openMI, saveMI, saveAsMI, exitMI;
MenuItem selectAll, cutMI, copyMI, deleteMI, pasteMI;
MenuItem about;
/**
* Constructor
*/
public JavaEdit() {
super("JavaEdit"); // set frame title
setLayout(new BorderLayout()); // set layout
// create menu bar
MenuBar menubar = new MenuBar();
setMenuBar(menubar);
// create file menu
Menu fileMenu = new Menu("File");
menubar.add(fileMenu);
newMI = fileMenu.add(new MenuItem("New"));
newMI.addActionListener(this);
openMI = fileMenu.add(new MenuItem("Open"));
openMI.addActionListener(this);
fileMenu.addSeparator();
saveMI = fileMenu.add(new MenuItem("Save"));
saveMI.addActionListener(this);
saveAsMI = fileMenu.add(new MenuItem("Save As ..."));
saveAsMI.addActionListener(this);
fileMenu.addSeparator();
exitMI = fileMenu.add(new MenuItem("Exit"));
exitMI.addActionListener(this);
// create edit menu
Menu editMenu = new Menu("Edit");
menubar.add(editMenu);
selectAll = editMenu.add(new MenuItem("Select All"));
selectAll.addActionListener(this);
cutMI = editMenu.add(new MenuItem("Cut"));
cutMI.addActionListener(this);
copyMI = editMenu.add(new MenuItem("Copy"));
copyMI.addActionListener(this);
pasteMI = editMenu.add(new MenuItem("Paste"));
pasteMI.addActionListener(this);
deleteMI = editMenu.add(new MenuItem("Delete"));
deleteMI.addActionListener(this);
Menu helpMenu = new Menu("Help");
menubar.add(helpMenu);
about = helpMenu.add(new MenuItem("About"));
about.addActionListener(this);
// create text editing area
text = new TextArea();
add(text, BorderLayout.CENTER);
}
// implementing ActionListener
public void actionPerformed(ActionEvent event) {
Object source = event.getSource();
if(source == newMI) {
clearText();
fileName = null;
setTitle("JavaEdit"); // reset frame title
}
else if(source == openMI) {
doOpen();
}
else if (source == saveAsMI) {
doSaveAs();
}
else if (source == saveMI) {
doSave();
}
else if(source == exitMI) {
System.exit(0);
}
else if(source == selectAll) {
doSelect();
}
else if(source == cutMI) {
doCopy();
doDelete();
}
else if(source == copyMI) {
doCopy();
}
else if(source == pasteMI) {
doPaste();
}
else if(source == deleteMI) {
doDelete();
}
else if(source == about){
MessageDialog dialog = new MessageDialog(this, "About",
"JavaEdit in Java, Version 2.0, 2017");
dialog.setVisible(true);
return;
}
}
/**
* method to specify and open a file
*/
private void doOpen() {
// display file selection dialog
FileDialog fDialog = new FileDialog(this, "Open ...", FileDialog.LOAD);
fDialog.setVisible(true);
// Get the file name chosen by the user
String name = fDialog.getFile();
// If user canceled file selection, return without doing anything.
if(name == null)
return;
fileName = fDialog.getDirectory() + name;
// Try to create a file reader from the chosen file.
FileReader reader=null;
try {
reader = new FileReader(fileName);
} catch (FileNotFoundException ex) {
MessageDialog dialog = new MessageDialog(this, "Error Message",
"File Not Found: "+fileName);
dialog.setVisible(true);
return;
}
BufferedReader bReader = new BufferedReader(reader);
// Try to read from the file one line at a time.
StringBuffer textBuffer = new StringBuffer();
try {
String textLine = bReader.readLine();
while (textLine != null) {
textBuffer.append(textLine + '\n');
textLine = bReader.readLine();
}
bReader.close();
reader.close();
} catch (IOException ioe) {
MessageDialog dialog = new MessageDialog(this, "Error Message",
"Error reading file: "+ioe.toString());
dialog.setVisible(true);
return;
}
setTitle("JavaEdit: " +name); // reset frame title
text.setText(textBuffer.toString());
}
private void doSaveAs() {
FileDialog fDialog = new FileDialog(this, "Save As ...", FileDialog.SAVE);
fDialog.setVisible(true);
fileName = fDialog.getFile();
String name = fileName.toString();
setTitle("JavaEdit: " + name); // reset frame title
fDialog.setFile(name);
FileWriter fileCharStream = null; // File stream for writing file
try {
fileCharStream = new FileWriter(fileName); // May throw IOException
// Use file output stream
fileCharStream.write(text.getText());
} catch (IOException excpt) {
MessageDialog dialog = new MessageDialog(this, "Error Message",
fileName);
dialog.setVisible(true);
return;
} finally {
closeFileWriter(fileCharStream); // Ensure file is closed!
}
}
private void doSave() {
if(fileName == null )
{
doSaveAs();
}
FileWriter out = null;
try {
out =new FileWriter(fileName);
out.write(text.getText());
}
catch (IOException excpt) {
MessageDialog dialog = new MessageDialog(this, "Error Message",
fileName);
dialog.setVisible(true);
return;
} finally {
closeFileWriter(out); // Ensure file is closed!
}// Ensure file is closed!
}
static void closeFileWriter(FileWriter fileName) {
try {
if (fileName != null) { // Ensure "file" references a valid object
fileName.close(); // close() may throw IOException if fails
}
} catch (IOException closeExcpt) {
closeExcpt.getMessage();
}
return;
}
private void doSelect() {
text.selectAll();
}
/**
* method to clear text editing area
*/
private void clearText() {
text.setText("");
}
/**
* method to copy selected text to the clipBoard
*/
private void doCopy() {
clipBoard = new String(text.getSelectedText());
}
/**
* method to delete selected text
*/
private void doDelete() {
text.replaceRange("", text.getSelectionStart(), text.getSelectionEnd());
}
/**
* method to replace current selection with the contents of the clipBoard
*/
private void doPaste() {
if(clipBoard != null) {
text.replaceRange(clipBoard, text.getSelectionStart(),
text.getSelectionEnd());
}
}
/**
* class for message dialog
*/
class MessageDialog extends Dialog implements ActionListener {
private Label message;
private Button okButton;
// Constructor
public MessageDialog(Frame parent, String title, String messageString) {
super(parent, title, true);
setSize(400, 100);
setLocation(150, 150);
setLayout(new BorderLayout());
message = new Label(messageString, Label.CENTER);
add(message, BorderLayout.CENTER);
Panel panel = new Panel(new FlowLayout(FlowLayout.CENTER));
add(panel, BorderLayout.SOUTH);
okButton = new Button(" OK ");
okButton.addActionListener(this);
panel.add(okButton);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
setVisible(false);
dispose();
}
});
}
// implementing ActionListener
public void actionPerformed(ActionEvent event) {
setVisible(false);
dispose();
}
}
/**
* the main method
*/
public static void main(String[] argv) {
// create frame
JavaEdit frame = new JavaEdit();
Dimension size = Toolkit.getDefaultToolkit().getScreenSize();
frame.setSize(size.width-80, size.height-80);
frame.setLocation(20, 20);
// add window closing listener
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
// show the frame
frame.setVisible(true);
}
}
Simply check if the returned file is null:
String name = fDialog.getFile();
// if Cancel is pressed we just exit
if (name == null) {
return;
}
// otherwise we save it
fileName = name;
...
I am working on a text editor in Java as a fun side project. When I exported the project, I converted to executable JAR file to ".exe" so that I could set the text editor as the default program to open ".txt" files. I can run the ".exe" and write text and then save the file, and the file saves, but the contents of the file are not saved when I try to open the file with the text editor; however, I can open the same file with notepad, and the contents of the file show. The file saves fine in Eclipse. What do I need to fix so that the file contents are shown when I try to open them with my text editor?
Here is my code:
public class Open extends JFrame implements KeyListener {
JPanel panel = new JPanel();
JTextArea textArea = new JTextArea();
JScrollPane scrollPane = new JScrollPane(textArea);
JMenuBar menuBar = new JMenuBar();
JMenu menu;
JMenuItem item;
Font systemFont;
public Open() {
systemFont = new Font("Times New Roman", Font.PLAIN, 20);
textArea.setLineWrap(true);
textArea.setWrapStyleWord(false);
textArea.setFont(systemFont);
panel.setLayout(new BorderLayout());
panel.add(scrollPane);
add(panel);
menu = new JMenu("File");
item = new JMenuItem("Save As");
item.setAccelerator(KeyStroke.getKeyStroke('S', Toolkit.getDefaultToolkit ().getMenuShortcutKeyMask()));
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
JFileChooser JFC = new JFileChooser();
File fileName = new File("");
BufferedWriter writer = null;
try {
int rVal = JFC.showSaveDialog(Open.this);
if(rVal == JFileChooser.APPROVE_OPTION) {
writer = new BufferedWriter(new FileWriter(JFC.getSelectedFile()));
writer.write(textArea.getText());
}
} catch(Exception e) {
e.printStackTrace();
} finally {
if(writer != null) {
try {
writer.close();
} catch(IOException e) {
e.printStackTrace();
}
}
}
}
});
menu.add(item);
menuBar.add(menu);
menu = new JMenu("Edit");
item = new JMenuItem("Undo");
menu.add(item);
menu.add(item);
menuBar.add(menu);
add("North", menuBar);
setLookAndFeel();
frameDetails("Text Editor");
}
public void frameDetails(String title) {
setSize(700, 500);
setLocationRelativeTo(null);
setTitle(title);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void setLookAndFeel() {
try {
UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());
SwingUtilities.updateComponentTreeUI(this);
} catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
Open editor = new Open();
}
}
Here is the bit of code with the save button:
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
JFileChooser JFC = new JFileChooser();
File fileName = new File("");
BufferedWriter writer = null;
try {
int rVal = JFC.showSaveDialog(Open.this);
if(rVal == JFileChooser.APPROVE_OPTION) {
writer = new BufferedWriter(new FileWriter(JFC.getSelectedFile()));
writer.write(textArea.getText());
}
} catch(Exception e) {
e.printStackTrace();
} finally {
if(writer != null) {
try {
writer.close();
} catch(IOException e) {
e.printStackTrace();
}
}
}
}
});
You are never reading the text file. In order to do that, Use something like this
public void loadFile(JTextArea area, String path, String file)
{
try
{
area.read(new FileReader(path + file), "Default");
}
catch(IOException e)
{
e.printStackTrace();
}
}
Note: You don't have to have this in a method. You could just use the try - catch code
To act as a default text editor, your program needs to accept a file name as the argument to main (String[] args). It should verify the file exists, then open it, read its contents, and close it.
Also, when you save a file you should rename the former version to "name.bak" or "name~" before overwriting it with the new version, in case something goes wrong during the save.
I have a JFormattedTextField that is meant for user to enter phone number. My phone number is taking the following format :+### ###-###-###. I want to check for empty string before I save the phone number to a database. The problem is I am not able to check/determine if the field is empty. When I print field.getText().length() it outputs 16 meaning some characters are already in the field. How do I check if the user has entered some characters?
Below is my code:
public class JTextFiledDemo {
private JFrame frame;
JTextFiledDemo() throws ParseException {
frame = new JFrame();
frame.setVisible(true);
frame.setSize(300, 300);
frame.setLayout(new GridLayout(4, 1));
frame.setLocationRelativeTo(null);
iniGui();
}
private void iniGui() throws ParseException {
JButton login = new JButton("Test");
JFormattedTextField phone = new JFormattedTextField(new MaskFormatter(
"+### ###-###-###"));
frame.add(phone);
frame.add(login);
frame.pack();
login.addActionListener((ActionEvent) -> {
JOptionPane.showMessageDialog(frame, "The length of input is :"
+ phone.getText().length());
});
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
JTextFiledDemo tf = new JTextFiledDemo();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
}
You can used the isEditValid() method to check the contents
final boolean editValid = phone.isEditValid();
showMessageDialog(frame, "The length of input is :" + phone.getText().length() + ". It is " + (editValid ? "" : "not ") + "valid!");