Example usage for org.apache.commons.lang3 StringUtils EMPTY

List of usage examples for org.apache.commons.lang3 StringUtils EMPTY

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils EMPTY.

Prototype

String EMPTY

To view the source code for org.apache.commons.lang3 StringUtils EMPTY.

Click Source Link

Document

The empty String "" .

Usage

From source file:com.tesshu.subsonic.client.sample4_music_andmovie.StreamDownloadAndPlayApplication.java

@Override
public void start(Stage stage) throws Exception {

    Search2Controller search2 = context.getBean(Search2Controller.class);

    StreamController streamController = context.getBean(StreamController.class);

    SuccessObserver callback = context.getBean(SuccessObserver.class);

    File tmpDirectory = new File(tmpPath);
    tmpDirectory.mkdir();/*from   www. jav  a 2  s  .  c om*/

    Optional<SearchResult2> result2 = search2.getOf("e", null, null, null, null, 1, null, null);

    result2.ifPresent(result -> {
        Optional<Child> maybeSong = result.getSongs().stream().findFirst();
        maybeSong.ifPresent(song -> {

            streamController.stream(song, maxBitRate, format, null, null, null, null,
                    (subject, inputStream, contentLength) -> {

                        File dir = new File(
                                tmpPath + "/" + song.getPath().replaceAll("([^/]+?)?$", StringUtils.EMPTY));
                        dir.mkdirs();

                        File file = new File(tmpPath + "/"
                                + song.getPath().replaceAll("([^.]+?)?$", StringUtils.EMPTY) + format);

                        try {
                            BufferedOutputStream fos = new BufferedOutputStream(new FileOutputStream(file));
                            BufferedInputStream reader = new BufferedInputStream(inputStream);

                            byte buf[] = new byte[256];
                            int len;
                            while ((len = reader.read(buf)) != -1) {
                                fos.write(buf, 0, len);
                            }
                            fos.flush();
                            fos.close();
                            reader.close();
                            inputStream.close();
                        } catch (IOException e) {
                            e.printStackTrace();
                        }

                        String path = Paths.get(file.getPath()).toUri().toString();
                        Group root = new Group();
                        Scene scene = new Scene(root, 640, 480);
                        Media media = new Media(path);
                        MediaPlayer player = new MediaPlayer(media);
                        MediaView view = new MediaView(player);
                        ((Group) scene.getRoot()).getChildren().add(view);
                        stage.setScene(scene);
                        stage.show();

                        player.play();

                    }, callback);

        });

    });
}

From source file:it.scoppelletti.mobilepower.preference.BTDevicePreference.java

public void run(BluetoothAdapter adapter) {
    int i, n;/*from   w w w  .  jav  a2  s.co m*/
    CharSequence[] entries, entryValues;
    Set<BluetoothDevice> devices;

    devices = adapter.getBondedDevices();
    n = devices.size();
    if (n > 0) {
        entries = new CharSequence[n];
        entryValues = new CharSequence[n];
        i = 0;
        for (BluetoothDevice device : devices) {
            entries[i] = BTManager.getName(device);
            entryValues[i] = device.getAddress();
            i++;
        }
    } else {
        entries = new CharSequence[1];
        entryValues = new CharSequence[1];

        entries[0] = getContext().getText(R.string.lbl_BTNoDevicePaired);
        entryValues[0] = StringUtils.EMPTY;
    }

    setEntries(entries);
    setEntryValues(entryValues);
}

From source file:de.knightsoftnet.validators.rebind.GwtReflectGetterGenerator.java

