jnr.posix.POSIX.unsetenv()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(134)

本文整理了Java中jnr.posix.POSIX.unsetenv()方法的一些代码示例,展示了POSIX.unsetenv()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。POSIX.unsetenv()方法的具体详情如下:
包路径:jnr.posix.POSIX
类名称:POSIX
方法名:unsetenv

POSIX.unsetenv介绍

暂无

代码示例

代码示例来源:origin: com.github.jnr/jnr-posix

public int unsetenv(String envName) {
  try { return posix.unsetenv(envName); } catch (UnsatisfiedLinkError ule) { return unimplementedInt(); }
}

代码示例来源:origin: com.cloudbees.util/jnr-unixsocket-nodep

public int unsetenv(String envName) {
  return posix().unsetenv(envName);
}

代码示例来源:origin: com.cloudbees.util/jnr-unixsocket-nodep

public int unsetenv(String envName) {
  try { return posix.unsetenv(envName); } catch (UnsatisfiedLinkError ule) { return unimplementedInt(); }
}

代码示例来源:origin: io.prestosql.cassandra/cassandra-driver

public int unsetenv(String envName) {
  return posix().unsetenv(envName);
}

代码示例来源:origin: com.github.jnr/jnr-posix

public int unsetenv(String envName) {
  return posix().unsetenv(envName);
}

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver

public int unsetenv(String envName) {
  try { return posix.unsetenv(envName); } catch (UnsatisfiedLinkError ule) { return unimplementedInt(); }
}

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver

public int unsetenv(String envName) {
  return posix().unsetenv(envName);
}

代码示例来源:origin: io.prestosql.cassandra/cassandra-driver

public int unsetenv(String envName) {
  try { return posix.unsetenv(envName); } catch (UnsatisfiedLinkError ule) { return unimplementedInt(); }
}

代码示例来源:origin: org.jruby/jruby-core

private IRubyObject case_aware_op_aset(ThreadContext context, IRubyObject key, final IRubyObject value) {
  if (!isStringLike(key)) {
    throw context.runtime.newTypeError("can't convert " + key.getMetaClass() + " into String");
  }
  RubyString keyAsStr = key.convertToString();
  if (!isCaseSensitive()) key = keyAsStr = getCorrectKey(keyAsStr);
  if (value == context.nil) {
    return super.delete(context, key, org.jruby.runtime.Block.NULL_BLOCK);
  }
  if (!isStringLike(value)) {
    throw context.runtime.newTypeError("can't convert " + value.getMetaClass() + " into String");
  }
  RubyString valueAsStr = normalizeEnvString(context, keyAsStr, value.convertToString());
  if (updateRealENV) {
    final POSIX posix = context.runtime.getPosix();
    final String keyAsJava = keyAsStr.asJavaString();
    // libc (un)setenv is not reentrant, so we need to synchronize across the entire JVM (JRUBY-5933)
    if (valueAsStr == context.nil) {
      synchronized (Object.class) { posix.unsetenv(keyAsJava); }
    } else {
      final String valueAsJava = valueAsStr.asJavaString();
      synchronized (Object.class) { posix.setenv(keyAsJava, valueAsJava, 1); }
    }
  }
  return super.op_aset(context, keyAsStr, valueAsStr);
}

代码示例来源:origin: org.jruby/jruby-complete

private IRubyObject case_aware_op_aset(ThreadContext context, IRubyObject key, final IRubyObject value) {
  if (!isStringLike(key)) {
    throw context.runtime.newTypeError("can't convert " + key.getMetaClass() + " into String");
  }
  RubyString keyAsStr = key.convertToString();
  if (!isCaseSensitive()) key = keyAsStr = getCorrectKey(keyAsStr);
  if (value == context.nil) {
    return super.delete(context, key, org.jruby.runtime.Block.NULL_BLOCK);
  }
  if (!isStringLike(value)) {
    throw context.runtime.newTypeError("can't convert " + value.getMetaClass() + " into String");
  }
  RubyString valueAsStr = normalizeEnvString(context, keyAsStr, value.convertToString());
  if (updateRealENV) {
    final POSIX posix = context.runtime.getPosix();
    final String keyAsJava = keyAsStr.asJavaString();
    // libc (un)setenv is not reentrant, so we need to synchronize across the entire JVM (JRUBY-5933)
    if (valueAsStr == context.nil) {
      synchronized (Object.class) { posix.unsetenv(keyAsJava); }
    } else {
      final String valueAsJava = valueAsStr.asJavaString();
      synchronized (Object.class) { posix.setenv(keyAsJava, valueAsJava, 1); }
    }
  }
  return super.op_aset(context, keyAsStr, valueAsStr);
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

protected IRubyObject case_aware_op_aset(ThreadContext context, IRubyObject key, IRubyObject value, boolean caseSensitive) {
  if (!key.respondsTo("to_str")) {
    throw getRuntime().newTypeError("can't convert " + key.getMetaClass() + " into String");
  }
  if (!value.respondsTo("to_str") && !value.isNil()) {
    throw getRuntime().newTypeError("can't convert " + value.getMetaClass() + " into String");
  }
  if (! caseSensitive) {
    key = getCorrectKey(key, context);
  }
  if (value.isNil()) {
    return super.delete(context, key, org.jruby.runtime.Block.NULL_BLOCK);
  }
  IRubyObject keyAsStr = normalizeEnvString(Helpers.invoke(context, key, "to_str"));
  IRubyObject valueAsStr = value.isNil() ? getRuntime().getNil() :
      normalizeEnvString(Helpers.invoke(context, value, "to_str"));
  if (updateRealENV) {
    POSIX posix = getRuntime().getPosix();
    String keyAsJava = keyAsStr.asJavaString();
    // libc (un)setenv is not reentrant, so we need to synchronize across the entire JVM (JRUBY-5933)
    if (valueAsStr == getRuntime().getNil()) {
      synchronized (Object.class) { posix.unsetenv(keyAsJava); }
    } else {
      synchronized (Object.class) { posix.setenv(keyAsJava, valueAsStr.asJavaString(), 1); }
    }
  }
  return super.op_aset(context, keyAsStr, valueAsStr);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

protected IRubyObject case_aware_op_aset(ThreadContext context, IRubyObject key, IRubyObject value, boolean caseSensitive) {
  if (!key.respondsTo("to_str")) {
    throw getRuntime().newTypeError("can't convert " + key.getMetaClass() + " into String");
  }
  if (!value.respondsTo("to_str") && !value.isNil()) {
    throw getRuntime().newTypeError("can't convert " + value.getMetaClass() + " into String");
  }
  if (! caseSensitive) {
    key = getCorrectKey(key, context);
  }
  if (value.isNil()) {
    return super.delete(context, key, org.jruby.runtime.Block.NULL_BLOCK);
  }
  IRubyObject keyAsStr = normalizeEnvString(Helpers.invoke(context, key, "to_str"));
  IRubyObject valueAsStr = value.isNil() ? getRuntime().getNil() :
      normalizeEnvString(Helpers.invoke(context, value, "to_str"));
  if (updateRealENV) {
    POSIX posix = getRuntime().getPosix();
    String keyAsJava = keyAsStr.asJavaString();
    // libc (un)setenv is not reentrant, so we need to synchronize across the entire JVM (JRUBY-5933)
    if (valueAsStr == getRuntime().getNil()) {
      synchronized (Object.class) { posix.unsetenv(keyAsJava); }
    } else {
      synchronized (Object.class) { posix.setenv(keyAsJava, valueAsStr.asJavaString(), 1); }
    }
  }
  return super.op_aset(context, keyAsStr, valueAsStr);
}

相关文章

POSIX类方法