@Override
public final String generate(final TreeLogger plogger, final GeneratorContext pcontext, final String ptypeName)
        throws UnableToCompleteException {
    try {// w w  w .  j ava  2s . c o m
        plogger.log(TreeLogger.DEBUG, "Start generating for " + ptypeName + ".");

        final JClassType classType = pcontext.getTypeOracle().getType(ptypeName);
        final TypeOracle typeOracle = pcontext.getTypeOracle();
        assert typeOracle != null;
        final JClassType reflectorType = this.findType(plogger, typeOracle, ptypeName);

        // here you would retrieve the metadata based on typeName for this class
        final SourceWriter src = this.getSourceWriter(classType, pcontext, plogger);

        // generator is called more then once in a build, with second call, we don't get
        // a writer and needn't generate the class once again
        if (src != null) {
            final Class<?>[] classes = this.getBeans(plogger, reflectorType);

            src.println("@Override");
            src.println("public final Object getProperty(final Object pbean, final String pname)"
                    + " throws NoSuchMethodException, ReflectiveOperationException {");

            src.println("  if (pbean == null) {");
            src.println("    throw new NoSuchMethodException(\"A null object has no getters\");");
            src.println("  }");
            src.println("  if (pname == null) {");
            src.println("    throw new NoSuchMethodException(\"No method to get property for null\");");
            src.println("  }");
            src.println(StringUtils.EMPTY);

            for (final Class<?> clazz : classes) {
                final String className = clazz.getName();
                plogger.log(TreeLogger.DEBUG, "Generating getter reflections for class " + className);

                // Describe the bean properties
                final PropertyDescriptor[] properties = PropertyUtils.getPropertyDescriptors(clazz);

                src.println("  if (pbean.getClass() == " + className + ".class) {");
                src.println("    switch (pname) {");

                // for all getters generate a case and return entry
                for (final PropertyDescriptor property : properties) {

                    final Method readMethod = property.getReadMethod();
                    final String name = property.getName();
                    if (readMethod == null) {
                        continue; // If the property cannot be read
                    }
                    plogger.log(TreeLogger.DEBUG, "Add getter for property " + name);

                    // Invoke the getter on the bean
                    src.println("      case \"" + name + "\":");
                    src.println("        return ((" + className + ") pbean)." + readMethod.getName() + "();");
                }

                src.println("      default:");
                src.println("        throw new NoSuchMethodException(\"Class " + className
                        + " has no getter for porperty \" + pname);");
                src.println("    }");
                src.println("  }");
            }
            src.println("  throw new ReflectiveOperationException(\"Class \" + "
                    + "pbean.getClass().getName() + \" is not reflected\");");
            src.println("}");

            plogger.log(TreeLogger.DEBUG, "End of generating reached");

            src.commit(plogger);
        }
        return this.getClassPackage(classType) + "." + this.getClassName(classType);
    } catch (final NotFoundException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:com.aqnote.app.wifianalyzer.vendor.model.VendorServiceTest.java

@Test
public void testFindWithMacAddressesBelongToSameVendor() throws Exception {
    // setup/*from w ww.  j  a va2  s . com*/
    fixture.findVendorName(MAC_IN_RANGE1);
    // execute
    String actual = fixture.findVendorName(MAC_IN_RANGE2);
    fixture.findVendorName(MAC_IN_RANGE2.toLowerCase());
    // validate
    verify(database).find(MAC_IN_RANGE1);
    verify(remoteCall).execute(MAC_IN_RANGE1);
    verify(remoteCall, never()).execute(MAC_IN_RANGE2);
    verify(remoteCall, never()).execute(MAC_IN_RANGE2.toLowerCase());

    assertEquals(StringUtils.EMPTY, actual);
    assertSame(StringUtils.EMPTY, actual);
}

From source file:com.norconex.commons.lang.xml.EnhancedXMLStreamWriter.java

private void writeAttributeObject(String localName, Object value) throws XMLStreamException {
    String strValue = Objects.toString(value, null);
    if (StringUtils.isNotBlank(strValue)) {
        writeAttribute(localName, strValue);
    } else if (writeBlanks) {
        writeAttribute(localName, StringUtils.EMPTY);
    }// ww  w.j  av a  2 s . c o m
}

From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.SignTest.java

@Test(expected = IllegalArgumentException.class)
public void testGetNameLocaleDeCannotBeEmpty() {
    new Sign.Builder().setId(0).setName(FOOTBALL).setNameLocaleDe(StringUtils.EMPTY).setMnemonic(KICK_A_BALL)
            .setStarred(false).setLearningProgress(0).create();
}

From source file:com.cognifide.qa.bb.aem.touch.pageobjects.touchui.DialogConfigurer.java

/**
 * Returns the label of given field.//ww  w  . j av  a  2s . c  o m
 * Label may not be present in the field, thus a workaround using list is introduced here.
 *
 * @param field WebElement corresponding to the given field
 * @return label of the field or {@code StringUtils.Empty} when there is none
 */
private String getFieldLabel(WebElement field) {
    List<WebElement> labelField = field.findElements(LABEL_SELECTOR);
    return labelField.isEmpty() ? StringUtils.EMPTY : labelField.get(0).getText();
}

From source file:com.willwinder.universalgcodesender.TinyGController.java

public TinyGController(AbstractCommunicator abstractCommunicator) {
    super(abstractCommunicator);
    capabilities = new Capabilities();
    commandCreator = new TinyGGcodeCommandCreator();

    firmwareSettings = new TinyGFirmwareSettings(this);
    abstractCommunicator.setListenAll(firmwareSettings);

    controllerStatus = new ControllerStatus(StringUtils.EMPTY, ControllerState.UNKNOWN,
            new Position(0, 0, 0, UnitUtils.Units.MM), new Position(0, 0, 0, UnitUtils.Units.MM));
    firmwareVersion = "TinyG unknown version";
}

From source file:io.knotx.knot.templating.impl.HandlebarsKnotProxyImpl.java

private String snippetComment(String commentTemplate) {
    String debugLine = StringUtils.EMPTY;
    if (configuration.templateDebug()) {
        debugLine = commentTemplate;/*from  w w  w  . j a va  2 s  . c  o  m*/
    }
    return debugLine;
}

From source file:gobblin.writer.partitioner.TimeBasedWriterPartitioner.java

private static String getWriterPartitionSuffix(State state, int numBranches, int branchId) {
    String propName = ForkOperatorUtils.getPropertyNameForBranch(WRITER_PARTITION_SUFFIX, numBranches,
            branchId);//www.ja  v a2 s  .  co m
    return state.getProp(propName, StringUtils.EMPTY);
}